com.netflix.astyanax.serializers
Class AbstractSerializer<T>

java.lang.Object
  extended by com.netflix.astyanax.serializers.AbstractSerializer<T>
Type Parameters:
T -
All Implemented Interfaces:
Serializer<T>
Direct Known Subclasses:
AnnotatedCompositeSerializer, AsciiSerializer, BigDecimalSerializer, BigIntegerSerializer, BooleanSerializer, ByteBufferSerializer, BytesArraySerializer, ByteSerializer, CharSerializer, CompositeSerializer, DateSerializer, DoubleSerializer, DynamicCompositeSerializer, FloatSerializer, GzipStringSerializer, Int32Serializer, IntegerSerializer, JaxbSerializer, ListSerializer, LongSerializer, MapSerializer, ObjectSerializer, PrefixedSerializer, SetSerializer, ShortSerializer, SnappyStringSerializer, StringSerializer, TypeInferringSerializer, UUIDSerializer

public abstract class AbstractSerializer<T>
extends java.lang.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.


Constructor Summary
AbstractSerializer()
           
 
Method Summary
 int computeInitialHashSize(int initialSize)
           
abstract  T fromByteBuffer(java.nio.ByteBuffer byteBuffer)
          Extract an object of type T from the bytes.
 T fromBytes(byte[] bytes)
           
 java.util.List<T> fromBytesList(java.util.List<java.nio.ByteBuffer> list)
           
<V> java.util.Map<T,V>
fromBytesMap(java.util.Map<java.nio.ByteBuffer,V> map)
           
 java.util.List<T> fromBytesSet(java.util.Set<java.nio.ByteBuffer> set)
           
 java.nio.ByteBuffer fromString(java.lang.String string)
          Create a ByteBuffer by first parsing the type out of a string
 ComparatorType getComparatorType()
           
 java.nio.ByteBuffer getNext(java.nio.ByteBuffer byteBuffer)
          Return the byte buffer for the next value in sorted order for the matching comparator type.
 java.lang.String getString(java.nio.ByteBuffer byteBuffer)
           
abstract  java.nio.ByteBuffer toByteBuffer(T obj)
          Extract bytes from the obj of type T
 byte[] toBytes(T obj)
           
 java.util.List<java.nio.ByteBuffer> toBytesList(java.util.Collection<T> list)
           
 java.util.List<java.nio.ByteBuffer> toBytesList(java.lang.Iterable<T> list)
           
 java.util.List<java.nio.ByteBuffer> toBytesList(java.util.List<T> list)
           
<V> java.util.Map<java.nio.ByteBuffer,V>
toBytesMap(java.util.Map<T,V> map)
           
 java.util.Set<java.nio.ByteBuffer> toBytesSet(java.util.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 java.nio.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(java.nio.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 java.util.Set<java.nio.ByteBuffer> toBytesSet(java.util.List<T> list)
Specified by:
toBytesSet in interface Serializer<T>

fromBytesSet

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

toBytesList

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

toBytesList

public java.util.List<java.nio.ByteBuffer> toBytesList(java.util.Collection<T> list)
Specified by:
toBytesList in interface Serializer<T>

toBytesList

public java.util.List<java.nio.ByteBuffer> toBytesList(java.lang.Iterable<T> list)
Specified by:
toBytesList in interface Serializer<T>

fromBytesList

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

toBytesMap

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

fromBytesMap

public <V> java.util.Map<T,V> fromBytesMap(java.util.Map<java.nio.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>

fromString

public java.nio.ByteBuffer fromString(java.lang.String string)
Description copied from interface: Serializer
Create a ByteBuffer by first parsing the type out of a string

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

getString

public java.lang.String getString(java.nio.ByteBuffer byteBuffer)
Specified by:
getString in interface Serializer<T>

getNext

public java.nio.ByteBuffer getNext(java.nio.ByteBuffer byteBuffer)
Description copied from interface: Serializer
Return the byte buffer for the next value in sorted order for the matching comparator type. This is used for paginating columns.

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