Changeset 29484 in osm for applications/editors/josm/plugins/imagerycache/src/org/mapdb/Serializer.java
- Timestamp:
- 2013-04-07T17:07:27+02:00 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/imagerycache/src/org/mapdb/Serializer.java
r29363 r29484 20 20 import java.io.DataOutput; 21 21 import java.io.IOException; 22 import java.io.Serializable; 22 23 import java.util.zip.CRC32; 23 24 … … 148 149 */ 149 150 150 public static finalSerializer<byte[]> CRC32_CHECKSUM = new Serializer<byte[]>() {151 Serializer<byte[]> CRC32_CHECKSUM = new Serializer<byte[]>() { 151 152 @Override 152 153 public void serialize(DataOutput out, byte[] value) throws IOException { … … 174 175 175 176 177 Serializer<byte[] > BYTE_ARRAY_SERIALIZER = new Serializer<byte[]>() { 178 179 @Override 180 public void serialize(DataOutput out, byte[] value) throws IOException { 181 out.write(value); 182 } 183 184 @Override 185 public byte[] deserialize(DataInput in, int available) throws IOException { 186 byte[] ret = new byte[available]; 187 in.readFully(ret); 188 return ret; 189 } 190 } ; 191 192 193 class CompressSerializerWrapper<E> implements Serializer<E>, Serializable { 194 protected final Serializer<E> serializer; 195 public CompressSerializerWrapper(Serializer<E> serializer) { 196 this.serializer = serializer; 197 } 198 199 @Override 200 public void serialize(DataOutput out, E value) throws IOException { 201 //serialize to byte[] 202 DataOutput2 out2 = new DataOutput2(); 203 serializer.serialize(out2, value); 204 byte[] b = out2.copyBytes(); 205 CompressLZF.SERIALIZER.serialize(out, b); 206 } 207 208 @Override 209 public E deserialize(DataInput in, int available) throws IOException { 210 byte[] b = CompressLZF.SERIALIZER.deserialize(in, available); 211 DataInput2 in2 = new DataInput2(b); 212 return serializer.deserialize(in2, b.length); 213 } 214 } 176 215 } 177 216
Note:
See TracChangeset
for help on using the changeset viewer.