com.netflix.astyanax
Interface Serializer<T>

Type Parameters:
T - The type to which data extraction should work.
All Known Implementing Classes:
AbstractSerializer, AnnotatedCompositeSerializer, AsciiSerializer, BigIntegerSerializer, BooleanSerializer, ByteBufferSerializer, BytesArraySerializer, CharSerializer, CompositeSerializer, DateSerializer, DoubleSerializer, DynamicCompositeSerializer, FloatSerializer, IntegerSerializer, JaxbSerializer, LongSerializer, ObjectSerializer, PrefixedSerializer, ShortSerializer, SpecificCompositeSerializer, StringSerializer, TimeUUIDSerializer, TypeInferringSerializer, UUIDSerializer

public interface Serializer<T>

Serializes a type T from the given bytes, or vice a versa. In cassandra column names and column values (and starting with 0.7.0 row keys) are all byte[]. To allow type safe conversion in java and keep all conversion code in one place we define the Extractor interface. Implementors of the interface define type conversion according to their domains. A predefined set of common extractors can be found in the extractors package, for example StringSerializer.

Author:
Ran Tavory

Method Summary
 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> list)
           
 ByteBuffer fromString(String string)
          Create a ByteBuffer by first parsing the type out of a string
 ComparatorType getComparatorType()
           
 ByteBuffer getNext(ByteBuffer byteBuffer)
          Return the byte buffer for the next value in sorted order for the matching comparator type.
 String getString(ByteBuffer byteBuffer)
           
 ByteBuffer toByteBuffer(T obj)
          Extract bytes from the obj of type T
 byte[] toBytes(T obj)
           
 List<ByteBuffer> toBytesList(Collection<T> list)
           
 List<ByteBuffer> toBytesList(List<T> list)
           
<V> Map<ByteBuffer,V>
toBytesMap(Map<T,V> map)
           
 Set<ByteBuffer> toBytesSet(List<T> list)
           
 

Method Detail

toByteBuffer

ByteBuffer toByteBuffer(T obj)
Extract bytes from the obj of type T

Parameters:
obj -
Returns:

toBytes

byte[] toBytes(T obj)

fromBytes

T fromBytes(byte[] bytes)

fromByteBuffer

T fromByteBuffer(ByteBuffer byteBuffer)
Extract an object of type T from the bytes.

Parameters:
bytes -
Returns:

toBytesSet

Set<ByteBuffer> toBytesSet(List<T> list)

fromBytesSet

List<T> fromBytesSet(Set<ByteBuffer> list)

toBytesMap

<V> Map<ByteBuffer,V> toBytesMap(Map<T,V> map)

fromBytesMap

<V> Map<T,V> fromBytesMap(Map<ByteBuffer,V> map)

toBytesList

List<ByteBuffer> toBytesList(List<T> list)

toBytesList

List<ByteBuffer> toBytesList(Collection<T> list)

fromBytesList

List<T> fromBytesList(List<ByteBuffer> list)

getComparatorType

ComparatorType getComparatorType()

getNext

ByteBuffer getNext(ByteBuffer byteBuffer)
Return the byte buffer for the next value in sorted order for the matching comparator type. This is used for paginating columns.

Parameters:
byteBuffer -
Returns:

fromString

ByteBuffer fromString(String string)
Create a ByteBuffer by first parsing the type out of a string

Parameters:
string -
Returns:

getString

String getString(ByteBuffer byteBuffer)


Copyright © 2012. All Rights Reserved.