com.funambol.push
Class CTPService.CTPMessage

java.lang.Object
  extended by com.funambol.push.CTPService.CTPMessage
Enclosing class:
CTPService

protected class CTPService.CTPMessage
extends java.lang.Object

This class represents a CTP message. Messages format is described in the CTP design document. This class purpose is to allow users to easily create a CTP message, setting all its properties and then to generate the byte sequence that represent such a message. The second goal of the class is to allow the opposite transformation. A byte stream received from the server can be parsed and translated into a CTPMessage object.


Constructor Summary
CTPService.CTPMessage()
          Build an empty message
CTPService.CTPMessage(byte[] rawMessage)
          Build a message decoding the given byte stream
 
Method Summary
 void addParameter(int code, byte[] value)
          Add one parameter
 byte[] getBytes()
          Get a byte representation of this message.
 int getCommand()
          Returns the command or status code
 byte[] getNonce()
          Return the last nonce that has been parsed.
 int getParameterCode(int idx)
          Get the parameter code of a given parameter.
 int getParametersNumber()
          Returns the number of parameters.
 byte[] getParameterValue(int idx)
          Get the parameter value of a given parameter.
 void setCommand(int commandCode)
          Sets the command or status code
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CTPService.CTPMessage

public CTPService.CTPMessage()
Build an empty message


CTPService.CTPMessage

public CTPService.CTPMessage(byte[] rawMessage)
Build a message decoding the given byte stream

Parameters:
rawMessage - is the byte stream representing the CTP message
Method Detail

setCommand

public void setCommand(int commandCode)
Sets the command or status code

Parameters:
the - new code

getCommand

public int getCommand()
Returns the command or status code


addParameter

public void addParameter(int code,
                         byte[] value)
Add one parameter

Parameters:
code - parameter code
value - parameter value

getParametersNumber

public int getParametersNumber()
Returns the number of parameters.


getParameterCode

public int getParameterCode(int idx)
Get the parameter code of a given parameter. An exception maybe thrown if the index is out of bounds.

Parameters:
idx - parameter index
Returns:
the parameter code

getParameterValue

public byte[] getParameterValue(int idx)
Get the parameter value of a given parameter. An exception maybe thrown if the index is out of bounds.


getBytes

public byte[] getBytes()
Get a byte representation of this message. This byte representation is conformant to the CTP protocol specification (see the CTP design document).

Returns:
a byte array representing this message in CTP protocol format

getNonce

public byte[] getNonce()
Return the last nonce that has been parsed. This method is not generic, it does not return the nonce for any CTP message. But only for messages that have been created from a byte stream and which contains a nonce parameter.

Returns:
the nonce value or null if not defined


Copyright © 2001-2009 Funambol.