net.sf.beep4j.internal
Class DataHeader

java.lang.Object
  extended by net.sf.beep4j.internal.DataHeader
Direct Known Subclasses:
DataHeader.ANSHeader

public class DataHeader
extends java.lang.Object

Represents a data header as specified by the BEEP specification.

Author:
Simon Raess

Nested Class Summary
static class DataHeader.ANSHeader
          Header for messages of type ANS.
 
Field Summary
protected  int channel
          The channel number of the frame.
protected  boolean intermediate
          Whether this is an intermediate frame.
protected  int messageNumber
          The message number of the frame.
protected  int payloadSize
          The size of the frame's payload.
protected  long sequenceNumber
          The sequence number of the first byte in the frame's payload.
protected  MessageType type
          The message type of the frame.
 
Constructor Summary
DataHeader(MessageType type, int channel, int messageNumber, boolean intermediate, long sequenceNumber, int size)
          Creates a new DataHeader.
 
Method Summary
 java.nio.ByteBuffer asByteBuffer()
          Converts the header into a ByteBuffer.
 boolean equals(java.lang.Object obj)
           
 int getChannel()
           
 int getMessageNumber()
           
 int getPayloadSize()
           
 long getSequenceNumber()
           
 MessageType getType()
           
 int hashCode()
           
 boolean isIntermediate()
           
static DataHeader parseHeader(java.lang.String[] tokens)
          Parses the passed in tokenized header line into a DataHeader.
 DataHeader[] split(int size)
          Splits the header into two parts.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

type

protected MessageType type
The message type of the frame.


payloadSize

protected int payloadSize
The size of the frame's payload.


channel

protected int channel
The channel number of the frame.


messageNumber

protected int messageNumber
The message number of the frame.


intermediate

protected boolean intermediate
Whether this is an intermediate frame.


sequenceNumber

protected long sequenceNumber
The sequence number of the first byte in the frame's payload.

Constructor Detail

DataHeader

public DataHeader(MessageType type,
                  int channel,
                  int messageNumber,
                  boolean intermediate,
                  long sequenceNumber,
                  int size)
Creates a new DataHeader.

Parameters:
type - the message type of the frame
channel - the channel number, must be greater or equal than zero
messageNumber - the message number of the frame
intermediate - whether this is an intermediate frame
sequenceNumber - the sequence number of the frame
size - the payload size of the frame
Method Detail

parseHeader

public static final DataHeader parseHeader(java.lang.String[] tokens)
Parses the passed in tokenized header line into a DataHeader.

Parameters:
tokens - the tokenized header line
Returns:
the parsed header

getType

public MessageType getType()

getChannel

public int getChannel()

getMessageNumber

public int getMessageNumber()

isIntermediate

public boolean isIntermediate()

getPayloadSize

public int getPayloadSize()

getSequenceNumber

public long getSequenceNumber()

split

public DataHeader[] split(int size)
Splits the header into two parts. The first part's size is set to the passed in parameter. It has the intermediate flag set to true. The second part has the remaining size plus its sequence number adapted.

Parameters:
size - the size of the first part
Returns:
an array of two elements

asByteBuffer

public java.nio.ByteBuffer asByteBuffer()
Converts the header into a ByteBuffer.

Returns:
the converted ByteBuffer

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © 2007 null. All Rights Reserved.