org.mobicents.protocols.smpp.util
Class PacketDecoderImpl

java.lang.Object
  extended by org.mobicents.protocols.smpp.util.PacketDecoderImpl
All Implemented Interfaces:
PacketDecoder

public class PacketDecoderImpl
extends Object
implements PacketDecoder

Implementation of the packet decoder.

Version:
$Id: PacketDecoderImpl.java 457 2009-01-15 17:37:42Z orank $

Constructor Summary
PacketDecoderImpl()
           
PacketDecoderImpl(byte[] bytes)
           
PacketDecoderImpl(byte[] bytes, int parsePosition)
           
 
Method Summary
 int getAvailableBytes()
          Get the number of available bytes to be read by this decoder.
 byte[] getBytes()
           
 int getParsePosition()
          Get the current parse position of this packet decoder.
 Address readAddress()
          Read an SMPP address from the byte array.
 byte readByte()
          Read a byte from the byte array.
 byte[] readBytes(int length)
          Get a byte array sub-set from the specified byte array.
 String readCString()
          Read a C-String (a string terminated by a nul-byte) from the byte array.
 SMPPDate readDate()
          Read an SMPP date from the byte array.
 ErrorAddress readErrorAddress()
          Read an SMPP address and error code pairing.
 long readInt8()
           
 String readString(int length)
          Read a fixed-length String from the bytes.
 int readUInt1()
          Read a 1-byte unsigned integer from the array.
 int readUInt2()
          Read a 2-byte unsigned integer from the array.
 long readUInt4()
          Read a 4-byte unsigned integer from the array.
 void setBytes(byte[] bytes)
           
 void setParsePosition(int pos)
          Set the current parse position of this decoder.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PacketDecoderImpl

public PacketDecoderImpl()

PacketDecoderImpl

public PacketDecoderImpl(byte[] bytes)

PacketDecoderImpl

public PacketDecoderImpl(byte[] bytes,
                         int parsePosition)
Method Detail

getBytes

public byte[] getBytes()

setBytes

public void setBytes(byte[] bytes)

getParsePosition

public int getParsePosition()
Description copied from interface: PacketDecoder
Get the current parse position of this packet decoder.

Specified by:
getParsePosition in interface PacketDecoder
Returns:
The current parse position.

setParsePosition

public void setParsePosition(int pos)
Description copied from interface: PacketDecoder
Set the current parse position of this decoder.

Specified by:
setParsePosition in interface PacketDecoder
Parameters:
pos - The new parse position.

getAvailableBytes

public int getAvailableBytes()
Description copied from interface: PacketDecoder
Get the number of available bytes to be read by this decoder.

Specified by:
getAvailableBytes in interface PacketDecoder
Returns:
The number of bytes that can be decoded.

readByte

public byte readByte()
Description copied from interface: PacketDecoder
Read a byte from the byte array.

Specified by:
readByte in interface PacketDecoder
Returns:
The byte at the specified parse position in the array.

readCString

public String readCString()
Description copied from interface: PacketDecoder
Read a C-String (a string terminated by a nul-byte) from the byte array. The bytes will be interpreted as US-ASCII characters.

Specified by:
readCString in interface PacketDecoder
Returns:
The decoded String.

readString

public String readString(int length)
Description copied from interface: PacketDecoder
Read a fixed-length String from the bytes. The bytes will be interpreted as US-ASCII characters.

Specified by:
readString in interface PacketDecoder
Parameters:
length - The number of bytes to parse for the string.
Returns:
The decoded String.

readUInt1

public int readUInt1()
Description copied from interface: PacketDecoder
Read a 1-byte unsigned integer from the array.

Specified by:
readUInt1 in interface PacketDecoder
Returns:
The decoded integer.

readUInt2

public int readUInt2()
Description copied from interface: PacketDecoder
Read a 2-byte unsigned integer from the array. SMPP integers are big-endian, also known as network byte order.

Specified by:
readUInt2 in interface PacketDecoder
Returns:
The decoded integer.

readUInt4

public long readUInt4()
Description copied from interface: PacketDecoder
Read a 4-byte unsigned integer from the array. SMPP integers are big-endian, also known as network byte order. Since the integers are unsigned, a Java long primitive is required to hold all the possible values.

Specified by:
readUInt4 in interface PacketDecoder
Returns:
The decoded (long) integer.

readInt8

public long readInt8()
Specified by:
readInt8 in interface PacketDecoder

readAddress

public Address readAddress()
Description copied from interface: PacketDecoder
Read an SMPP address from the byte array.

Specified by:
readAddress in interface PacketDecoder
Returns:
The parsed address.

readErrorAddress

public ErrorAddress readErrorAddress()
Description copied from interface: PacketDecoder
Read an SMPP address and error code pairing. This is used in the submit multi response packet to create its table of unsuccessful submissions.

Specified by:
readErrorAddress in interface PacketDecoder
Returns:
An error address object.

readDate

public SMPPDate readDate()
Description copied from interface: PacketDecoder
Read an SMPP date from the byte array.

Specified by:
readDate in interface PacketDecoder
Returns:
The parsed SMPP date, or null if the date is null.

readBytes

public byte[] readBytes(int length)
Description copied from interface: PacketDecoder
Get a byte array sub-set from the specified byte array.

Specified by:
readBytes in interface PacketDecoder
Parameters:
length - The number of bytes to copy out of the array.
Returns:
A byte array with length bytes in it copied from bytes.


Copyright © 2011 Mobicents. All Rights Reserved.