com.uc3m.it.pfc.pdp
Class PDPMessage

java.lang.Object
  extended bycom.uc3m.it.pfc.pdp.PDPMessage

class PDPMessage
extends java.lang.Object

The PDPMessage class implements the mechanism to create, manage and parse all available PDP messages.

It provides mechanisms to create new messages from basic data types, convert it into byte arrays to adapt them to be sent through the network, and read an parse messages received from the network.

Version:
initial
Author:
Celeste Campo Vázquez (celeste[at]it.uc3m.es), José Carlos Perea Barreiro (jperea[at]it.uc3m.es)

Field Summary
private  boolean any
          "Any" message flag field.
private  ServiceEntry[] entry
          ServiceEntryList/PRList field form a PDP message
private  byte function_id
          Function ID header field
private static int MAXIMUN_MESSAGE_LENGTH
          Maximun length in bytes for a PDP message
private static byte MINIMUN_MESSAGE_LENGTH
          Minimun length in bytes for a PDP message
private  boolean overflow
          Overflow flag.
protected static byte PDP_SERVICE_DEREGISTER
          Identifier for PDP ServiceDeregister messages
protected static byte PDP_SERVICE_REPLY
          Identifier for PDP ServiceReply messages
protected static byte PDP_SERVICE_REQUEST
          Identifier for PDP ServiceRequest messages
static byte PDP_VERSION
          Version 1.0
private  java.lang.String service_type
          ServiceType field from a ServiceRequest message
private  int xid
          XID header field.
 
Constructor Summary
protected PDPMessage(byte[] data)
          Constructor.
protected PDPMessage(int xid, java.lang.String service_type, java.util.Vector pr_list, boolean any)
          Constructor.
protected PDPMessage(int xid, java.util.Vector entry)
          Constructor.
private PDPMessage(int xid, java.util.Vector entry, byte id)
          Private Constructor.
protected PDPMessage(java.util.Vector entry)
          Constructor.
 
Method Summary
protected  byte[] getBytes()
          Translates this objecto into a byte array to send this PDP message through the network
private  byte[] getEntryBytes()
          Returns a byte array cotainning the information stored on the entry field
private  byte getFlags()
          Returns the flags header field form this PDP message
protected  byte getFunctionID()
          Returns the functionID header field of this PDP message.
protected  ServiceEntry[] getPrList()
          Returns the PRList field from a PDPServiceRequest message
protected  ServiceEntry[] getServiceEntry()
          Returns the ServiceEntry list within an array
protected  java.lang.String getServiceType()
          Returns the serviceType field from a PDPServiceRequest message
protected  int getXID()
          Returns the xid header field from the PDP message.
protected  boolean isAny()
          Returns whether the message is set as a 1-request 1-reply or not.
private  void newEntry(java.util.Vector v, int i)
          Fills entry field from the information given on the parameters
protected  void setXid(int xid)
          Sets the xid on this PDP message
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PDP_VERSION

public static final byte PDP_VERSION
Version 1.0

See Also:
Constant Field Values

PDP_SERVICE_REQUEST

protected static final byte PDP_SERVICE_REQUEST
Identifier for PDP ServiceRequest messages

See Also:
Constant Field Values

PDP_SERVICE_REPLY

protected static final byte PDP_SERVICE_REPLY
Identifier for PDP ServiceReply messages

See Also:
Constant Field Values

PDP_SERVICE_DEREGISTER

protected static final byte PDP_SERVICE_DEREGISTER
Identifier for PDP ServiceDeregister messages

See Also:
Constant Field Values

MINIMUN_MESSAGE_LENGTH

private static final byte MINIMUN_MESSAGE_LENGTH
Minimun length in bytes for a PDP message

See Also:
Constant Field Values

MAXIMUN_MESSAGE_LENGTH

private static final int MAXIMUN_MESSAGE_LENGTH
Maximun length in bytes for a PDP message

See Also:
Constant Field Values

function_id

private byte function_id
Function ID header field


overflow

private boolean overflow
Overflow flag. true whether the entry message does not fit within one single datagram.


any

private boolean any
"Any" message flag field. When true it specifies a 1-request 1-reply type message


xid

private int xid
XID header field. Acts as a message request identifier


service_type

private java.lang.String service_type
ServiceType field from a ServiceRequest message


entry

private ServiceEntry[] entry
ServiceEntryList/PRList field form a PDP message

Constructor Detail

PDPMessage

protected PDPMessage(int xid,
                     java.lang.String service_type,
                     java.util.Vector pr_list,
                     boolean any)
              throws PDPException
Constructor. This method creates a new PDP ServiceRequest message with the information given on the parameters

Parameters:
xid - XID message field that identifies every ServiceRequest message
service_type - Type of service to discover on the network
pr_list - Vector of already known services of the type of service requested on the message
any - Any flag field that identifies tye type of the request sent to the network. When true this request is a 1-request 1-reply message type

PDPMessage

protected PDPMessage(int xid,
                     java.util.Vector entry)
              throws PDPException
Constructor. Creates a new ServiceReply message with the information given on the parameters. This method internaly uses ( int, Vector, byte ) Constructor.

Parameters:
xid - XID message field that identifies every ServiceReply message
entry - Vector of services stored on the message

PDPMessage

protected PDPMessage(java.util.Vector entry)
              throws PDPException
Constructor. Creates a new ServiceDeregister message with the information given on the parameter. This method internaly uses ( Vector ) Constructor.

Parameters:
entry - Vector of services stored on the message

PDPMessage

private PDPMessage(int xid,
                   java.util.Vector entry,
                   byte id)
            throws PDPException
Private Constructor. Creates a new ServiceReply (see ( int, Vector )) or ServiceDeregister (see ( Vector )) message to be sent throgh the network.

Parameters:
xid - XID message field that identifies every ServiceReply message. On a ServiceDeregister message this field is set to 0x00
entry - Vector of services stored on the message
id - FunctionID header field message

PDPMessage

protected PDPMessage(byte[] data)
              throws PDPException
Constructor. Creates a new PDPMessage object from a message received from the network.

Parameters:
data - Byte array with the message received from the network
Method Detail

isAny

protected boolean isAny()
Returns whether the message is set as a 1-request 1-reply or not.

Returns:
The "ANY" message flag field

getServiceEntry

protected ServiceEntry[] getServiceEntry()
Returns the ServiceEntry list within an array

Returns:
The serviceentry message field from a ServiceReply or ServiceDeregister message

getFunctionID

protected byte getFunctionID()
Returns the functionID header field of this PDP message.

Returns:
FunctionID header field

getPrList

protected ServiceEntry[] getPrList()
Returns the PRList field from a PDPServiceRequest message

Returns:
PRList message field from a ServiceRequest message

getServiceType

protected java.lang.String getServiceType()
Returns the serviceType field from a PDPServiceRequest message

Returns:
ServiceType message field from a ServiceRequest message

getXID

protected int getXID()
Returns the xid header field from the PDP message.

Returns:
XID header field

setXid

protected void setXid(int xid)
Sets the xid on this PDP message

Parameters:
xid - The xid to set

getFlags

private byte getFlags()
Returns the flags header field form this PDP message

Returns:
The flags header field

getBytes

protected byte[] getBytes()
Translates this objecto into a byte array to send this PDP message through the network


newEntry

private void newEntry(java.util.Vector v,
                      int i)
Fills entry field from the information given on the parameters

Parameters:
v - Vector of ServiceEntry objects to add on the entry field
i - number of elements of the vector to add on the entry field

getEntryBytes

private byte[] getEntryBytes()
Returns a byte array cotainning the information stored on the entry field

Returns:
The byte array with the ServiceEntry message information