Class SerializationContext

  extended bycom.bubble.serializer.SerializationContext

public class SerializationContext
extends java.lang.Object

The SerializationContext allows Objects and object graphs to be written to a ByteBuffer in serialized form.

The function of the context is to keep track of objects and class data that have already been serialized, replacing previously seen objects with simple references. This allows, for instance, the serialization of objects graphs that contains cycles.

Only objects that implement can be serialized through a SerializationContext. Currently, custom serialization (through or writeObject method) as well as other advanced serialization features are not supported.

Objects written to a ByteBuffer by a SerializationContext can be retrieved with a DeserializationContext. The data written to the ByteBuffer is not self-contained, because it may refer to objects or classes that have been previously written. Because of that, data written with a single SerializationContext should be read by a single DeserializationContext.

Leonardo "Bubble" Mesquita
See Also:
ByteBuffer, Serializable, DeserializationContext

Constructor Summary
          Constructs a new SerializationContext.
Method Summary
 void serialize(java.lang.Object obj, java.nio.ByteBuffer buffer)
          Serializes an object to a ByteBuffer.
 void update(java.lang.Object obj, java.nio.ByteBuffer buffer)
          Serializes a new state for an object.
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail


public SerializationContext()
Constructs a new SerializationContext.

Method Detail


public void serialize(java.lang.Object obj,
                      java.nio.ByteBuffer buffer)
Serializes an object to a ByteBuffer.

The object must implement

obj - The object being serialized.
buffer - The buffer to which the object will be serialized.


public void update(java.lang.Object obj,
                   java.nio.ByteBuffer buffer)
Serializes a new state for an object. When read through a DeserializationContext, it will update the state of the Object that was created when this Object was first read.

The object must implement

obj - The object being updated.
buffer - The buffer to which the object state will be serialized.

Faster Java Serialization.
Copyright (C) 2006 Leonardo Bubble Mesquita.