public interface CatalystSerializable
Classes can implement this interface as an alternative to providing a separate TypeSerializer instance. Note,
however, that CatalystSerializable classes must still be registered via Serializer.register(Class).
Types that implement this interface should provide a no-argument constructor via which Catalyst can allocate new
instances of the class. During serialization, Catalyst will call writeObject(BufferOutput, Serializer)
to serialize the object to a Buffer. During deserialization, Catalyst will call
readObject(BufferInput, Serializer) to deserialize
the object from a Buffer.
| Modifier and Type | Method and Description |
|---|---|
void |
readObject(BufferInput buffer,
Serializer serializer)
Reads the object from the given buffer.
|
void |
writeObject(BufferOutput buffer,
Serializer serializer)
Writes the object to the given buffer.
|
void writeObject(BufferOutput buffer, Serializer serializer)
Implementations of this method should write object attributes to the given buffer. Note that assumptions cannot be
safely made about the given buffer's Buffer.position(), Buffer.limit(),
or any other navigational attributes of the provided Buffer. To navigate the buffer,
set the buffer's Buffer.mark() and Buffer.reset().
When writing dynamically sized attributes such as strings and collections, users should always write the attribute's
count to the given buffer. Catalyst makes no guarantee that the buffer provided to
readObject(BufferInput, Serializer) will reflect the
number of bytes written to the buffer during serialization.
buffer - The buffer to which to write the object.serializer - The serializer with which the object is being serialized.readObject(BufferInput, Serializer)void readObject(BufferInput buffer, Serializer serializer)
Implementations of this method should read object attributes from the given buffer in the same order with which they
were written to the buffer in writeObject(BufferOutput, Serializer).
Catalyst guarantees only that the current Buffer.position() will reflect the start
of the bytes written by writeObject(BufferOutput, Serializer),
but not that the Buffer.remaining() bytes reflect the number of bytes written by
writeObject(BufferOutput, Serializer).
buffer - The buffer from which to read the object.serializer - The serializer with which the object is being serialized.writeObject(BufferOutput, Serializer)Copyright © 2013–2015. All rights reserved.