org.jsmpp.util
Class PDUByteBuffer

java.lang.Object
  extended by org.jsmpp.util.PDUByteBuffer

public class PDUByteBuffer
extends java.lang.Object

Utility to compose the PDU bytes. The size of the buffer is depends to the entities appended to the buffer.

Since:
1.0
Version:
1.0
Author:
uudashr

Constructor Summary
PDUByteBuffer()
          Default constructor.
PDUByteBuffer(CapacityPolicy capacityPolicy)
          Construct with specified capacity policy.
PDUByteBuffer(int commandId, int commandStatus, int sequenceNumber)
          Construct with specified command_id, command_status, and sequence_number.
PDUByteBuffer(int commandId, int commandStatus, int sequenceNumber, CapacityPolicy capacityPolicy)
          Construct with specified command_id, command_status, sequence_number and capacity policy.
 
Method Summary
 int append(byte b)
          Append single byte.
 int append(byte[] bytes)
          Append all bytes.
 int append(byte[] b, int offset, int length)
          Append bytes to specified offset and length.
 int append(int intValue)
          Append int value (contains 4 octet).
 int append(OptionalParameter optionalParameter)
          Append an optional parameter.
 int append(java.lang.String stringValue)
          Append C-Octet String / null terminated String value.
 int append(java.lang.String stringValue, boolean nullTerminated)
          Append String value.
 int appendAll(OptionalParameter[] optionalParameters)
          Append all optional parameters.
 byte[] toBytes()
          Get the composed bytes of PDU.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PDUByteBuffer

public PDUByteBuffer(int commandId,
                     int commandStatus,
                     int sequenceNumber)
Construct with specified command_id, command_status, and sequence_number.

Parameters:
commandId - is the command_id.
commandStatus - is the command_status.
sequenceNumber - is the sequence_number.

PDUByteBuffer

public PDUByteBuffer(int commandId,
                     int commandStatus,
                     int sequenceNumber,
                     CapacityPolicy capacityPolicy)
Construct with specified command_id, command_status, sequence_number and capacity policy.

Parameters:
commandId - is the command_id.
commandStatus - is the command_status.
sequenceNumber - is the sequence_number.
capacityPolicy - is the capacity policy.

PDUByteBuffer

public PDUByteBuffer()
Default constructor.


PDUByteBuffer

public PDUByteBuffer(CapacityPolicy capacityPolicy)
Construct with specified capacity policy.

Parameters:
capacityPolicy - is the capacity policy.
Method Detail

append

public int append(byte[] b,
                  int offset,
                  int length)
Append bytes to specified offset and length.

Parameters:
b - is the bytes to append.
offset - is the offset where the bytes will be placed.
length - the length that will specified which part of the bytes will be append.
Returns:
the latest length of the byte buffer.

append

public int append(byte[] bytes)
Append all bytes.

Parameters:
bytes - is the bytes to append.
Returns:
the latest length of the buffer.

append

public int append(byte b)
Append single byte.

Parameters:
b - is the byte to append.
Returns:
the latest length of the buffer.

append

public int append(int intValue)
Append int value (contains 4 octet).

Parameters:
intValue - is the value to append.
Returns:
the latest length of the buffer.

append

public int append(java.lang.String stringValue,
                  boolean nullTerminated)
Append String value.

Parameters:
stringValue -
nullTerminated - true means C-Octet String. The default value is true.
Returns:
the latest length of the buffer.

append

public int append(java.lang.String stringValue)
Append C-Octet String / null terminated String value.

Parameters:
stringValue - is the value to append.
Returns:
the latest length of the buffer.

append

public int append(OptionalParameter optionalParameter)
Append an optional parameter.

Parameters:
optionalParameter - is the optional parameter.
Returns:
the latest length of the buffer.

appendAll

public int appendAll(OptionalParameter[] optionalParameters)
Append all optional parameters.

Parameters:
optionalParameters - is the optional parameters.
Returns:
the latest length of the buffer.

toBytes

public byte[] toBytes()
Get the composed bytes of PDU.

Returns:
the composed bytes.