its.backbone.frame
Class ItsFrame

java.lang.Object
  extended byits.backbone.frame.ItsFrame

public class ItsFrame
extends java.lang.Object

Fundamental low-level unit of network communication for ITS applications. Contains methods to read and write the frame header and data to a stream.

Author:
Rick Kint

Field Summary
static int FLAG_COMPRESSED
          If FLAG_COMPRESSED is set in the ItsFrame header flag field, then the frame has been compressed with GZIPOutputStream.
 
Constructor Summary
ItsFrame()
          Constructs null ITS frame.
ItsFrame(java.io.InputStream is)
          Constructs ITS frame and reads its contents from an ITS stream.
ItsFrame(ItsInputStream is)
           
ItsFrame(short newType, byte[] newData)
          Constructs an ITS frame with the type as a parameter, reading the data from a byte array.
ItsFrame(short newType, ItsData newData)
          Constructs an ITS frame with the type as a parameter, reading the data from an ItsData It is anticipated that this constructor will be used to create an ITS frame for output using existing data.
 
Method Summary
 byte[] getData()
          Returns the data portion of the frame as a byte array.
 int getDataLength()
          Returns the length of the data portion of the frame (which may be zero).
 int getFlags()
           
 short getTimeout()
           
 ItsFrameType getType()
          Returns the ITS Frame type
 int getVersion()
           
 short getXid()
          Returns the transaction ID
 void read(java.io.InputStream is)
          Reads the frame from an InputStream
 void setData(byte[] newData)
          Sets the data portion of the frame to a new byte array (which may be null)
 void setFlags(int flags)
           
 void setTimeout(short s)
           
 void setXid(short theXid)
          Sets the Xid
 void write(java.io.DataOutput do_)
          Writes an ITS frame to an OutputStream
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FLAG_COMPRESSED

public static final int FLAG_COMPRESSED
If FLAG_COMPRESSED is set in the ItsFrame header flag field, then the frame has been compressed with GZIPOutputStream.

See Also:
Constant Field Values
Constructor Detail

ItsFrame

public ItsFrame()
Constructs null ITS frame.


ItsFrame

public ItsFrame(java.io.InputStream is)
         throws java.io.IOException,
                BadMagicException
Constructs ITS frame and reads its contents from an ITS stream.

Throws:
java.io.IOException - io error
BadMagicException - if the magic number is incorrect

ItsFrame

public ItsFrame(ItsInputStream is)
         throws java.io.IOException,
                BadMagicException

ItsFrame

public ItsFrame(short newType,
                byte[] newData)
Constructs an ITS frame with the type as a parameter, reading the data from a byte array. It is anticipated that this constructor will be used to create an ITS frame for output using existing data. Other fields (XID, flags) will have to be set using accessor methods.

Throws:
java.io.IOException - io error

ItsFrame

public ItsFrame(short newType,
                ItsData newData)
Constructs an ITS frame with the type as a parameter, reading the data from an ItsData It is anticipated that this constructor will be used to create an ITS frame for output using existing data. Other fields (XID, flags) will have to be set using accessor methods.

Method Detail

setData

public void setData(byte[] newData)
Sets the data portion of the frame to a new byte array (which may be null)

Parameters:
newData - byte[], the data to be added to the frame

getData

public byte[] getData()
Returns the data portion of the frame as a byte array. This is an object reference so the data may be modified


getDataLength

public int getDataLength()
Returns the length of the data portion of the frame (which may be zero).


getType

public ItsFrameType getType()
Returns the ITS Frame type


getFlags

public int getFlags()

setFlags

public void setFlags(int flags)

getXid

public short getXid()
Returns the transaction ID


setXid

public void setXid(short theXid)
Sets the Xid

Parameters:
theXid - new Xid value

getTimeout

public short getTimeout()

setTimeout

public void setTimeout(short s)

getVersion

public int getVersion()

read

public void read(java.io.InputStream is)
          throws java.io.IOException,
                 BadMagicException
Reads the frame from an InputStream

Throws:
java.io.IOException - io error
BadMagicException - bad magic number in header

write

public void write(java.io.DataOutput do_)
           throws java.io.IOException
Writes an ITS frame to an OutputStream

Throws:
java.io.IOException - io error