Package jade.imtp.leap.JICP
Class JICPPacket
- java.lang.Object
-
- jade.imtp.leap.JICP.JICPPacket
-
public class JICPPacket extends Object
This class is the JICP data packet representation along with methods for reading from and writing to dataXXputStreams.- Author:
- Ronnie Taib - Motorola, Steffen Rusitschka - Siemens AG
-
-
Field Summary
Fields Modifier and Type Field Description static intMAX_SIZE
-
Constructor Summary
Constructors Constructor Description JICPPacket(byte type, byte info, byte[] data)Constructor.JICPPacket(byte type, byte info, String recipientID, byte[] data)Constructor used to set the recipientID.JICPPacket(String explanation, Exception e)constructs a JICPPacket of type JICPProtocol.ERROR_TYPE and sets the data to the string representation of the exception.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]getData()bytegetInfo()intgetLength()StringgetRecipientID()bytegetSessionID()bytegetType()static JICPPacketreadFrom(InputStream in)This static method reads from a givenDataInputStreamand returns the JICPPacket that it reads.voidsetRecipientID(String id)Set the recipientID of this packet and adjust the info field accordingly.voidsetSessionID(byte id)Set the sessionID of this packet and adjust the info field accordingly.voidsetTerminatedInfo(boolean set)Set the TERMINATED_INFO flag in the info field.intwriteTo(OutputStream out)Writes the packet into the providedOutputStream.
-
-
-
Field Detail
-
MAX_SIZE
public static final int MAX_SIZE
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
JICPPacket
public JICPPacket(byte type, byte info, byte[] data)Constructor.- Parameters:
type- The type of data included in the packetdata- The data itself, as a byte array.
-
JICPPacket
public JICPPacket(byte type, byte info, String recipientID, byte[] data)Constructor used to set the recipientID.- Parameters:
type- The type of data included in the packetdata- The data itself, as a byte array.
-
-
Method Detail
-
getType
public byte getType()
- Returns:
- The type of data included in the packet.
-
getInfo
public byte getInfo()
- Returns:
- the info field of this packet
-
getSessionID
public byte getSessionID()
- Returns:
- The sessionID of this packet.
-
setSessionID
public void setSessionID(byte id)
Set the sessionID of this packet and adjust the info field accordingly.
-
getRecipientID
public String getRecipientID()
- Returns:
- The recipientID of this packet.
-
setRecipientID
public void setRecipientID(String id)
Set the recipientID of this packet and adjust the info field accordingly.
-
setTerminatedInfo
public void setTerminatedInfo(boolean set)
Set the TERMINATED_INFO flag in the info field.
-
getData
public byte[] getData()
- Returns:
- The actual data included in the packet, as a byte array.
-
writeTo
public int writeTo(OutputStream out) throws IOException
Writes the packet into the providedOutputStream. The packet is serialized in an internal representation, so the data should be retrieved and deserialized with thereadFrom()static method below. The output stream is flushed but not opened nor closed by this method.- Parameters:
out- TheOutputStreamto write the data in- Throws:
May- send a large bunch of exceptions, mainly in the IO package.IOException
-
readFrom
public static JICPPacket readFrom(InputStream in) throws IOException
This static method reads from a givenDataInputStreamand returns the JICPPacket that it reads. The input stream is not opened nor closed by this method.- Parameters:
in- TheInputStreamto read from- Throws:
May- send a large bunch of exceptions, mainly in the IO package.IOException
-
getLength
public int getLength()
-
-