me.prettyprint.cassandra.serializers
Class AbstractSerializer<T>

java.lang.Object
  extended by me.prettyprint.cassandra.serializers.AbstractSerializer<T>
Type Parameters:
T -
All Implemented Interfaces:
Serializer<T>
Direct Known Subclasses:
AsciiSerializer, BigIntegerSerializer, BooleanSerializer, ByteBufferSerializer, BytesArraySerializer, CharSerializer, CompositeSerializer, DateSerializer, DoubleSerializer, DynamicCompositeSerializer, FloatSerializer, IntegerSerializer, JaxbSerializer, LongSerializer, ObjectSerializer, PrefixedSerializer, ShortSerializer, StringSerializer, TimeUUIDSerializer, TypeInferringSerializer, UUIDSerializer

public abstract class AbstractSerializer<T>
extends Object
implements Serializer<T>

A base class for serializer implementations. Takes care of the default implementations of to/fromBytesList and to/fromBytesMap. Extenders of this class only need to implement the toBytes and fromBytes.

Author:
Ed Anuff

Constructor Summary
AbstractSerializer()
           
 
Method Summary
 int computeInitialHashSize(int initialSize)
           
abstract  T fromByteBuffer(ByteBuffer byteBuffer)
          Extract an object of type T from the bytes.
 T fromBytes(byte[] bytes)
           
 List<T> fromBytesList(List<ByteBuffer> list)
           
<V> Map<T,V>
fromBytesMap(Map<ByteBuffer,V> map)
           
 List<T> fromBytesSet(Set<ByteBuffer> set)
           
 ComparatorType getComparatorType()
           
abstract  ByteBuffer toByteBuffer(T obj)
          Extract bytes from the obj of type T
 byte[] toBytes(T obj)
           
 List<ByteBuffer> toBytesList(List<T> list)
           
<V> Map<ByteBuffer,V>
toBytesMap(Map<T,V> map)
           
 Set<ByteBuffer> toBytesSet(List<T> list)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractSerializer

public AbstractSerializer()
Method Detail

toByteBuffer

public abstract ByteBuffer toByteBuffer(T obj)
Description copied from interface: Serializer
Extract bytes from the obj of type T

Specified by:
toByteBuffer in interface Serializer<T>
Returns:

toBytes

public byte[] toBytes(T obj)
Specified by:
toBytes in interface Serializer<T>

fromBytes

public T fromBytes(byte[] bytes)
Specified by:
fromBytes in interface Serializer<T>

fromByteBuffer

public abstract T fromByteBuffer(ByteBuffer byteBuffer)
Description copied from interface: Serializer
Extract an object of type T from the bytes.

Specified by:
fromByteBuffer in interface Serializer<T>
Returns:

toBytesSet

public Set<ByteBuffer> toBytesSet(List<T> list)
Specified by:
toBytesSet in interface Serializer<T>

fromBytesSet

public List<T> fromBytesSet(Set<ByteBuffer> set)
Specified by:
fromBytesSet in interface Serializer<T>

toBytesList

public List<ByteBuffer> toBytesList(List<T> list)
Specified by:
toBytesList in interface Serializer<T>

fromBytesList

public List<T> fromBytesList(List<ByteBuffer> list)
Specified by:
fromBytesList in interface Serializer<T>

toBytesMap

public <V> Map<ByteBuffer,V> toBytesMap(Map<T,V> map)
Specified by:
toBytesMap in interface Serializer<T>

fromBytesMap

public <V> Map<T,V> fromBytesMap(Map<ByteBuffer,V> map)
Specified by:
fromBytesMap in interface Serializer<T>

computeInitialHashSize

public int computeInitialHashSize(int initialSize)

getComparatorType

public ComparatorType getComparatorType()
Specified by:
getComparatorType in interface Serializer<T>


Copyright © 2011. All Rights Reserved.