edu.UCL.xmiddle.framework.controller
Interface Data

All Known Implementing Classes:
DataPacket

public interface Data

Data.java Data is the basic element that is sent and received by the xmiddle networking layer and the Listeners and Senders. It provides a basic interface for storing and retreiving data as well as the host from which the packet was received or is to be sent. Data also has provisions for binding the data with a check (CRC/checksum etc - the choice is left to the implementation) which it can use to find out errors. Created: Thu Jul 19 16:34:36 2001


Field Summary
static boolean RECEIVED
          Represents a packet which was received.
static boolean TO_SEND
          Represents a packet is to be sent
 
Method Summary
 void appendData(byte[] data)
          Append the given information to the current data.
 void appendData(byte[] data, int offset, int length)
          Append the given information to the current data.
 void appendData(org.w3c.dom.Node data)
          Append the given information to the current data.
 void appendData(java.lang.String data)
          Append the given information to the current data.
 java.lang.Object getCalculatedCheck()
          Returns the check that is calculated from the data.
 java.lang.Object getCheck()
          Retutns the check that is bound with the data.
 byte[] getData()
          Returns the data of the packet
 byte[][] getData(int segmentSize)
          Returns the data contained as numbered segments of the given size
 Host getHost()
          Returns the host to which this package is targetted or from which this packet was received
 boolean getType()
          Retrieves the type of the packet
 void prependData(byte[] data)
          Prepend the given information to the current data.
 void prependData(byte[] data, int offset, int length)
          DPrepend the given information to the current data.
 void prependData(org.w3c.dom.Node data)
          Prepend the given information to the current data.
 void prependData(java.lang.String data)
          Prepend the given information to the current data.
 void setData(byte[] data)
          Sets the data that this packet contains
 void setData(byte[] data, int offset, int length)
          Sets the data that this packet contains
 void setData(org.w3c.dom.Node data)
          Sets the data that this packet contains
 void setData(java.lang.String data)
          Sets the data that this packet contains
 void setHost(Host host)
          Sets the host to which this packet is destined to.
 void setType(boolean type)
          Sets the type of the packet.
 

Field Detail

TO_SEND

public static final boolean TO_SEND
Represents a packet is to be sent

See Also:
Constant Field Values

RECEIVED

public static final boolean RECEIVED
Represents a packet which was received.

See Also:
Constant Field Values
Method Detail

setData

public void setData(byte[] data)
Sets the data that this packet contains

Parameters:
data - a byte[] value

setData

public void setData(byte[] data,
                    int offset,
                    int length)
Sets the data that this packet contains

Parameters:
data - a byte[] value
offset - from offset
length - to offset+length

setData

public void setData(java.lang.String data)
Sets the data that this packet contains

Parameters:
data - a String value

setData

public void setData(org.w3c.dom.Node data)
Sets the data that this packet contains

Parameters:
data - a Node value

getData

public byte[] getData()
Returns the data of the packet

Returns:
the data, stored as a byte[] value

getData

public byte[][] getData(int segmentSize)
Returns the data contained as numbered segments of the given size

Parameters:
segmentSize - the maximum size of each segment (in bytes). The last segment returned could possibly contain less bytes - It is up to the caller to check this.
Returns:
the data are returned in an array of byte arrays, of the specified segment size

setHost

public void setHost(Host host)
Sets the host to which this packet is destined to.

Parameters:
host - is the target host.

getHost

public Host getHost()
Returns the host to which this package is targetted or from which this packet was received

Returns:
a Host value

setType

public void setType(boolean type)
Sets the type of the packet. It can either be TO_SEND or RECEIVED

Parameters:
type - the type of the packet

getType

public boolean getType()
Retrieves the type of the packet

Returns:
either TO_SEND or RECEIVED

getCheck

public java.lang.Object getCheck()
Retutns the check that is bound with the data.

Returns:
an Object value

getCalculatedCheck

public java.lang.Object getCalculatedCheck()
Returns the check that is calculated from the data. If the data is RECEIVED and getCalculatedCheck() does not match getCheck then there has been a transmission error.

Returns:
an Object value

appendData

public void appendData(byte[] data)
Append the given information to the current data.

Parameters:
data - a byte[] value

appendData

public void appendData(byte[] data,
                       int offset,
                       int length)
Append the given information to the current data.

Parameters:
data - a byte[] value
offset - from offset
length - to offset+length

appendData

public void appendData(java.lang.String data)
Append the given information to the current data.

Parameters:
data - a String value

appendData

public void appendData(org.w3c.dom.Node data)
Append the given information to the current data.

Parameters:
data - a Node value

prependData

public void prependData(byte[] data)
Prepend the given information to the current data.

Parameters:
data - a byte[] value

prependData

public void prependData(byte[] data,
                        int offset,
                        int length)
DPrepend the given information to the current data.

Parameters:
data - a byte[] value
offset - from offset
length - to offset+length

prependData

public void prependData(java.lang.String data)
Prepend the given information to the current data.

Parameters:
data - a String value

prependData

public void prependData(org.w3c.dom.Node data)
Prepend the given information to the current data.

Parameters:
data - a Node value