Version

ByteBufUtil

public class ByteBufUtil
Extends: java.lang.Object
ByteBufUtil is a utility class for low-level byte buffer operations used in encoding and decoding SMPP protocol data. It provides static methods to read, write, and calculate sizes for fields like addresses, TLVs, and strings using Netty's ByteBuf. This class is used statically — there's no need to create an instance.

Fields:

Field Type Description
logger Logger Logger used for internal debugging or error reporting.
EMPTY_ADDRESS Address A reusable constant representing an empty SMPP address.
PDU_CMD_ID_RESP_MASK int Bitmask used to identify whether a command ID is a response type.

Constructor:

public ByteBufUtil()
Standard constructor. Not used since all methods are static.

Methods:

boolean isRequestCommandId(int commandId) Checks if the given command ID represents a request PDU.
int calculateByteSizeOfAddress(Address value) Calculates the number of bytes needed to encode an SMPP address.
Address readAddress(ByteBuf buffer)

Reads and returns an Address from the buffer.

Throws: UnrecoverablePduException, RecoverablePduException

void writeAddress(ByteBuf buffer, Address value)

Writes an Address to the buffer.

Throws: UnrecoverablePduException, RecoverablePduException

Tlv readTlv(ByteBuf buffer)

Reads a TLV object from the buffer.

Throws: NotEnoughDataInBufferException

void writeTlv(ByteBuf buffer, Tlv tlv)

Writes a TLV into the buffer.

Throws: NotEnoughDataInBufferException

int calculateByteSizeOfNullTerminatedString(String value) Returns the size in bytes of a null-terminated string.
void writeNullTerminatedString(ByteBuf buffer, String value)

Writes a null-terminated string into the buffer.

Throws: UnrecoverablePduException

String readNullTerminatedString(ByteBuf buffer)

Reads a string from the buffer, stopping at the null terminator.

Throws: TerminatingNullByteNotFoundException

Methods inherited from class java.lang.Object

equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Start innovating with Mobius

What's next? Let's talk!

Mobius Software

As a company you'll get:

  • Get started quickly

  • Support any business model

  • Join millions of businesses

Questions? websupport@mobius.com