com.mindtree.techworks.insight.remoteprotocol.spi
Class DataPacket

java.lang.Object
  extended by com.mindtree.techworks.insight.remoteprotocol.spi.DataPacket
All Implemented Interfaces:
java.io.Serializable

public class DataPacket
extends java.lang.Object
implements java.io.Serializable

Represents a data packet sent to Insight. The packet concists of a header which in the Java world is the PacketHeader class, and some content of the packet, which are represented by the subclasses of PacketDataContent.

The format of the data packet is described in the PacketHeader class.

Version:
$Revision: 1.2 $ $Date: 2005/08/09 18:39:16 $
Author:
Bindul Bhowmik
See Also:
PacketHeader, PacketDataContent, Serialized Form

Field Summary
static int MAX_PACKET_SIZE
          Maximum number of bytes a packet should have.
 
Constructor Summary
DataPacket()
          Creates an instance of DataPacket
DataPacket(PacketDataContent content, PacketHeader header)
          Creates a DataPacket instance
 
Method Summary
 byte[] getDataPacketAsByteArray()
          Returns the entire packet as a byte array.
 PacketDataContent getPacketDataContent()
          Returns the content of the packet
 PacketHeader getPacketHeader()
          Returns the packet's header
 void recalculatePacketHeader()
          Recalculates the packet's data relative content.
 void setPacketDataContent(PacketDataContent packetDataContent)
          Sets the content of the packet
 void setPacketHeader(PacketHeader packetHeader)
          Sets the packet's header
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_PACKET_SIZE

public static final int MAX_PACKET_SIZE
Maximum number of bytes a packet should have.

See Also:
Constant Field Values
Constructor Detail

DataPacket

public DataPacket(PacketDataContent content,
                  PacketHeader header)
Creates a DataPacket instance

Parameters:
content - The content of the packet
header - The header of the packet

DataPacket

public DataPacket()
Creates an instance of DataPacket

Method Detail

getPacketDataContent

public PacketDataContent getPacketDataContent()
Returns the content of the packet

Returns:
The PacketDataContent

setPacketDataContent

public void setPacketDataContent(PacketDataContent packetDataContent)
Sets the content of the packet

Parameters:
packetDataContent - The PacketDataContent to set

getPacketHeader

public PacketHeader getPacketHeader()
Returns the packet's header

Returns:
The instance's PacketHeader

setPacketHeader

public void setPacketHeader(PacketHeader packetHeader)
Sets the packet's header

Parameters:
packetHeader - The PacketHeader to set

getDataPacketAsByteArray

public byte[] getDataPacketAsByteArray()
Returns the entire packet as a byte array.

Returns:
The contents in this packet as a byte array.

recalculatePacketHeader

public void recalculatePacketHeader()
Recalculates the packet's data relative content. In particular the following fields are recalculated and set:
  1. DATA LENGTH
  2. HEADER CHECKSUM

See Also:
PacketHeader.recalculateHeader(PacketDataContent)


Copyright © 2003-2008 MindTree Consulting Ltd.. All Rights Reserved.