ist.palcom.mal
Class MessageHeaderNode

java.lang.Object
  extended by ist.palcom.collections.Link
      extended by ist.palcom.mal.MessageHeaderNode

public class MessageHeaderNode
extends Link


Field Summary
static byte FUNCTION_CLOSE
           
static byte FUNCTION_MESSAGE_OVER_CONNECTION
           
static byte FUNCTION_NONE
          Special value used when function has not been set
static byte FUNCTION_OPEN
           
static byte FUNCTION_OPEN_REPLY
           
static byte FUNCTION_RADIOCASTED
           
static byte FUNCTION_RE_OPEN
           
static byte FUNCTION_USER_ID
           
static byte NODE_FORMAT_ACKMESSAGE
          The Reliable Ack message node 'A'.
static byte NODE_FORMAT_CHOPPED
          The Chopped message node '-'.
static byte NODE_FORMAT_CONNECTION
          The Connection message node 'c'.
static byte NODE_FORMAT_GROUP_JOIN
          The group join message node 'g'.
static byte NODE_FORMAT_GROUP_LEAVE
          The group leave message node 'q'.
static byte NODE_FORMAT_GROUP_MESSAGE
          The group message node 'G'.
static byte NODE_FORMAT_HBINFOREPLY
          The HBInfoReply message node 'I'.
static byte NODE_FORMAT_HBINFOREQUEST
          The HBInfoRequest message node 'i'.
static byte NODE_FORMAT_HEARTATTACK
          The heartattack message node 'X'.
static byte NODE_FORMAT_HEARTBEAT
          The heartbeat message node 'h'.
static byte NODE_FORMAT_HEARTBEATACK
          The heartbeat ack message node 'H'.
static byte NODE_FORMAT_MARK
          The mark message node 'm'.
static byte NODE_FORMAT_NONE
          Special value used before a format has been assigned
static byte NODE_FORMAT_PUBLISH
          The publish message node 'P'.
static byte NODE_FORMAT_RELIABLE
          The Reliable message node 'R'.
static byte NODE_FORMAT_RESENDMESSAGE
          The Reliable resend message node 'B'.
static byte NODE_FORMAT_ROUTINGR
          The RoutingR message node 'r'.
static byte NODE_FORMAT_ROUTINGS
          The RoutingS message node 's'.
static byte NODE_FORMAT_SINGLE_SHOT
          The single-shot message node 'S'.
static byte NODE_FORMAT_VERSION
          The FormatVersion message node 'v'.
 
Constructor Summary
MessageHeaderNode(byte formatIdentifier)
          Constructs a message header node with no data.
MessageHeaderNode(byte[] data, int offset, int length)
          Constructs a message header node from an array with data.
MessageHeaderNode(byte formatIdentifier, byte functionIdentifier, java.lang.String[] data)
          Constructs a message header node from the parameters.
MessageHeaderNode(byte formatIdentifier, java.lang.String[] data)
          Constructs a message header node from the parameters with no function identifier.
 
Method Summary
 MessageHeaderNode getCopy()
           
 java.lang.String[] getData()
           
 byte getFormatIdentifier()
           
 byte getFunctionIdentifier()
           
 int getLength()
          Returns the length of the data part of the node without the header part.
static int getMessageDataNodeOffset(byte[] message)
          Returns the offset where the message data node or nodes start in a byte array containing an entire message.
 int getTotalLength()
          Returns the total length of the message header node, including the length of the header with length and format.
 byte[] toByteArray()
           
 java.lang.String toString()
           
 
Methods inherited from class ist.palcom.collections.Link
getNext, getPrev
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NODE_FORMAT_NONE

public static final byte NODE_FORMAT_NONE
Special value used before a format has been assigned

See Also:
Constant Field Values

NODE_FORMAT_HEARTBEAT

public static final byte NODE_FORMAT_HEARTBEAT
The heartbeat message node 'h'.

See Also:
Constant Field Values

NODE_FORMAT_HEARTBEATACK

public static final byte NODE_FORMAT_HEARTBEATACK
The heartbeat ack message node 'H'.

See Also:
Constant Field Values

NODE_FORMAT_HEARTATTACK

public static final byte NODE_FORMAT_HEARTATTACK
The heartattack message node 'X'.

See Also:
Constant Field Values

NODE_FORMAT_HBINFOREQUEST

public static final byte NODE_FORMAT_HBINFOREQUEST
The HBInfoRequest message node 'i'.

See Also:
Constant Field Values

NODE_FORMAT_HBINFOREPLY

public static final byte NODE_FORMAT_HBINFOREPLY
The HBInfoReply message node 'I'.

See Also:
Constant Field Values

NODE_FORMAT_VERSION

public static final byte NODE_FORMAT_VERSION
The FormatVersion message node 'v'.

See Also:
Constant Field Values

NODE_FORMAT_CONNECTION

public static final byte NODE_FORMAT_CONNECTION
The Connection message node 'c'.

See Also:
Constant Field Values

NODE_FORMAT_ROUTINGR

public static final byte NODE_FORMAT_ROUTINGR
The RoutingR message node 'r'.

See Also:
Constant Field Values

NODE_FORMAT_ROUTINGS

public static final byte NODE_FORMAT_ROUTINGS
The RoutingS message node 's'.

See Also:
Constant Field Values

NODE_FORMAT_MARK

public static final byte NODE_FORMAT_MARK
The mark message node 'm'.

See Also:
Constant Field Values

NODE_FORMAT_RELIABLE

public static final byte NODE_FORMAT_RELIABLE
The Reliable message node 'R'.

See Also:
Constant Field Values

NODE_FORMAT_ACKMESSAGE

public static final byte NODE_FORMAT_ACKMESSAGE
The Reliable Ack message node 'A'.

See Also:
Constant Field Values

NODE_FORMAT_RESENDMESSAGE

public static final byte NODE_FORMAT_RESENDMESSAGE
The Reliable resend message node 'B'.

See Also:
Constant Field Values

NODE_FORMAT_CHOPPED

public static final byte NODE_FORMAT_CHOPPED
The Chopped message node '-'.

See Also:
Constant Field Values

NODE_FORMAT_SINGLE_SHOT

public static final byte NODE_FORMAT_SINGLE_SHOT
The single-shot message node 'S'.

See Also:
Constant Field Values

NODE_FORMAT_PUBLISH

public static final byte NODE_FORMAT_PUBLISH
The publish message node 'P'.

See Also:
Constant Field Values

NODE_FORMAT_GROUP_JOIN

public static final byte NODE_FORMAT_GROUP_JOIN
The group join message node 'g'.

See Also:
Constant Field Values

NODE_FORMAT_GROUP_MESSAGE

public static final byte NODE_FORMAT_GROUP_MESSAGE
The group message node 'G'.

See Also:
Constant Field Values

NODE_FORMAT_GROUP_LEAVE

public static final byte NODE_FORMAT_GROUP_LEAVE
The group leave message node 'q'.

See Also:
Constant Field Values

FUNCTION_NONE

public static final byte FUNCTION_NONE
Special value used when function has not been set

See Also:
Constant Field Values

FUNCTION_RADIOCASTED

public static final byte FUNCTION_RADIOCASTED
See Also:
Constant Field Values

FUNCTION_OPEN

public static final byte FUNCTION_OPEN
See Also:
Constant Field Values

FUNCTION_OPEN_REPLY

public static final byte FUNCTION_OPEN_REPLY
See Also:
Constant Field Values

FUNCTION_CLOSE

public static final byte FUNCTION_CLOSE
See Also:
Constant Field Values

FUNCTION_RE_OPEN

public static final byte FUNCTION_RE_OPEN
See Also:
Constant Field Values

FUNCTION_MESSAGE_OVER_CONNECTION

public static final byte FUNCTION_MESSAGE_OVER_CONNECTION
See Also:
Constant Field Values

FUNCTION_USER_ID

public static final byte FUNCTION_USER_ID
See Also:
Constant Field Values
Constructor Detail

MessageHeaderNode

public MessageHeaderNode(byte[] data,
                         int offset,
                         int length)
Constructs a message header node from an array with data. If the syntax is incorrect the header node will have format identifier set to NODE_FORMAT_NONE.

Parameters:
data - The array with data
offset - The offset to start parsing from
length - Parse the message to at most length bytes.

MessageHeaderNode

public MessageHeaderNode(byte formatIdentifier)
Constructs a message header node with no data. (HBInfoRequests uses this format)

Parameters:
formatIdentifier - The format of the node

MessageHeaderNode

public MessageHeaderNode(byte formatIdentifier,
                         java.lang.String[] data)
Constructs a message header node from the parameters with no function identifier.

Parameters:
formatIdentifier - The format of the node
data - The data part of the node

MessageHeaderNode

public MessageHeaderNode(byte formatIdentifier,
                         byte functionIdentifier,
                         java.lang.String[] data)
Constructs a message header node from the parameters. If the format is connection use the functionIdentifier parameter otherwise use FUNCTION_NONE for it.

Parameters:
formatIdentifier - The format of the node
functionIdentifier - The function of the node
data - The data part of the node
Method Detail

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
Returns:
The message header node as a string

getData

public java.lang.String[] getData()

getFormatIdentifier

public byte getFormatIdentifier()

getFunctionIdentifier

public byte getFunctionIdentifier()

getLength

public int getLength()
Returns the length of the data part of the node without the header part.


getTotalLength

public int getTotalLength()
Returns the total length of the message header node, including the length of the header with length and format.


toByteArray

public byte[] toByteArray()

getMessageDataNodeOffset

public static int getMessageDataNodeOffset(byte[] message)
Returns the offset where the message data node or nodes start in a byte array containing an entire message.

Parameters:
message - The message to find the data node part in.
Returns:
The message data node offset.

getCopy

public MessageHeaderNode getCopy()