org.mapdb
Interface Serializer<A>

All Known Implementing Classes:
BTreeMap.NodeSerializer, Queues.SimpleQueue.NodeSerializer, Serializer.CompressionWrapper, SerializerBase, SerializerPojo

public interface Serializer<A>

Provides serialization and deserialization

Author:
Jan Kotek

Nested Class Summary
static class Serializer.CompressionWrapper<E>
          wraps another serializer and (de)compresses its output/input
 
Field Summary
static Serializer<Object> BASIC
          Basic serializer for most classes in 'java.lang' and 'java.util' packages.
static Serializer<Boolean> BOOLEAN
           
static Serializer<byte[]> BYTE_ARRAY
          Serializes `byte[]` it adds header which contains size information
static Serializer<byte[]> BYTE_ARRAY_NOSIZE
          Serializes `byte[]` directly into underlying store It does not store size, so it can not be used in Maps and other collections.
static Serializer<char[]> CHAR_ARRAY
          Serializes `char[]` it adds header which contains size information
static Serializer<double[]> DOUBLE_ARRAY
          Serializes `double[]` it adds header which contains size information
static Serializer<Object> ILLEGAL_ACCESS
          Always throws IllegalAccessError when invoked.
static Serializer<int[]> INT_ARRAY
          Serializes `int[]` it adds header which contains size information
static Serializer<Integer> INTEGER
          Serializes Integer into 4 bytes.
static Serializer<Object> JAVA
          Serializer which uses standard Java Serialization with ObjectInputStream and ObjectOutputStream
static Serializer<Long> LONG
          Serializes Long into 8 bytes, used mainly for testing.
static Serializer<long[]> LONG_ARRAY
          Serializes `long[]` it adds header which contains size information
static Serializer<String> STRING
          Serializes strings using UTF8 encoding.
static Serializer<String> STRING_ASCII
          Serializes strings using ASCII encoding (8 bit character).
static Serializer<String> STRING_INTERN
          Serializes strings using UTF8 encoding.
static Serializer<String> STRING_NOSIZE
          Serializes strings using UTF8 encoding.
static Serializer<UUID> UUID
          Serializers UUID class
 
Method Summary
 A deserialize(DataInput in, int available)
          Deserialize the content of an object from a DataInput.
 int fixedSize()
          Data could be serialized into record with variable size or fixed size.
 void serialize(DataOutput out, A value)
          Serialize the content of an object into a ObjectOutput
 

Field Detail

STRING

static final Serializer<String> STRING
Serializes strings using UTF8 encoding. Stores string size so can be used as collection serializer. Does not handle null values


STRING_INTERN

static final Serializer<String> STRING_INTERN
Serializes strings using UTF8 encoding. Deserialized String is interned String.intern(), so it could save some memory. Stores string size so can be used as collection serializer. Does not handle null values


STRING_ASCII

static final Serializer<String> STRING_ASCII
Serializes strings using ASCII encoding (8 bit character). Is faster compared to UTF8 encoding. Stores string size so can be used as collection serializer. Does not handle null values


STRING_NOSIZE

static final Serializer<String> STRING_NOSIZE
Serializes strings using UTF8 encoding. Used mainly for testing. Does not handle null values.


LONG

static final Serializer<Long> LONG
Serializes Long into 8 bytes, used mainly for testing. Does not handle null values.


INTEGER

static final Serializer<Integer> INTEGER
Serializes Integer into 4 bytes. Does not handle null values.


BOOLEAN

static final Serializer<Boolean> BOOLEAN

ILLEGAL_ACCESS

static final Serializer<Object> ILLEGAL_ACCESS
Always throws IllegalAccessError when invoked. Useful for testing and assertions.


BASIC

static final Serializer<Object> BASIC
Basic serializer for most classes in 'java.lang' and 'java.util' packages. It does not handle custom POJO classes. It also does not handle classes which require access to `DB` itself.


BYTE_ARRAY

static final Serializer<byte[]> BYTE_ARRAY
Serializes `byte[]` it adds header which contains size information


BYTE_ARRAY_NOSIZE

static final Serializer<byte[]> BYTE_ARRAY_NOSIZE
Serializes `byte[]` directly into underlying store It does not store size, so it can not be used in Maps and other collections.


CHAR_ARRAY

static final Serializer<char[]> CHAR_ARRAY
Serializes `char[]` it adds header which contains size information


INT_ARRAY

static final Serializer<int[]> INT_ARRAY
Serializes `int[]` it adds header which contains size information


LONG_ARRAY

static final Serializer<long[]> LONG_ARRAY
Serializes `long[]` it adds header which contains size information


DOUBLE_ARRAY

static final Serializer<double[]> DOUBLE_ARRAY
Serializes `double[]` it adds header which contains size information


JAVA

static final Serializer<Object> JAVA
Serializer which uses standard Java Serialization with ObjectInputStream and ObjectOutputStream


UUID

static final Serializer<UUID> UUID
Serializers UUID class

Method Detail

serialize

void serialize(DataOutput out,
               A value)
               throws IOException
Serialize the content of an object into a ObjectOutput

Parameters:
out - ObjectOutput to save object into
value - Object to serialize
Throws:
IOException

deserialize

A deserialize(DataInput in,
              int available)
              throws IOException
Deserialize the content of an object from a DataInput.

Parameters:
in - to read serialized data from
available - how many bytes are available in DataInput for reading, may be -1 (in streams) or 0 (null).
Returns:
deserialized object
Throws:
IOException

fixedSize

int fixedSize()
Data could be serialized into record with variable size or fixed size. Some optimizations can be applied to serializers with fixed size

Returns:
fixed size or -1 for variable size


Copyright © 2014. All Rights Reserved.