jarol.messages
Class SerializationHandle

java.lang.Object
  extended by jarol.messages.SerializationHandle

public class SerializationHandle
extends java.lang.Object

Application parameterisation for message factories and serialization.

This class can used to parameterize the serialization done through MessageFactory. it can be

- The timestamp counter method to apply in message headers, if any

- The sequence id counter to apply to message headers, if any

- The checksum method to apply to message footers if any

This base default implementation always returns 0 for all of the above calculations and should be overriden as needed.

All values returned are 'long' values but they may be converted to 'byte', 'short' or 'int' values according to the characteristics of a particular message set. The implementation of the methods should therefore take that into consideration.

Version:
0.1
Author:
Eduardo Marques

Constructor Summary
SerializationHandle()
          Constructor.
 
Method Summary
 long checksum(byte[] buf, int off, int len)
          Checksum method.
 long nextSequenceId(Message msg)
          Sequence id counter method.
 double timestamp()
          Timestamp method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SerializationHandle

public SerializationHandle()
Constructor.

Method Detail

timestamp

public double timestamp()
Timestamp method. This default implementation always returns 0.0 . It should be overriden if required.

Returns:
this default implementation always returns 0.

nextSequenceId

public long nextSequenceId(Message msg)
Sequence id counter method. It takes a message argument to allow counters per message type (or any other message type based way). This default implementation always returns 0. It should be overriden if required.

Parameters:
msg - message argument
Returns:
this default implementation always returns 0.

checksum

public long checksum(byte[] buf,
                     int off,
                     int len)
Checksum method. This default implementation always returns 0. It should be overriden if required.

Parameters:
buf - the source buffer for calculating the checksum
off - the buffer offset for checksum calculation
len - the number of bytes to consider for checksum
Returns:
this default implementation always returns 0.