|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.partnersoft.data.ByteLib
public class ByteLib
A function library for bit-flipping, endianness conversion, and other routine low-level annoyances.
In general, numbers in weird formats are are supplied as their integer counterparts - for example, the double conversion routines use longs to represent little endian doubles.
Copyright 1999-2006 Partner Software, Inc.
| Method Summary | |
|---|---|
static long |
bigToLittleEndianDouble(double bigInjun)
Converts a big-endian java double into a little-endian double. |
static int |
bigToLittleEndianFloat(float bigInjun)
Converts a big-endian java float into a little-endian float. |
static java.lang.String |
byteCountToString(double bytes)
Converts bytecount to a more human-readable String. |
static double |
bytesToDouble(byte[] bytes)
Converts an 8-byte array into a double. |
static double |
bytesToDouble(byte[] bytes,
int start)
Converts an 8-byte array section into a double. |
static float |
bytesToFloat(byte[] bytes)
Converts a 4-byte array into a float. |
static float |
bytesToFloat(byte[] bytes,
int start)
Converts a 4-byte array section into a float. |
static java.lang.String |
bytesToHexString(byte[] buffer)
|
static java.lang.String |
bytesToHexString(byte[] buffer,
int start)
|
static java.lang.String |
bytesToHexString(byte[] buffer,
int start,
int length)
|
static int |
bytesToInt(byte[] bytes)
Converts a 4-byte array into an int. |
static int |
bytesToInt(byte[] bytes,
int start)
Converts a 4-byte array section into an int. |
static int[] |
bytesToInts(byte[] bytes)
Converts a byte array to a big-endian int array. |
static long |
bytesToLong(byte[] bytes)
Converts an 8-byte array into a long. |
static long |
bytesToLong(byte[] bytes,
int start)
Converts an 8-byte array section into a long. |
static java.lang.String |
bytesToString(byte[] buffer,
int start,
int width)
|
static int |
bytesToUnsignedShort(byte[] bytes,
int start)
Converts a 2-byte array section into a positive int. |
static int |
findSequence(byte[] bytes,
byte[] sequence,
int startIndex)
Search for given byte array sequence in the given byte array, starting at the given index. |
static byte[] |
hexStringToBytes(java.lang.String hex)
|
static byte[] |
intsToBytes(int[] ints)
Converts a big-endian int array to a byte array (with the same byte sequence). |
static java.lang.String |
intToBinary(int aint)
Converts a primitive, big-endian int to its binary representation. |
static void |
intToBytes(int value,
byte[] bytes,
int start)
Converts an int into a 4-byte array. |
static java.lang.String |
intToHex(int aint)
Converts a primitive, big-endian int to its hexadecimal representation. |
static double |
littleToBigEndianDouble(long littleInjun)
Converts a little-indian double into a big-endian java double. |
static float |
littleToBigEndianFloat(int littleInjun)
Converts a little-indian float into a big-endian java float. |
static java.lang.String |
longToBinary(long along)
Converts a primitive, big-endian long to its binary representation. |
static void |
longToBytes(long value,
byte[] bytes,
int start)
Converts a lont into an 8-byte array. |
static java.lang.String |
longToHex(long along)
Converts a primitive, big-endian long to its hexadecimal representation. |
static int |
reverseByteOrder(int victim)
Converts a little-endian int to a big endian int and vice-versa. |
static long |
reverseByteOrder(long victim)
Converts a little-endian long to a big endian long and vice-versa. |
static short |
reverseByteOrder(short victim)
Converts a little-endian short to a big endian short and vice-versa. |
static long |
reverseByteOrderByWord(long victim)
Converts a little-endian long to a big endian long, respecting word order, and vice-versa. |
static double |
reverseBytesToDouble(byte[] bytes)
Converts an 8-byte array into a double reversing as it goes (little-endian). |
static double |
reverseBytesToDouble(byte[] bytes,
int start)
Converts an 8-byte array section into a double reversing as it goes (little-endian). |
static float |
reverseBytesToFloat(byte[] bytes,
int start)
Converts a 4-byte array section into a float reversing as it goes (little-endian). |
static int |
reverseBytesToInt(byte[] bytes)
Converts a 4-byte array into an int reversing as it goes (little-endian). |
static int |
reverseBytesToInt(byte[] bytes,
int start)
Converts a 4-byte array section into an int reversing as it goes (little-endian). |
static long |
reverseBytesToLong(byte[] bytes)
Converts an 8-byte array into a long reversing as it goes (little-endian). |
static long |
reverseBytesToLong(byte[] bytes,
int start)
Converts an 8-byte array section into a long reversing as it goes (little-endian). |
static int |
reverseBytesToUnsignedShort(byte[] bytes,
int start)
Converts a 2-byte array section into an reversed short. |
static java.lang.String |
shortToBinary(short ashort)
Converts a primitive, big-endian short to its binary representation. |
static java.lang.String |
shortToHex(short ashort)
Converts a primitive, big-endian short to its hexadecimal representation. |
static void |
stringToBytes(java.lang.String value,
byte[] bytes,
int start)
Converts a string into a null-terminated ASCII array section. |
static void |
unsignedShortToBytes(int value,
byte[] bytes,
int start)
Converts an int into a 2-byte array. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static int reverseByteOrder(int victim)
public static short reverseByteOrder(short victim)
public static long reverseByteOrder(long victim)
public static long reverseByteOrderByWord(long victim)
public static double littleToBigEndianDouble(long littleInjun)
public static long bigToLittleEndianDouble(double bigInjun)
public static float littleToBigEndianFloat(int littleInjun)
public static int bigToLittleEndianFloat(float bigInjun)
public static long bytesToLong(byte[] bytes)
public static long bytesToLong(byte[] bytes,
int start)
public static long reverseBytesToLong(byte[] bytes)
public static long reverseBytesToLong(byte[] bytes,
int start)
public static int bytesToInt(byte[] bytes)
public static int bytesToInt(byte[] bytes,
int start)
public static int reverseBytesToUnsignedShort(byte[] bytes,
int start)
public static int bytesToUnsignedShort(byte[] bytes,
int start)
public static int reverseBytesToInt(byte[] bytes)
public static int reverseBytesToInt(byte[] bytes,
int start)
public static double bytesToDouble(byte[] bytes)
public static double bytesToDouble(byte[] bytes,
int start)
public static float bytesToFloat(byte[] bytes)
public static float bytesToFloat(byte[] bytes,
int start)
public static double reverseBytesToDouble(byte[] bytes)
public static double reverseBytesToDouble(byte[] bytes,
int start)
public static float reverseBytesToFloat(byte[] bytes,
int start)
public static java.lang.String bytesToString(byte[] buffer,
int start,
int width)
public static byte[] hexStringToBytes(java.lang.String hex)
public static java.lang.String bytesToHexString(byte[] buffer)
public static java.lang.String bytesToHexString(byte[] buffer,
int start)
public static java.lang.String bytesToHexString(byte[] buffer,
int start,
int length)
public static void intToBytes(int value,
byte[] bytes,
int start)
public static void longToBytes(long value,
byte[] bytes,
int start)
public static void unsignedShortToBytes(int value,
byte[] bytes,
int start)
public static void stringToBytes(java.lang.String value,
byte[] bytes,
int start)
public static int findSequence(byte[] bytes,
byte[] sequence,
int startIndex)
public static byte[] intsToBytes(int[] ints)
ints - array of input integers
public static int[] bytesToInts(byte[] bytes)
bytes - input byte array
public static java.lang.String byteCountToString(double bytes)
public static java.lang.String longToHex(long along)
along - big-endian long
public static java.lang.String intToHex(int aint)
aint - big-endian int
public static java.lang.String shortToHex(short ashort)
ashort - big-endian short
public static java.lang.String longToBinary(long along)
along - big-endian long
public static java.lang.String intToBinary(int aint)
aint - big-endian int
public static java.lang.String shortToBinary(short ashort)
ashort - big-endian short
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||