Package com.highdeal.pnr.hci
Class StatelessContextSerializer
java.lang.Object
com.highdeal.pnr.hci.StatelessContextSerializer
This class provides methods for the serialization and unserialization of
the
StatelessRatingContext and
StatelessPreRatingContext.
Objects are serialized (unserialized) to (from) byte arrays. What is done with these byte arrays is the reponsibility of the integration code.
The format of the byte arrays is:
- array[0]: the version number of the StatelessContextSerializer class used for serialization
- array[1]
to array[8]: checksum of the (uncompressed) byte array representing the
serialized object. This checksum is computed using
Adler32class. - array[9]: compression flag
- array[10] array[13]: size of (uncompressed) data
- array[14] to array[array.lenght-1]: data (eventually compressed)
In case of compressed data, the used algorithm is the ZLIB compression
provided by Deflater and
Inflater.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final byteFlag for compressed datastatic final byteFlag for not compressed datastatic final byteFlag indicating the version -
Method Summary
Modifier and TypeMethodDescriptionstatic StatelessContextSerializerReturns the singleton instance for this class.readStatelessPreRatingContext(byte[] bytes) Unserializes a byte array to a StatelessPreRatingContext.readStatelessRatingContext(byte[] bytes) Unserializes a byte array to a StatelessRatingContext.toString()Returns a string representation of this object.byte[]writeStatelessPreRatingContext(StatelessPreRatingContext preRatingContext, boolean compress) Serializes the given StatelessPreRatingContext into a new allocated byte array.byte[]writeStatelessRatingContext(StatelessRatingContext ratingContext, boolean compress) Serializes the given StatelessRatingContext into a new allocated byte array.
-
Field Details
-
VERSION
public static final byte VERSIONFlag indicating the version- See Also:
-
NOT_COMPRESSED
public static final byte NOT_COMPRESSEDFlag for not compressed data- See Also:
-
COMPRESSED
public static final byte COMPRESSEDFlag for compressed data- See Also:
-
-
Method Details
-
getInstance
Returns the singleton instance for this class.- Returns:
- The singleton instance for this class
-
writeStatelessRatingContext
public byte[] writeStatelessRatingContext(StatelessRatingContext ratingContext, boolean compress) throws StatelessContextSerializationException Serializes the given StatelessRatingContext into a new allocated byte array.- Parameters:
ratingContext- The StatelessRatingContext to serializecompress- The flag to indicate whether serialized data should be compressed ot not- Returns:
- A byte array containing the serialized ratinContext
- Throws:
StatelessContextSerializationException
-
readStatelessRatingContext
public StatelessRatingContext readStatelessRatingContext(byte[] bytes) throws StatelessContextSerializationException Unserializes a byte array to a StatelessRatingContext.- Parameters:
bytes- The bytes to unserialize- Returns:
- A newly allocated StatelessRatingContext built from the given bytes
- Throws:
StatelessContextSerializationException
-
writeStatelessPreRatingContext
public byte[] writeStatelessPreRatingContext(StatelessPreRatingContext preRatingContext, boolean compress) throws StatelessContextSerializationException Serializes the given StatelessPreRatingContext into a new allocated byte array.- Parameters:
preRatingContext- The StatelessPreRatingContext to serializecompress- The flag to indicate whether serialized data should be compressed ot not- Returns:
- A byte array containing the serialized preRatingContext
- Throws:
StatelessContextSerializationException
-
readStatelessPreRatingContext
public StatelessPreRatingContext readStatelessPreRatingContext(byte[] bytes) throws StatelessContextSerializationException Unserializes a byte array to a StatelessPreRatingContext.- Parameters:
bytes- The bytes to unserialize- Returns:
- A newly allocated StatelessPreRatingContext built from the given bytes
- Throws:
StatelessContextSerializationException
-
toString
Returns a string representation of this object.
-