jarol.messages
Class Message

java.lang.Object
  extended by jarol.messages.Message
All Implemented Interfaces:
MessageInterface, MessagePart, java.lang.Cloneable

public abstract class Message
extends java.lang.Object
implements MessagePart, MessageInterface

Base class for messages.

Version:
0.1
Author:
Eduardo Marques

Field Summary
static float MAX_FP32
          Max value for FP32 type.
static double MAX_FP64
          Max value for FP64 type.
static short MAX_INT16
          Max value for INT16 type.
static int MAX_INT32
          Max value for INT32 type.
static long MAX_INT64
          Max value for INT64 type.
static byte MAX_INT8
          Max value for INT8 type.
static int MAX_UINT16
          Max value for UINT16 type.
static long MAX_UINT32
          Max value for UINT32 type.
static long MAX_UINT64
          Max value for UINT64 type (not accurate)
static short MAX_UINT8
          Max value for UINT8 type.
static float MIN_FP32
          Min value for FP32 type.
static double MIN_FP64
          Min value for FP64 type.
static short MIN_INT16
          Min value for INT16 type.
static int MIN_INT32
          Min value for INT32 type.
static long MIN_INT64
          Min value for INT64 type.
static byte MIN_INT8
          Min value for INT8 type.
static int MIN_UINT16
          Min value for UINT16 type.
static int MIN_UINT32
          Min value for UINT32 type.
static long MIN_UINT64
          Min value for UINT64 type.
static short MIN_UINT8
          Min value for UINT8 type.
static boolean MSG_DEBUG
           
 
Constructor Summary
Message()
          No argument constructor.
 
Method Summary
 java.lang.Object clone()
          clone() implementation with deep copy semantics.
 java.lang.Object deepClone()
          deepClone() implementation.
 long getSequenceId()
          Get sequence id By default this implementation always returns 0.
 double getTimestamp()
          Get timestamp.
abstract  int serialId()
          Get serialization id for message.
abstract  void serialize(Buffer buffer)
          Serialize message.
abstract  int serialSize()
          Get serialization size for message.
 void setSequenceId(long id)
          Set sequence id for message.
 void setTimestamp(double timestamp)
          Set timestamp for message.
abstract  void unserialize(Buffer buffer)
          Unserialize message.
abstract  void validate()
          Abstract method to validate messages.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface jarol.messages.MessagePart
dump
 
Methods inherited from interface jarol.MessageInterface
toString
 

Field Detail

MIN_UINT8

public static final short MIN_UINT8
Min value for UINT8 type.

See Also:
Constant Field Values

MIN_UINT16

public static final int MIN_UINT16
Min value for UINT16 type.

See Also:
Constant Field Values

MIN_UINT32

public static final int MIN_UINT32
Min value for UINT32 type.

See Also:
Constant Field Values

MIN_UINT64

public static final long MIN_UINT64
Min value for UINT64 type.

See Also:
Constant Field Values

MIN_INT8

public static final byte MIN_INT8
Min value for INT8 type.

See Also:
Constant Field Values

MIN_INT16

public static final short MIN_INT16
Min value for INT16 type.

See Also:
Constant Field Values

MIN_INT32

public static final int MIN_INT32
Min value for INT32 type.

See Also:
Constant Field Values

MIN_INT64

public static final long MIN_INT64
Min value for INT64 type.

See Also:
Constant Field Values

MAX_INT8

public static final byte MAX_INT8
Max value for INT8 type.

See Also:
Constant Field Values

MAX_INT16

public static final short MAX_INT16
Max value for INT16 type.

See Also:
Constant Field Values

MAX_INT32

public static final int MAX_INT32
Max value for INT32 type.

See Also:
Constant Field Values

MAX_INT64

public static final long MAX_INT64
Max value for INT64 type.

See Also:
Constant Field Values

MAX_UINT8

public static final short MAX_UINT8
Max value for UINT8 type.

See Also:
Constant Field Values

MAX_UINT16

public static final int MAX_UINT16
Max value for UINT16 type.

See Also:
Constant Field Values

MAX_UINT32

public static final long MAX_UINT32
Max value for UINT32 type.

See Also:
Constant Field Values

MAX_UINT64

public static final long MAX_UINT64
Max value for UINT64 type (not accurate)

See Also:
Constant Field Values

MIN_FP32

public static final float MIN_FP32
Min value for FP32 type.

See Also:
Constant Field Values

MAX_FP32

public static final float MAX_FP32
Max value for FP32 type.

See Also:
Constant Field Values

MIN_FP64

public static final double MIN_FP64
Min value for FP64 type.

See Also:
Constant Field Values

MAX_FP64

public static final double MAX_FP64
Max value for FP64 type.

See Also:
Constant Field Values

MSG_DEBUG

public static final boolean MSG_DEBUG
Constructor Detail

Message

public Message()
No argument constructor.

Method Detail

getTimestamp

public double getTimestamp()
Get timestamp. By default this implementation always returns 0.0 It must be overridden by message sets which use header timestamps.


setTimestamp

public void setTimestamp(double timestamp)
Set timestamp for message. By default the base implemenation does nothing, nor Message declares any field to hold the timestamp. It must be overridden by message sets which use header sequence ids.


getSequenceId

public long getSequenceId()
Get sequence id By default this implementation always returns 0. It must be overridden by message sets which use header timestamps.


setSequenceId

public void setSequenceId(long id)
Set sequence id for message. By default the base implemenation does nothing nor Message declares any field to hold the sequence id. It must be overridden by message sets which use header sequence ids.


validate

public abstract void validate()
                       throws InvalidMessageException
Abstract method to validate messages. The validate() method throws InvalidMessageException when the message is invalid.

Specified by:
validate in interface MessagePart
Throws:
InvalidMessageException - if the contents of this message part are invalid

serialId

public abstract int serialId()
Get serialization id for message.

Returns:
serialization id for message

serialSize

public abstract int serialSize()
Get serialization size for message.

Specified by:
serialSize in interface MessagePart
Returns:
serialization size for message

serialize

public abstract void serialize(Buffer buffer)
                        throws InvalidMessageException
Serialize message.

Specified by:
serialize in interface MessagePart
Parameters:
buffer - Output buffer
Throws:
InvalidMessageException - if the message is not valid

unserialize

public abstract void unserialize(Buffer buffer)
                          throws InvalidMessageException
Unserialize message.

Specified by:
unserialize in interface MessagePart
Parameters:
buffer - Input buffer
Throws:
InvalidMessageException - if the unserialized message is not valid

deepClone

public final java.lang.Object deepClone()
deepClone() implementation. This is a final method. Sub-classes should override clone() to provide deep-copy semantics if they contain 'rawdata' fields.

Specified by:
deepClone in interface MessageInterface
Returns:
deep clone of the message
Throws:
java.lang.RuntimeException - if an exception such as CloneNotSupportedException was raised

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
clone() implementation with deep copy semantics. In order to provide compatibility with messages in the Jarol system it should be overriden by message classes with mutable fields. Otherwise the shallow-copy semantics of Object.clone() are sufficient.

Specified by:
clone in interface MessageInterface
Overrides:
clone in class java.lang.Object
Returns:
deep clone of Message object
Throws:
java.lang.CloneNotSupportedException