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

java.lang.Object
  extended by com.mindtree.techworks.insight.remoteprotocol.spi.PacketDataContent
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
LogMessageDataContent, NullMessageDataContent, StartupMessageDataContent

public abstract class PacketDataContent
extends java.lang.Object
implements java.io.Serializable

Abstract class representing the data content in the DataPacket. This class contains the byte representation of the data. Specific subclasses may provide methods to access the data in a friendlier way. Unless an object of this class is an instance of NullMessageDataContent, setting null data is not allowed.

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

Field Summary
static int MAX_PACKET_DATA_SIZE
          The maximum number of bytes a data packet can have.
protected  MessageType messageType
          Identifies the type of this message packet.
protected  byte[] packetData
          Packet Data without the header
 
Constructor Summary
PacketDataContent()
          Creates an instance of PacketDataContent object
PacketDataContent(byte[] completePacketData, PacketHeader packetHeader)
          Creates an instance of PacketDataContent object.
 
Method Summary
protected  void checkPacketDataSize(byte[] dataToSet)
          Checks the packet data size and ensures that this is less than MAX_PACKET_DATA_SIZE.
 int getLength()
          Returns the length of the data in the packet.
 MessageType getMessageType()
          Returns the messageType
 byte[] getPacketData()
          Returns the packetData.
 void setMessageType(MessageType messageType)
          Sets the messageType field
 void setPacketData(byte[] packetData)
          Sets the packetData field
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_PACKET_DATA_SIZE

public static final int MAX_PACKET_DATA_SIZE
The maximum number of bytes a data packet can have. It is enforced by the

See Also:
Constant Field Values

packetData

protected byte[] packetData
Packet Data without the header


messageType

protected MessageType messageType
Identifies the type of this message packet.

Constructor Detail

PacketDataContent

public PacketDataContent()
Creates an instance of PacketDataContent object


PacketDataContent

public PacketDataContent(byte[] completePacketData,
                         PacketHeader packetHeader)
Creates an instance of PacketDataContent object.

The byte [] passed in should be complete data for the packet including the header. The constructor will start reading data for this packet leaving the bytes required for the Header.

Note: Using this constructor requires that certain fields regarding this packet be already set in the header. In particular the following fields in the header are used:

Parameters:
completePacketData -
packetHeader -
Method Detail

getLength

public int getLength()
Returns the length of the data in the packet.

Returns:
the number of bytes in the data.

getMessageType

public MessageType getMessageType()
Returns the messageType

Returns:
Returns the messageType.

setMessageType

public void setMessageType(MessageType messageType)
Sets the messageType field

Parameters:
messageType - The messageType to set.

getPacketData

public byte[] getPacketData()
Returns the packetData. Although it would be more appropriate to use the specific methods in the subtype of this class to get the data in the correct format.

Returns:
Returns the packetData.

setPacketData

public void setPacketData(byte[] packetData)
                   throws RemoteProtocolException
Sets the packetData field

Parameters:
packetData - The packetData to set.
Throws:
PacketDataSizeOverLimitsException - This may be thrown if the packet data is over limit
RemoteProtocolException - This may be thrown by a subclass overriding this method to indicate some invalid data.

checkPacketDataSize

protected void checkPacketDataSize(byte[] dataToSet)
                            throws PacketDataSizeOverLimitsException
Checks the packet data size and ensures that this is less than MAX_PACKET_DATA_SIZE. This method is called before setting packet data. If subclasses override the #setPacketData(byte[]) method, then they should call this method before setting the data.

Parameters:
dataToSet - Checks the data to set
Throws:
PacketDataSizeOverLimitsException - If the data size is over the allowed limit


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