org.ehcache.spi.serialization
Interface Serializer<T>

Type Parameters:
T - the type of the instances to serialize
All Superinterfaces:
java.io.Closeable
All Known Implementing Classes:
CompactJavaSerializer, CompactPersistentJavaSerializer, SoftLockSerializer, SoftLockValueCombinedSerializer

public interface Serializer<T>
extends java.io.Closeable

Interface defining the contract used to transform types in a serial form. Implementations must be thread-safe and must define a constructor accepting a single ClassLoader parameter.


Nested Class Summary
static interface Serializer.Persistent
          Marks a Serializer that is suitable for operation within a persistent cache.
static interface Serializer.Transient
          Marks a Serializer that is suitable for operation within a transient cache.
 
Method Summary
 boolean equals(T object, java.nio.ByteBuffer binary)
          Checks if the given instance and serial form are representations of the same instance.
 T read(java.nio.ByteBuffer binary)
          Reconstructs an instance from the given serial form.
 java.nio.ByteBuffer serialize(T object)
          Transforms the given instance into its serial form.
 
Methods inherited from interface java.io.Closeable
close
 

Method Detail

serialize

java.nio.ByteBuffer serialize(T object)
                              throws SerializerException
Transforms the given instance into its serial form.

Parameters:
object - the instance to serialize
Returns:
the binary representation of the serial form
Throws:
SerializerException - if serialization fails

read

T read(java.nio.ByteBuffer binary)
       throws java.lang.ClassNotFoundException,
              SerializerException
Reconstructs an instance from the given serial form.

Parameters:
binary - the binary representation of the serial form
Returns:
the de-serialized instance
Throws:
SerializerException - if reading the byte buffer fails
java.lang.ClassNotFoundException - if the type to de-serialize to cannot be found

equals

boolean equals(T object,
               java.nio.ByteBuffer binary)
               throws java.lang.ClassNotFoundException,
                      SerializerException
Checks if the given instance and serial form are representations of the same instance.

Parameters:
object - the instance to check
binary - the serial form to check
Returns:
true if both parameters represent the same instance, false otherwise
Throws:
SerializerException - if reading the byte buffer fails
java.lang.ClassNotFoundException - if the type to de-serialize to cannot be found