|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.partnersoft.io.BitLib
public class BitLib
A general library for bit-flipping, endianness conversion, and other routine 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.
| Constructor Summary | |
|---|---|
BitLib()
|
|
| 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 int[] |
blobToInts(byte[] blob)
|
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 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[] |
intsToBlob(int[] ints)
|
static void |
intToBytes(int value,
byte[] bytes,
int start)
Converts an int into a 4-byte array. |
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 void |
longToBytes(long value,
byte[] bytes,
int start)
Converts a lont into an 8-byte array. |
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 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 |
| Constructor Detail |
|---|
public BitLib()
| 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[] intsToBlob(int[] ints)
public static int[] blobToInts(byte[] blob)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||