|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--edu.UCL.xmiddle.controller.DataPacket
This class represents a data packet, either received from or being sent to another host.
Data
Field Summary |
Fields inherited from interface edu.UCL.xmiddle.framework.controller.Data |
RECEIVED, TO_SEND |
Constructor Summary | |
DataPacket(Host host,
boolean type,
byte[] data)
Creates a new DataPacket |
|
DataPacket(Host host,
boolean type,
org.w3c.dom.Node data)
Creates a new DataPacket |
|
DataPacket(Host host,
boolean type,
java.lang.String data)
Creates a new DataPacket |
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 |
init(Host host,
boolean type)
|
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. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public DataPacket(Host host, boolean type, byte[] data)
DataPacket
host
- a Host
valuetype
- either TO_SEND or RECEIVEDdata
- a byte[]
valuepublic DataPacket(Host host, boolean type, java.lang.String data)
DataPacket
host
- a Host
valuetype
- either TO_SEND or RECEIVEDdata
- a String
valuepublic DataPacket(Host host, boolean type, org.w3c.dom.Node data)
DataPacket
host
- a Host
valuetype
- either TO_SEND or RECEIVEDdata
- a Node
valueMethod Detail |
public void setData(byte[] data)
Data
setData
in interface Data
data
- a byte[]
valuepublic void setData(byte[] data, int offset, int length)
Data
setData
in interface Data
data
- a byte[]
valueoffset
- from offsetlength
- to offset+lengthpublic void setData(java.lang.String data)
Data
setData
in interface Data
data
- a String
valuepublic void init(Host host, boolean type)
public byte[] getData()
Data
getData
in interface Data
byte[]
valuepublic void setHost(Host host)
Data
setHost
in interface Data
host
- is the target host.public Host getHost()
Data
getHost
in interface Data
Host
valuepublic boolean getType()
Data
getType
in interface Data
TO_SEND
or RECEIVED
public void setType(boolean type)
Data
TO_SEND
or RECEIVED
setType
in interface Data
type
- the type of the packetpublic void setData(org.w3c.dom.Node data)
Data
setData
in interface Data
data
- a Node
valuepublic byte[][] getData(int segmentSize)
Data
getData
in interface Data
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.
public java.lang.Object getCheck()
Data
getCheck
in interface Data
Object
valuepublic java.lang.Object getCalculatedCheck()
Data
RECEIVED
and getCalculatedCheck()
does not match getCheck
then there has been a
transmission error.
getCalculatedCheck
in interface Data
Object
valuepublic void appendData(byte[] data)
Data
appendData
in interface Data
data
- a byte[]
valuepublic void prependData(byte[] data)
Data
prependData
in interface Data
data
- a byte[]
valuepublic void appendData(byte[] data, int offset, int length)
Data
appendData
in interface Data
data
- a byte[]
valueoffset
- from offsetlength
- to offset+lengthpublic void prependData(byte[] data, int offset, int length)
Data
prependData
in interface Data
data
- a byte[]
valueoffset
- from offsetlength
- to offset+lengthpublic void appendData(java.lang.String data)
Data
appendData
in interface Data
data
- a String
valuepublic void prependData(java.lang.String data)
Data
prependData
in interface Data
data
- a String
valuepublic void appendData(org.w3c.dom.Node data)
Data
appendData
in interface Data
data
- a Node
valuepublic void prependData(org.w3c.dom.Node data)
Data
prependData
in interface Data
data
- a Node
value
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |