com.esotericsoftware.kryo.serialize
Class BeanSerializer

java.lang.Object
  extended by com.esotericsoftware.kryo.Serializer
      extended by com.esotericsoftware.kryo.serialize.BeanSerializer

public class BeanSerializer
extends Serializer

Serializes Java beans using bean accessor methods. Only bean properties with both a getter and setter are serialized. This class is not as fast as FieldSerializer but is much faster and more efficient than Java serialization. Bytecode generation is used to invoke the bean propert methods, if possible.

BeanSerializer does not write header data, only the object data is stored. If the type of a bean property is not final (note primitives are final) then an extra byte is written for that property.

Author:
Nathan Sweet
See Also:
Serializer, Kryo.register(Class, Serializer)

Constructor Summary
BeanSerializer(Kryo kryo, java.lang.Class type)
           
 
Method Summary
<T> T
readObjectData(java.nio.ByteBuffer buffer, java.lang.Class<T> type)
          Reads an object from the buffer.
protected
<T> T
readObjectData(T object, java.nio.ByteBuffer buffer, java.lang.Class<T> type)
           
 void writeObjectData(java.nio.ByteBuffer buffer, java.lang.Object object)
          Writes the object to the buffer.
 
Methods inherited from class com.esotericsoftware.kryo.Serializer
isFinal, newInstance, readObject, setCanBeNull, writeObject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BeanSerializer

public BeanSerializer(Kryo kryo,
                      java.lang.Class type)
Method Detail

writeObjectData

public void writeObjectData(java.nio.ByteBuffer buffer,
                            java.lang.Object object)
Description copied from class: Serializer
Writes the object to the buffer.

Specified by:
writeObjectData in class Serializer
object - Cannot be null.

readObjectData

public <T> T readObjectData(java.nio.ByteBuffer buffer,
                            java.lang.Class<T> type)
Description copied from class: Serializer
Reads an object from the buffer.

Specified by:
readObjectData in class Serializer
Returns:
The deserialized object, never null.

readObjectData

protected <T> T readObjectData(T object,
                               java.nio.ByteBuffer buffer,
                               java.lang.Class<T> type)


Copyright © 2011. All Rights Reserved.