|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.mobicents.protocols.smpp.util.SMPPIO
public final class SMPPIO
Class that provides input and output methods for writing Java types encoded as SMPP types. This class cannot be instantiated...all it's methods are static.
| Method Summary | |
|---|---|
static String |
readCString(byte[] bytes,
int offset)
Read a C-String (a string terminated by a nul-byte) from the byte array. |
static int |
readInt4(byte[] b,
int offset)
Read a 4-byte integer from a byte array. |
static long |
readInt8(byte[] b,
int offset)
Read an 8-byte integer from a byte array. |
static String |
readString(byte[] bytes,
int offset,
int length)
Read a fixed-length String from bytes. |
static int |
readUInt1(byte[] b,
int offset)
Read an unsigned 1-byte integer from a byte array. |
static int |
readUInt2(byte[] b,
int offset)
Read a 2-byte unsigned integer from a byte array. |
static long |
readUInt4(byte[] b,
int offset)
Read a 4-byte unsigned integer from a byte array, returning a long. |
static void |
writeByte(int b,
OutputStream out)
Write a byte value to the output stream; |
static void |
writeCString(String s,
OutputStream out)
Write a String to an OutputStream followed by a NUL byte. |
static void |
writeInt(int value,
OutputStream out)
Write a 4-byte integer value to the output stream. |
static void |
writeLong(long value,
OutputStream out)
Write an 8-byte integer value to the output stream. |
static void |
writeLongInt(long value,
OutputStream out)
Write a 4-byte integer value to the output stream. |
static void |
writeShort(int value,
OutputStream out)
Write a 2-byte integer value to the output stream. |
static void |
writeString(String s,
int len,
OutputStream out)
Write a String of specified length to an OutputStream. |
static void |
writeString(String s,
OutputStream out)
Write a String in it's entirety to an OutputStream |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static String readCString(byte[] bytes,
int offset)
bytes - The bytes to decode the string from.offset - The offset in bytes to begin reading the
string from.
ArrayIndexOutOfBoundsException - if no nul byte
is detected in the array.
public static String readString(byte[] bytes,
int offset,
int length)
bytes. The bytes will be
interpreted as US-ASCII characters.
bytes - The bytes to decode the string from.offset - The offset in the array to begin parsing from.length - The number of bytes to parse for the string.
ArrayIndexOutOfBoundsException - if there are insufficient bytes
to parse the string.
public static int readUInt1(byte[] b,
int offset)
b - The byte array to read the integer from.offset - The offset in the array to read the integer from.
ArrayIndexOutOfBoundsException - If there are not enough bytes in
the array.
public static int readUInt2(byte[] b,
int offset)
b - The byte array to read the integer from.offset - The offset at which the (most significant) first byte of
the integer resides.
ArrayIndexOutOfBoundsException - If there are not enough bytes in
the array.
public static int readInt4(byte[] b,
int offset)
Integer.MAX_VALUE
, then the Java value will actually be a negative number.
If you are more interested in the actual value, then use
the readUInt4(byte[], int) method, which will return the real value in a
Java long primitive.
b - The byte array to read the integer from.offset - The offset at which the (most significant) first byte of
the integer resides.
ArrayIndexOutOfBoundsException - If there are not enough bytes in
the array.
public static long readUInt4(byte[] b,
int offset)
long
primitive is needed in Java to support the full range of unsigned
values.
b - The byte array to read the integer from.offset - The offset at which the (most significant) first byte of
the integer resides.
ArrayIndexOutOfBoundsException - If there are not enough bytes in
the array.
public static long readInt8(byte[] b,
int offset)
Long.MAX_VALUE
will be interpreted by Java as negative numbers.
b - The byte array to read the integer from.offset - The offset at which the (most significant) first byte of
the int resides.
ArrayIndexOutOfBoundsException - If there are not enough bytes in
the array.
public static void writeByte(int b,
OutputStream out)
throws IOException
b - The value to write.out - The output stream to write to.
IOException - If an error occurs writing to the stream.
public static void writeShort(int value,
OutputStream out)
throws IOException
value - The value to write.out - The output stream to write to.
IOException - If an error occurs writing to the stream.
public static void writeInt(int value,
OutputStream out)
throws IOException
value - The value to write.out - The output stream to write to.
IOException - If an error occurs writing to the stream.
public static void writeLongInt(long value,
OutputStream out)
throws IOException
long
to contain one in Java.
value - The value to write.out - The output stream to write to.
IOException - If an error occurs writing to the stream.
public static void writeLong(long value,
OutputStream out)
throws IOException
value - The value to write.out - The output stream to write to.
IOException - If an error occurs writing to the stream.
public static void writeCString(String s,
OutputStream out)
throws IOException
s - The string to writeout - The output stream to write to
IOException - If an I/O error occursOutputStream
public static void writeString(String s,
int len,
OutputStream out)
throws IOException
s - The String to writelen - The number of bytes to write. If len is greater
than the number of characters in the string, an exception will be
thrown.out - The OutputStream to write to.
IOException - If an I/O error occurs
ArrayIndexOutOfBoundsException - If there are not enough characters
to satisfy the len parameter.
public static void writeString(String s,
OutputStream out)
throws IOException
s - The String to writeout - The OutputStream to write to
IOException - If an I/O error occursOutputStream
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||