public class PortableTypeSerializer extends Object implements PofSerializer
PofSerializer implementation that serializes classes that implement PortableObject interface (and optionally EvolvableObject interface).
Unlike legacy PortableObjectSerializer, this class serializes attributes of each class in the object's hierarchy into a separate nested POF stream, which allows for independent evolution of each class in the hierarchy, as well as the evolution of the hierarchy itself (addition of new classes at any level in the hierarchy).
| Modifier and Type | Field and Description |
|---|---|
protected int |
m_nTypeId
The type identifier of the user type to serialize and deserialize.
|
| Constructor and Description |
|---|
PortableTypeSerializer(int nTypeId, Class<?> clazz)
Create a new PortableTypeSerializer for the user type with the given type identifier and class.
|
| Modifier and Type | Method and Description |
|---|---|
Object |
deserialize(PofReader reader)
Deserialize a user type instance from a POF stream by reading its state using the specified PofReader object.
|
protected Class |
getClassForTypeId(PofContext ctx, int nTypeId)
Return the class associated with a specified type identifier, or null if the identifier is not defined in the current POF context.
|
void |
serialize(PofWriter writer, Object o)
Serialize a user type instance to a POF stream by writing its state using the specified PofWriter object.
|
protected final int m_nTypeId
public PortableTypeSerializer(int nTypeId,
Class<?> clazz)
nTypeId - the type identifier of the user type to serialize and deserializeclazz - the class of the user type to serialize and deserializepublic void serialize(PofWriter writer, Object o) throws IOException
PofSerializerAn implementation of PofSerializer is required to follow the following steps in sequence for writing out an object of a user type:
PofWriter.setVersionId(int).PofWriter.writeRemainder(com.tangosol.util.Binary).serialize in interface PofSerializerwriter - the PofWriter with which to write the object's stateo - the object to serializeIOException - if an I/O error occurspublic Object deserialize(PofReader reader) throws IOException
PofSerializerAn implementation of PofSerializer is required to follow the following steps in sequence for reading in an object of a user type:
PofReader.getVersionId().PofReader.registerIdentity(java.lang.Object) with the new instance prior to reading any properties which are user type instances themselves.PofReader.readRemainder().deserialize in interface PofSerializerreader - the PofReader with which to read the object's stateIOException - if an I/O error occursprotected Class getClassForTypeId(PofContext ctx, int nTypeId)
ctx - the POF contextnTypeId - the type identifier to lookup