|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.magnos.data.Bits
public class Bits
A utility for converting between primitive data types and an array of bytes.
Constructor Summary | |
---|---|
Bits()
|
Method Summary | |
---|---|
static void |
free(java.nio.ByteBuffer buffer)
Explicitly frees the given buffer from memory if it is a DirectBuffer. |
static boolean |
getBoolean(byte b)
Given an array of bytes, the first 4 bytes of the array are used to compute a floating-point value. |
static byte |
getBooleanBytes(boolean x)
Given a boolean this will convert it to its byte value. |
static char |
getChar(byte[] b)
Given an array of bytes, the first 2 bytes of the array are used to compute a char value. |
static byte[] |
getCharBytes(char x)
Given a char an array of bytes will be returned representing the char. |
static void |
getCharBytes(char x,
byte[] b)
Given a char and an array of bytes, the first 2 bytes of the array are set to the bytes that make up the char. |
static double |
getDouble(byte[] b)
Given an array of bytes, the first 8 bytes of the array are used to compute a double value. |
static byte[] |
getDoubleBytes(double x)
Given a double an array of bytes will be returned representing the double. |
static void |
getDoubleBytes(double x,
byte[] b)
Given a double and an array of bytes, the first 8 bytes of the array are set to the bytes that make up the double. |
static float |
getFloat(byte[] b)
Given an array of bytes, the first 4 bytes of the array are used to compute a floating-point value. |
static byte[] |
getFloatBytes(float x)
Given a float an array of bytes will be returned representing the float. |
static void |
getFloatBytes(float x,
byte[] b)
Given a float and an array of bytes, the first 4 bytes of the array are set to the bytes that make up the float. |
static int |
getInt(byte[] b)
Given an array of bytes, the first 4 bytes of the array are used to compute an integer value. |
static byte[] |
getIntBytes(int x)
Given an integer an array of bytes will be returned representing the integer. |
static void |
getIntBytes(int x,
byte[] b)
Given an integer and an array of bytes, the first 4 bytes of the array are set to the bytes that make up the integer. |
static long |
getLong(byte[] b)
Given an array of bytes, the first 8 bytes of the array are used to compute a long value. |
static byte[] |
getLongBytes(long x)
Given a long an array of bytes will be returned representing the long. |
static void |
getLongBytes(long x,
byte[] b)
Given a long and an array of bytes, the first 8 bytes of the array are set to the bytes that make up the long. |
static short |
getShort(byte[] b)
Given an array of bytes, the first 2 bytes of the array are used to compute a short value. |
static byte[] |
getShortBytes(short x)
Given a short an array of bytes will be returned representing the short. |
static void |
getShortBytes(short x,
byte[] b)
Given a short and an array of bytes, the first 2 bytes of the array are set to the bytes that make up the short. |
static short |
getUByte(byte[] b)
Given an array of bytes, the first byte of the array are used to compute a short value. |
static byte[] |
getUByteBytes(short x)
Given a short an array of bytes will be returned representing the short. |
static void |
getUByteBytes(short x,
byte[] b)
Given a short and an array of bytes, the first byetshort of the array are set to the bytes that make up the short. |
static long |
getUInt(byte[] b)
Given an array of bytes, the first 4 bytes of the array are used to compute an integer value. |
static byte[] |
getUIntBytes(long x)
Given an integer an array of bytes will be returned representing the integer. |
static void |
getUIntBytes(long x,
byte[] b)
Given an integer and an array of bytes, the first 4 bytes of the array are set to the bytes that make up the integer. |
static int |
getUShort(byte[] b)
Given an array of bytes, the first 2 bytes of the array are used to compute a short value. |
static byte[] |
getUShortBytes(int x)
Given a short an array of bytes will be returned representing the short. |
static void |
getUShortBytes(int x,
byte[] b)
Given a short and an array of bytes, the first 2 bytes of the array are set to the bytes that make up the short. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Bits()
Method Detail |
---|
public static boolean getBoolean(byte b)
b
- The array of bytes.
public static byte getBooleanBytes(boolean x)
x
- The boolean to convert.
public static short getUByte(byte[] b)
b
- The array of bytes.
public static void getUByteBytes(short x, byte[] b)
x
- The short to place in the byte array.b
- The byte array to place the bytes.public static byte[] getUByteBytes(short x)
x
- The short to return as a byte array.
public static char getChar(byte[] b)
b
- The array of bytes.
public static void getCharBytes(char x, byte[] b)
x
- The char to place in the byte array.b
- The byte array to place the bytes.public static byte[] getCharBytes(char x)
x
- The char to return as a byte array.
public static short getShort(byte[] b)
b
- The array of bytes.
public static void getShortBytes(short x, byte[] b)
x
- The short to place in the byte array.b
- The byte array to place the bytes.public static byte[] getShortBytes(short x)
x
- The short to return as a byte array.
public static int getUShort(byte[] b)
b
- The array of bytes.
public static void getUShortBytes(int x, byte[] b)
x
- The short to place in the byte array.b
- The byte array to place the bytes.public static byte[] getUShortBytes(int x)
x
- The short to return as a byte array.
public static int getInt(byte[] b)
b
- The array of bytes.
public static void getIntBytes(int x, byte[] b)
x
- The integer to place in the byte array.b
- The byte array to place the bytes.public static byte[] getIntBytes(int x)
x
- The integer to return as a byte array.
public static long getUInt(byte[] b)
b
- The array of bytes.
public static void getUIntBytes(long x, byte[] b)
x
- The integer to place in the byte array.b
- The byte array to place the bytes.public static byte[] getUIntBytes(long x)
x
- The integer to return as a byte array.
public static long getLong(byte[] b)
b
- The array of bytes.
public static void getLongBytes(long x, byte[] b)
x
- The long to place in the byte array.b
- The byte array to place the bytes.public static byte[] getLongBytes(long x)
x
- The long to return as a byte array.
public static float getFloat(byte[] b)
b
- The array of bytes.
public static void getFloatBytes(float x, byte[] b)
x
- The float to place in the byte array.b
- The byte array to place the bytes.public static byte[] getFloatBytes(float x)
x
- The float to return as a byte array.
public static double getDouble(byte[] b)
b
- The array of bytes.
public static void getDoubleBytes(double x, byte[] b)
x
- The double to place in the byte array.b
- The byte array to place the bytes.public static byte[] getDoubleBytes(double x)
x
- The double to return as a byte array.
public static void free(java.nio.ByteBuffer buffer)
buffer
- The buffer to forcably free from memory if possible.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |