com.esotericsoftware.kryo.serialize
Class ReferenceFieldSerializer

java.lang.Object
  extended by com.esotericsoftware.kryo.Serializer
      extended by com.esotericsoftware.kryo.serialize.FieldSerializer
          extended by com.esotericsoftware.kryo.serialize.ReferenceFieldSerializer

public class ReferenceFieldSerializer
extends FieldSerializer

Serializes objects using direct field assignment, handling object references and cyclic graphs. Each object serialized requires 1 byte more than FieldSerializer. Each appearance of an object in the graph after the first is stored as an integer ordinal.

Note that serializing references can be convenient, but can sometimes be redundant information. If this is the case and serialized size is a priority, references should not be serialized. Code can sometimes be hand written to reconstruct the references after deserialization.

Author:
Nathan Sweet
See Also:
FieldSerializer

Nested Class Summary
 
Nested classes/interfaces inherited from class com.esotericsoftware.kryo.serialize.FieldSerializer
FieldSerializer.CachedField
 
Constructor Summary
ReferenceFieldSerializer(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.
 void writeObjectData(java.nio.ByteBuffer buffer, java.lang.Object object)
          Writes the object to the buffer.
 
Methods inherited from class com.esotericsoftware.kryo.serialize.FieldSerializer
getField, readObjectData, removeField, setFieldsAsAccessible, setFieldsCanBeNull, setIgnoreSyntheticFields
 
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

ReferenceFieldSerializer

public ReferenceFieldSerializer(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.

Overrides:
writeObjectData in class FieldSerializer
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.

Overrides:
readObjectData in class FieldSerializer
Returns:
The deserialized object, never null.


Copyright © 2011. All Rights Reserved.