| java.lang.Object com.tc.util.Conversion
Conversion | public class Conversion (Code) | | Data conversion algorithms and whatnot can be found in java.io.DataInput and java.io.DataOutput. Contains methods for
converting from one kind of thing to another.
author: orion |
Method Summary | |
public static byte | boolean2Byte(boolean value) | public static byte[] | boolean2Bytes(boolean v) | public static String | buffer2String(int length, TCByteBuffer buffer) | public static boolean | byte2Boolean(byte b) | public static byte[] | byte2Bytes(byte v) | public static short | byte2uint(byte b) Helper method to convert a byte to an unsigned int. | public static boolean | bytes2Boolean(byte[] bytes) | public static char | bytes2Char(byte[] bytes) | public static double | bytes2Double(byte[] bytes) | public static float | bytes2Float(byte[] bytes) | public static int | bytes2Int(byte[] bytes, int offset) | public static int | bytes2Int(byte[] bytes) | public static long | bytes2Long(byte[] bytes) | public static long | bytes2Long(byte[] bytes, int offset) | public static short | bytes2Short(byte[] bytes) | public static String | bytes2String(byte[] bytes) Helper method to convert a string to bytes in a safe way. | public static long | bytes2uint(byte b) | public static long | bytes2uint(byte b, int length) | public static long | bytes2uint(byte b, int offset, int length) | public static String | bytesToHex(byte[] b) Equivalent to calling bytesToHex(b, 0, b.length) . | public static String | bytesToHex(byte[] b, int index, int length) Converts a single byte to a hex string representation, can be decoded with Byte.parseByte(). | public static byte[] | char2Bytes(char v) | public static byte[] | double2Bytes(double l) | public static byte[] | float2Bytes(float l) | public static boolean | getFlag(byte flags, int offset) | public static byte[] | hexToBytes(String hexString) | public static byte[] | int2Bytes(int v) | public static byte[] | long2Bytes(long l) | public static byte | setFlag(byte flags, int offset, boolean value) | public static byte[] | short2Bytes(short v) | public static byte[] | string2Bytes(String string) Helper method to convert a string to bytes in a safe way. | public static byte[] | uint2bytes(long l) | public static byte[] | ushort2bytes(int i) | public static void | writeInt(int i, byte[] dest, int index) | public static void | writeLong(long l, byte[] rv, int offset) | public static void | writeUint(long l, byte[] dest, int index) |
MAX_UINT | final public static long MAX_UINT(Code) | | |
MIN_UINT | final public static long MIN_UINT(Code) | | |
boolean2Byte | public static byte boolean2Byte(boolean value)(Code) | | Parameters: value - |
boolean2Bytes | public static byte[] boolean2Bytes(boolean v)(Code) | | |
byte2Boolean | public static boolean byte2Boolean(byte b)(Code) | | |
byte2Bytes | public static byte[] byte2Bytes(byte v)(Code) | | |
byte2uint | public static short byte2uint(byte b)(Code) | | Helper method to convert a byte to an unsigned int. Use me when you want to treat a java byte as unsigned
|
bytes2Boolean | public static boolean bytes2Boolean(byte[] bytes)(Code) | | |
bytes2Char | public static char bytes2Char(byte[] bytes)(Code) | | |
bytes2Double | public static double bytes2Double(byte[] bytes)(Code) | | |
bytes2Float | public static float bytes2Float(byte[] bytes)(Code) | | |
bytes2Int | public static int bytes2Int(byte[] bytes, int offset)(Code) | | |
bytes2Int | public static int bytes2Int(byte[] bytes)(Code) | | |
bytes2Long | public static long bytes2Long(byte[] bytes)(Code) | | |
bytes2Long | public static long bytes2Long(byte[] bytes, int offset)(Code) | | |
bytes2Short | public static short bytes2Short(byte[] bytes)(Code) | | |
bytes2String | public static String bytes2String(byte[] bytes)(Code) | | Helper method to convert a string to bytes in a safe way.
|
bytes2uint | public static long bytes2uint(byte b)(Code) | | |
bytes2uint | public static long bytes2uint(byte b, int length)(Code) | | |
bytes2uint | public static long bytes2uint(byte b, int offset, int length)(Code) | | Helper method to convert 1-4 bytes (big-endiand) into an unsigned int (max: 2^32 -1)
|
bytesToHex | public static String bytesToHex(byte[] b)(Code) | | Equivalent to calling bytesToHex(b, 0, b.length) .
|
bytesToHex | public static String bytesToHex(byte[] b, int index, int length)(Code) | | Converts a single byte to a hex string representation, can be decoded with Byte.parseByte().
Parameters: b - the byte to encode a |
char2Bytes | public static byte[] char2Bytes(char v)(Code) | | |
double2Bytes | public static byte[] double2Bytes(double l)(Code) | | |
float2Bytes | public static byte[] float2Bytes(float l)(Code) | | |
getFlag | public static boolean getFlag(byte flags, int offset)(Code) | | |
hexToBytes | public static byte[] hexToBytes(String hexString)(Code) | | Parameters: hexString - an array of bytes, decoded from the hex-encoded string, if hexString is null or the length is not a multiple of two then null is returned. |
int2Bytes | public static byte[] int2Bytes(int v)(Code) | | |
long2Bytes | public static byte[] long2Bytes(long l)(Code) | | |
setFlag | public static byte setFlag(byte flags, int offset, boolean value)(Code) | | |
short2Bytes | public static byte[] short2Bytes(short v)(Code) | | |
string2Bytes | public static byte[] string2Bytes(String string)(Code) | | Helper method to convert a string to bytes in a safe way.
|
uint2bytes | public static byte[] uint2bytes(long l)(Code) | | Helper method to convert an unsigned integer to 4 bytes (big-endian)
|
ushort2bytes | public static byte[] ushort2bytes(int i)(Code) | | Helper method to convert an unsigned short to 2 bytes (big-endian)
|
writeInt | public static void writeInt(int i, byte[] dest, int index)(Code) | | Helper method to write a 4 byte java (signed) integer value into a given byte array at a given offset
Parameters: l - the signed int value to write Parameters: dest - the byte array to write the uint into Parameters: index - starting offset into the destination byte array |
writeLong | public static void writeLong(long l, byte[] rv, int offset)(Code) | | |
writeUint | public static void writeUint(long l, byte[] dest, int index)(Code) | | Helper method to write a 4 byte unsigned integer value into a given byte array at a given offset
Parameters: l - the unsigned int value to write Parameters: dest - the byte array to write the uint into Parameters: index - starting offset into the destination byte array |
|
|