public final class DataPacker
extends java.lang.Object
| Constructor and Description |
|---|
DataPacker() |
| Modifier and Type | Method and Description |
|---|---|
static int |
getBufferPosition(int pos,
java.lang.String str,
boolean uni,
boolean nul)
Calculate the new buffer position after the specified string and encoding (ASCII or Unicode)
|
static java.lang.String |
getDataString(char typ,
byte[] bytarray,
int pos,
int maxlen,
boolean uni)
Unpack a null terminated data string from the data buffer.
|
static int |
getInt(byte[] buf,
int pos)
Unpack a 32-bit integer.
|
static int |
getIntelInt(byte[] bytarray,
int pos)
Unpack a 32-bit integer that is stored in Intel format.
|
static long |
getIntelLong(byte[] bytarray,
int pos)
Unpack a 64-bit integer that is stored in Intel format.
|
static int |
getIntelShort(byte[] bytarray,
int pos)
Unpack a 16-bit value that is stored in Intel format.
|
static long |
getLong(byte[] buf,
int pos)
Unpack a 64-bit long.
|
static int |
getShort(byte[] bytarray,
int pos)
Unpack a 16-bit value.
|
static java.lang.String |
getString(byte[] bytarray,
int pos,
int maxlen)
Unpack a null terminated string from the data buffer.
|
static java.lang.String |
getString(byte[] bytarray,
int pos,
int maxlen,
boolean isUni)
Unpack a null terminated string from the data buffer.
|
static int |
getStringLength(java.lang.String str,
boolean uni,
boolean nul)
Calculate the string length in bytes
|
static java.lang.String |
getUnicodeString(byte[] byt,
int pos,
int maxlen)
Unpack a null terminated Unicode string from the data buffer.
|
static boolean |
isBigEndian()
Return the current endian setting.
|
static int |
longwordAlign(int pos)
Align a buffer offset on a longword boundary
|
static void |
putInt(int val,
byte[] bytarray,
int pos)
Pack a 32-bit integer into the supplied byte buffer.
|
static void |
putIntelInt(int val,
byte[] bytarray,
int pos)
Pack an 32-bit integer value in Intel format.
|
static void |
putIntelLong(int val,
byte[] bytarray,
int pos)
Pack a 64-bit integer value in Intel format.
|
static void |
putIntelLong(long val,
byte[] bytarray,
int pos)
Pack a 64-bit integer value in Intel format.
|
static void |
putIntelShort(int val,
byte[] bytarray,
int pos)
Pack a 16 bit value in Intel byte order.
|
static void |
putLong(long val,
byte[] bytarray,
int pos)
Pack a 64-bit integer value into the buffer
|
static void |
putShort(int val,
byte[] bytarray,
int pos)
Pack a 16-bit value into the supplied byte buffer.
|
static int |
putString(java.lang.String str,
byte[] bytarray,
int pos,
boolean nullterm)
Pack a string into a data buffer
|
static int |
putString(java.lang.String str,
byte[] bytarray,
int pos,
boolean nullterm,
boolean isUni)
Pack a string into a data buffer.
|
static int |
putString(java.lang.String str,
int fldLen,
byte[] bytarray,
int pos)
Pack a string into a data buffer
|
static int |
putUnicodeString(java.lang.String str,
byte[] bytarray,
int pos,
boolean nullterm)
Pack a Unicode string into a data buffer
|
static void |
putZeros(byte[] buf,
int pos,
int cnt)
Pack nulls into the buffer.
|
static int |
wordAlign(int pos)
Align a buffer offset on a word boundary
|
public static final boolean isBigEndian()
public static final java.lang.String getDataString(char typ,
byte[] bytarray,
int pos,
int maxlen,
boolean uni)
typ - Data type, as specified by SMBDataType.bytarray - Byte array to unpack the string value from.pos - Offset to start unpacking the string value.maxlen - Maximum length of data to be searched for a null character.uni - String is Unicode if true, else ASCIIpublic static final int getInt(byte[] buf,
int pos)
throws java.lang.IndexOutOfBoundsException
buf - Byte buffer containing the integer to be unpacked.pos - Position within the buffer that the integer is stored.java.lang.IndexOutOfBoundsException - If there is not enough data in the buffer.public static final int getIntelInt(byte[] bytarray,
int pos)
throws java.lang.IndexOutOfBoundsException
bytarray - Byte array containing the Intel integer to be unpacked.pos - Offset that the Intel integer is stored within the byte array.java.lang.IndexOutOfBoundsException - If there is not enough data in the buffer.public static final long getLong(byte[] buf,
int pos)
throws java.lang.IndexOutOfBoundsException
buf - Byte buffer containing the integer to be unpacked.pos - Position within the buffer that the integer is stored.java.lang.IndexOutOfBoundsException - If there is not enough data in the buffer.public static final long getIntelLong(byte[] bytarray,
int pos)
throws java.lang.IndexOutOfBoundsException
bytarray - Byte array containing the Intel long to be unpacked.pos - Offset that the Intel integer is stored within the byte array.java.lang.IndexOutOfBoundsException - If there is not enough data in the buffer.public static final int getIntelShort(byte[] bytarray,
int pos)
throws java.lang.IndexOutOfBoundsException
bytarray - Byte array containing the short value to be unpacked.pos - Offset to start unpacking the short value.java.lang.IndexOutOfBoiundsException - If there is not enough data in the buffer.java.lang.IndexOutOfBoundsExceptionpublic static final int getShort(byte[] bytarray,
int pos)
throws java.lang.IndexOutOfBoundsException
bytarray - Byte array containing the short to be unpacked.pos - Offset within the byte array that the short is stored.java.lang.IndexOutOfBoundsException - If there is not enough data in the buffer.public static final java.lang.String getString(byte[] bytarray,
int pos,
int maxlen)
bytarray - Byte array to unpack the string value from.pos - Offset to start unpacking the string value.maxlen - Maximum length of data to be searched for a null character.public static final java.lang.String getString(byte[] bytarray,
int pos,
int maxlen,
boolean isUni)
bytarray - Byte array to unpack the string value from.pos - Offset to start unpacking the string value.maxlen - Maximum length of data to be searched for a null character.isUni - Unicode string if true, else ASCII stringpublic static final java.lang.String getUnicodeString(byte[] byt,
int pos,
int maxlen)
byt - Byte array to unpack the string value from.pos - Offset to start unpacking the string value.maxlen - Maximum length of data to be searched for a null character.public static final void putInt(int val,
byte[] bytarray,
int pos)
throws java.lang.IndexOutOfBoundsException
val - Integer value to be packed.bytarray - Byte buffer to pack the integer value into.pos - Offset to start packing the integer value.java.lang.IndexOutOfBoundsException - If the buffer does not have enough space.public static final void putIntelInt(int val,
byte[] bytarray,
int pos)
throws java.lang.IndexOutOfBoundsException
val - Integer value to be packed.bytarray - Byte array to pack the value into.pos - Offset to start packing the integer value.java.lang.IndexOutOfBoundsException - If there is not enough data in the buffer.public static final void putLong(long val,
byte[] bytarray,
int pos)
throws java.lang.IndexOutOfBoundsException
val - Integer value to be packed.bytarray - Byte array to pack the value into.pos - Offset to start packing the integer value.java.lang.IndexOutOfBoundsException - If there is not enough data in the buffer.public static final void putIntelLong(long val,
byte[] bytarray,
int pos)
throws java.lang.IndexOutOfBoundsException
val - Integer value to be packed.bytarray - Byte array to pack the value into.pos - Offset to start packing the integer value.java.lang.IndexOutOfBoundsException - If there is not enough data in the buffer.public static final void putIntelLong(int val,
byte[] bytarray,
int pos)
throws java.lang.IndexOutOfBoundsException
val - Integer value to be packed.bytarray - Byte array to pack the value into.pos - Offset to start packing the integer value.java.lang.IndexOutOfBoundsException - If there is not enough data in the buffer.public static final void putIntelShort(int val,
byte[] bytarray,
int pos)
throws java.lang.IndexOutOfBoundsException
val - Short value to be packed.bytarray - Byte array to pack the short value into.pos - Offset to start packing the short value.java.lang.IndexOutOfBoundsException - If there is not enough data in the buffer.public static final void putShort(int val,
byte[] bytarray,
int pos)
throws java.lang.IndexOutOfBoundsException
val - Short value to be packed.bytarray - Byte array to pack the short value into.pos - Offset to start packing the short value.java.lang.IndexOutOfBoundsException - If there is not enough data in the buffer.public static final int putString(java.lang.String str,
byte[] bytarray,
int pos,
boolean nullterm)
str - String to be packed into the bufferbytarray - Byte array to pack the string intopos - Position to start packing the stringnullterm - true if the string should be null terminated, else falsepublic static final int putString(java.lang.String str,
int fldLen,
byte[] bytarray,
int pos)
str - String to be packed into the bufferfldLen - Field length, will be space padded if shortbytarray - Byte array to pack the string intopos - Position to start packing the stringpublic static final int putString(java.lang.String str,
byte[] bytarray,
int pos,
boolean nullterm,
boolean isUni)
str - String to be packed into the bufferbytarray - Byte array to pack the string intopos - Position to start packing the stringnullterm - true if the string should be null terminated, else falseisUni - true if the string should be packed as Unicode, false to pack as ASCIIpublic static final int putUnicodeString(java.lang.String str,
byte[] bytarray,
int pos,
boolean nullterm)
str - String to be packed into the bufferbytarray - Byte array to pack the string intopos - Position to start packing the stringnullterm - true if the string should be null terminated, else falsepublic static final void putZeros(byte[] buf,
int pos,
int cnt)
throws java.lang.ArrayIndexOutOfBoundsException
buf - Buffer to pack data into.pos - Position to start packing.cnt - Number of nulls to pack.java.lang.ArrayIndexOutOfBoundsException - If the buffer does not have enough space.public static final int wordAlign(int pos)
pos - intpublic static final int longwordAlign(int pos)
pos - intpublic static final int getStringLength(java.lang.String str,
boolean uni,
boolean nul)
str - Stringuni - booleannul - booleanpublic static final int getBufferPosition(int pos,
java.lang.String str,
boolean uni,
boolean nul)
pos - intstr - Stringuni - booleannul - booleanCopyright © 2005 - 2010 Alfresco Software, Inc. All Rights Reserved.