IBM WebSphereTM eXtreme Scale, Release 8.6
API Specification

com.ibm.websphere.objectgrid.plugins.io
Interface DataSerializer.Identifiable

All Superinterfaces:
DataSerializer
All Known Subinterfaces:
KeyDataSerializer, KeyDataSerializer.Partitionable, KeySerializerPlugin
Enclosing interface:
DataSerializer

public static interface DataSerializer.Identifiable
extends DataSerializer

DataSerializers implement this interface to allow an alternative identity. This interface is most useful on a KeyDataSerializer, when the serialized form of the data includes formatting or other data inconsistent with the key's identity.

If omitted from the DataSerializer plug-in or if the hasBinaryEquality() answers true, then the serialized form of the data is used to calculate a hash code and test for equality.

Since:
7.1.1

Nested Class Summary
 
Nested classes/interfaces inherited from interface com.ibm.websphere.objectgrid.plugins.io.DataSerializer
DataSerializer.DataAttributeInflatable, DataSerializer.Identifiable, DataSerializer.SpecialValue, DataSerializer.UserReadable
 
Method Summary
 boolean equals(DataObjectContext ctx, XsDataInputStream dataObjectInput1, XsDataInputStream dataObjectInput2)
          Answers true if the two serialized data objects are equivalent.
 boolean hasBinaryEquality()
          Answers true when the serialized form of the data object can be used directly to calculate equality and the hashCode.
 int hashCode(DataObjectContext ctx, XsDataInputStream dataObjectInput)
          For the serialized data object, retrieve the hash code for that object.
 
Methods inherited from interface com.ibm.websphere.objectgrid.plugins.io.DataSerializer
inflateDataObject, serializeDataObject
 

Method Detail

hasBinaryEquality

boolean hasBinaryEquality()
Answers true when the serialized form of the data object can be used directly to calculate equality and the hashCode. When true, the caller can skip calling the hashCode and equals method on this DataSerializer and use the entire serialized form as the identity.

If the serialized form of the identity includes unstructured data or meta-information that isn't part of the identity, this method must answer false. A DataSerializer must return consistent answers for hasBinaryEquality() for the same type of object. When this method returns true, the caller calculates the hashCode based on its own algorithm. When this method returns false, the hashCode(DataObjectContext, XsDataInputStream) method is used to calculate the hashCode using a different algorithm, thereby breaking the contract for Object.hashCode().

Returns:
false if the hashCode and equals method should always be called on this serializer, or true, if the hashCode and equals can optionally be invoked.

hashCode

int hashCode(DataObjectContext ctx,
             XsDataInputStream dataObjectInput)
             throws IOException
For the serialized data object, retrieve the hash code for that object.

Any two objects which answer true when passed to .equals must answer the same value for this method.

Do not store or use the data stream beyond the confines of this method call. The data stream is owned by the WebSphere eXtreme Scale framework and my be closed, pooled or reused as required.

Parameters:
ctx - the Context of the method call.
dataObjectInput - the data input stream to read the object, produced from DataSerializer.serializeDataObject(DataObjectContext, Object, XsDataOutputStream). Must not be null.
Returns:
the hashCode of the serialized data object.
Throws:
IOException - thrown if there is a problem reading the data.

equals

boolean equals(DataObjectContext ctx,
               XsDataInputStream dataObjectInput1,
               XsDataInputStream dataObjectInput2)
               throws IOException
Answers true if the two serialized data objects are equivalent.

Do not store or use the data streams beyond the confines of this method call. The data streams are owned by the WebSphere eXtreme Scale framework and my be closed, pooled or reused as required.

Parameters:
ctx - the context of the method call.
dataObjectInput1 - the data input stream to read the object, produced from DataSerializer.serializeDataObject(DataObjectContext, Object, XsDataOutputStream). Must not be null.
dataObjectInput2 - the data input stream to read the object, produced from DataSerializer.serializeDataObject(DataObjectContext, Object, XsDataOutputStream). Must not be null.
Returns:
true if the two serialized data objects are equivalent
Throws:
IOException - thrown if there is a problem reading the data.

IBM WebSphereTM eXtreme Scale, Release 8.6
API Specification

© Copyright International Business Machines Corp 2005,2012. All rights reserved.