public class BitConverter
extends java.lang.Object
A set of methods for converting various java primitive types to bytes.
NOTE: these methods convert values using "little-endian" semantics rather than normal java "big-endian" semantics. The intent was to allow values converted this way to interoperate with values created by a .net client.Modifier and Type | Method and Description |
---|---|
static byte[] |
getBytes(boolean value) |
static byte[] |
getBytes(java.util.Date value) |
static byte[] |
getBytes(double value) |
static byte[] |
getBytes(int value) |
static byte[] |
getBytes(long value) |
static byte[] |
getBytes(java.lang.String s) |
static byte[] |
getBytes(java.util.UUID value) |
static byte[] |
getBytesChar(int value) |
static byte[] |
getBytesUnicode(java.lang.String s) |
static int |
getInt(byte[] array,
int offset) |
static int |
getInt(java.nio.ByteBuffer buf,
int offset) |
static long |
getLong(byte[] array,
int offset) |
static short |
getShort(byte[] array,
int offset) |
static java.lang.String |
getStringFromAscii(byte[] array) |
static java.lang.String |
getStringFromUnicode(byte[] array) |
static int |
Hash_hash(int v1,
int v2) |
static int |
hashAppName(java.lang.String appName)
Use the same hash function used in sosslib to calculate the appId
to avoid precluding interoperation.
|
static byte[] |
hashString(java.lang.String s)
Provides a 128-bit hash value for an arbitrary length string.
|
static int[] |
hashStringInt(java.lang.String s)
Provides a 128-bit hash value for an arbitrary length string.
|
static int |
hashStringOneInt(java.lang.String s)
Provides a 32-bit hash value for an arbitrary length string.
|
static void |
putInt(byte[] array,
int offset,
int value) |
static void |
putInt(java.nio.ByteBuffer buffer,
int value) |
static void |
putShort(byte[] array,
int offset,
short value) |
public static byte[] getBytes(java.lang.String s)
public static byte[] getBytesUnicode(java.lang.String s)
public static byte[] getBytes(boolean value)
public static byte[] getBytes(java.util.Date value)
public static byte[] getBytes(int value)
public static byte[] getBytesChar(int value)
public static byte[] getBytes(long value)
public static byte[] getBytes(double value)
public static byte[] getBytes(java.util.UUID value)
public static int getInt(java.nio.ByteBuffer buf, int offset)
public static int getInt(byte[] array, int offset)
public static long getLong(byte[] array, int offset)
public static void putInt(byte[] array, int offset, int value)
public static void putInt(java.nio.ByteBuffer buffer, int value)
public static short getShort(byte[] array, int offset)
public static void putShort(byte[] array, int offset, short value)
public static int Hash_hash(int v1, int v2)
public static java.lang.String getStringFromUnicode(byte[] array)
public static java.lang.String getStringFromAscii(byte[] array)
public static byte[] hashString(java.lang.String s)
s
- key stringnull
if failedpublic static int[] hashStringInt(java.lang.String s)
s
- key stringnull
if failedpublic static int hashStringOneInt(java.lang.String s)
s
- key stringnull
if failedpublic static int hashAppName(java.lang.String appName)
appName
- the string appName