com.netflix.astyanax.serializers
Class JaxbSerializer

java.lang.Object
  extended by com.netflix.astyanax.serializers.AbstractSerializer<java.lang.Object>
      extended by com.netflix.astyanax.serializers.JaxbSerializer
All Implemented Interfaces:
Serializer<java.lang.Object>

public class JaxbSerializer
extends AbstractSerializer<java.lang.Object>

Serializes Objects using Jaxb. An instance of this class may only serialize JAXB compatible objects of classes known to its configured context.


Constructor Summary
JaxbSerializer(java.lang.Class... serializableClasses)
          Constructor.
 
Method Summary
protected  javax.xml.stream.XMLStreamReader createStreamReader(java.io.InputStream input)
          Get a new XML stream reader.
protected  javax.xml.stream.XMLStreamWriter createStreamWriter(java.io.OutputStream output)
          Get a new XML stream writer.
 java.lang.Object fromByteBuffer(java.nio.ByteBuffer bytes)
          Extract an object of type T from the bytes.
 java.nio.ByteBuffer toByteBuffer(java.lang.Object obj)
          Extract bytes from the obj of type T
 
Methods inherited from class com.netflix.astyanax.serializers.AbstractSerializer
computeInitialHashSize, fromBytes, fromBytesList, fromBytesMap, fromBytesSet, fromString, getComparatorType, getNext, getString, toBytes, toBytesList, toBytesList, toBytesList, toBytesMap, toBytesSet
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JaxbSerializer

public JaxbSerializer(java.lang.Class... serializableClasses)
Constructor.

Parameters:
serializableClasses - List of classes which can be serialized by this instance. Note that concrete classes directly referenced by any class in the list will also be serializable through this instance.
Method Detail

toByteBuffer

public java.nio.ByteBuffer toByteBuffer(java.lang.Object obj)
Extract bytes from the obj of type T

Specified by:
toByteBuffer in interface Serializer<java.lang.Object>
Specified by:
toByteBuffer in class AbstractSerializer<java.lang.Object>
Returns:

fromByteBuffer

public java.lang.Object fromByteBuffer(java.nio.ByteBuffer bytes)
Extract an object of type T from the bytes.

Specified by:
fromByteBuffer in interface Serializer<java.lang.Object>
Specified by:
fromByteBuffer in class AbstractSerializer<java.lang.Object>
Returns:

createStreamWriter

protected javax.xml.stream.XMLStreamWriter createStreamWriter(java.io.OutputStream output)
                                                       throws javax.xml.stream.XMLStreamException
Get a new XML stream writer.

Parameters:
output - An underlying OutputStream to write to.
Returns:
a new XMLStreamWriter which writes to the specified OutputStream. The output written by this XMLStreamWriter is understandable by XMLStreamReaders produced by createStreamReader(InputStream).
Throws:
javax.xml.stream.XMLStreamException

createStreamReader

protected javax.xml.stream.XMLStreamReader createStreamReader(java.io.InputStream input)
                                                       throws javax.xml.stream.XMLStreamException
Get a new XML stream reader.

Parameters:
input - the underlying InputStream to read from.
Returns:
a new XmlStreamReader which reads from the specified InputStream. The reader can read anything written by createStreamWriter(OutputStream).
Throws:
javax.xml.stream.XMLStreamException