Class ExternalizableLitePofSerializer

java.lang.Object
com.tangosol.util.Base
com.tangosol.io.pof.PofHelper
com.tangosol.io.pof.ExternalizableLitePofSerializer
All Implemented Interfaces:
PofConstants, PofSerializer

public class ExternalizableLitePofSerializer extends PofHelper implements PofSerializer
PofSerializer implementation that supports the serialization and deserialization of any class that implements ExternalizableLite to and from a POF stream. This implementation is provided to ease migration of ExternalizableLite implementations to support the POF stream format.

Warning: This implementation does not correctly support all possible ExternalizableLite implementations. It will likely support most simple ExternalizableLite implementations that read and write their properties is a manner analogous to a proper implementation of the PortableObject interface. Incompatibilities are likely when the user type does direct (or indirect) binary-level I/O through the DataInput and DataOutput stream objects passed to the ExternalizableLite.readExternal(java.io.DataInput) and ExternalizableLite.writeExternal(java.io.DataOutput) methods respectively. Note that the helper methods on ExternalizableHelper are POF aware, and thus safe to use within the readExternal and writeExternal methods.

Since:
Coherence 3.2
Author:
cp 2006.07.31
  • Field Details

    • m_nTypeId

      protected final int m_nTypeId
      The type identifier of the user type to serialize and deserialize.
  • Constructor Details

    • ExternalizableLitePofSerializer

      public ExternalizableLitePofSerializer(int nTypeId)
      Create a new ExternalizableLitePofSerializer for the user type with the given type identifier.
      Parameters:
      nTypeId - the user type identifier
  • Method Details

    • serialize

      public void serialize(PofWriter out, Object o) throws IOException
      Serialize a user type instance to a POF stream by writing its state using the specified PofWriter object.

      An implementation of PofSerializer is required to follow the following steps in sequence for writing out an object of a user type:

      1. If the object is evolvable, the implementation must set the version by calling PofWriter.setVersionId(int).
      2. The implementation may write any combination of the properties of the user type by using the "write" methods of the PofWriter, but it must do so in the order of the property indexes.
      3. After all desired properties of the user type have been written, the implementation must terminate the writing of the user type by calling PofWriter.writeRemainder(com.tangosol.util.Binary).
      Specified by:
      serialize in interface PofSerializer
      Parameters:
      out - the PofWriter with which to write the object's state
      o - the object to serialize
      Throws:
      IOException - if an I/O error occurs
    • deserialize

      public Object deserialize(PofReader in) throws IOException
      Deserialize a user type instance from a POF stream by reading its state using the specified PofReader object.

      An implementation of PofSerializer is required to follow the following steps in sequence for reading in an object of a user type:

      1. If the object is evolvable, the implementation must get the version by calling PofReader.getVersionId().
      2. The implementation may read any combination of the properties of the user type by using "read" methods of the PofReader, but it must do so in the order of the property indexes. Additionally, the implementation must call PofReader.registerIdentity(java.lang.Object) with the new instance prior to reading any properties which are user type instances themselves.
      3. After all desired properties of the user type have been read, the implementation must terminate the reading of the user type by calling PofReader.readRemainder().
      Specified by:
      deserialize in interface PofSerializer
      Parameters:
      in - the PofReader with which to read the object's state
      Returns:
      the deserialized user type instance
      Throws:
      IOException - if an I/O error occurs