Skip navigation links

Oracle® Coherence Java API Reference
Release 12.1.2.0.3

E26043-02


com.tangosol.io.pof
Class PofAnnotationSerializer

java.lang.Object
  extended by com.tangosol.io.pof.PofAnnotationSerializer

All Implemented Interfaces:
PofSerializer

public class PofAnnotationSerializer
extends java.lang.Object
implements PofSerializer

A PofAnnotationSerializer provides annotation based de/serialization. This serializer must be instantiated with the intended class which is eventually scanned for the presence of the following annotations.

This serializer supports classes iff they are annotated with the type level annotation; Portable. This annotation is a marker annotation with no children.

All fields annotated with PortableProperty are explicitly deemed POF serializable with the option of specifying overrides to provide explicit behaviour such as:

The PortableProperty.value() (POF index) can be omitted iff the auto-indexing feature is enabled. This is enabled by instantiating this class with the fAutoIndex constructor argument. This feature determines the index based on any explicit indexes specified and the name of the portable properties. Currently objects with multiple versions is not supported. The following illustrates the auto index algorithm:

Name Explicit Index Determined Index
c 1 1
a 0
b 2

NOTE: This implementation does support objects that implement Evolvable

Since:
3.7.1
Author:
hr
See Also:
Portable

Constructor Summary
PofAnnotationSerializer(int nTypeId, java.lang.Class clz)
          Constructs a PofAnnotationSerializer.
PofAnnotationSerializer(int nTypeId, java.lang.Class clz, boolean fAutoIndex)
          Constructs a PofAnnotationSerializer.

 

Method Summary
 java.lang.Object deserialize(PofReader in)
          Deserialize a user type instance from a POF stream by reading its state using the specified PofReader object.
protected  com.tangosol.io.pof.reflect.internal.TypeMetadata getTypeMetadata()
          Return the TypeMetadata instance that holds structural information regarding the class this serializer (de)serializes.
 void serialize(PofWriter out, java.lang.Object o)
          Serialize a user type instance to a POF stream by writing its state using the specified PofWriter object.

 

Constructor Detail

PofAnnotationSerializer

public PofAnnotationSerializer(int nTypeId,
                               java.lang.Class clz)
Constructs a PofAnnotationSerializer.
Parameters:
nTypeId - the POF type id
clz - type this serializer is aware of

PofAnnotationSerializer

public PofAnnotationSerializer(int nTypeId,
                               java.lang.Class clz,
                               boolean fAutoIndex)
Constructs a PofAnnotationSerializer.
Parameters:
nTypeId - the POF type id
clz - type this serializer is aware of
fAutoIndex - turns on the auto index feature

Method Detail

serialize

public void serialize(PofWriter out,
                      java.lang.Object o)
               throws java.io.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:
java.io.IOException - if an I/O error occurs

deserialize

public java.lang.Object deserialize(PofReader in)
                             throws java.io.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:
java.io.IOException - if an I/O error occurs

getTypeMetadata

protected com.tangosol.io.pof.reflect.internal.TypeMetadata getTypeMetadata()
Return the TypeMetadata instance that holds structural information regarding the class this serializer (de)serializes.
Returns:
a TypeMetadata instance for the class this serializer (de)serializes

Skip navigation links

Oracle® Coherence Java API Reference
Release 12.1.2.0.3

E26043-02


Copyright © 2000, 2014, Oracle and/or its affiliates. All rights reserved.