|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectpeakml.util.ByteArray
public class ByteArray
Utility functions for converting arrays of basic types into an array of bytes and vica-versa, which is especially useful for storing large amounts of data into a binary file. This provides a central point for platform independent storage of data. The endiannes can be set for each conversion in order to support platform independent conversion. Additionally, each conversion function accepts a precision value, indicating the amount of bits to use for storage (ie either 32 or 64).
Field Summary | |
---|---|
static int |
ENDIAN_BIG
The data is stored in big endian mode. |
static int |
ENDIAN_LITTLE
The data is stored in little endian mode. |
Constructor Summary | |
---|---|
ByteArray()
|
Method Summary | |
---|---|
static byte[] |
toByteArray(double[] array,
int endiannes,
int precision)
Converts the given double array into a byte-array. |
static byte[] |
toByteArray(int[] array,
int endiannes,
int precision)
Converts the given integer array into a byte-array. |
static byte[] |
toByteArray(long[] array,
int endiannes,
int precision)
Converts the given long array into a byte-array. |
static double[] |
toDoubleArray(byte[] array,
int endiannes,
int precision)
Converts a byte array containing double-values into a double array. |
static int[] |
toIntArray(byte[] array,
int endiannes,
int precision)
Converts a byte array containing integer-values into a long array. |
static long[] |
toLongArray(byte[] array,
int endiannes,
int precision)
Converts a byte array containing long-values into a long array. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int ENDIAN_BIG
public static final int ENDIAN_LITTLE
Constructor Detail |
---|
public ByteArray()
Method Detail |
---|
public static byte[] toByteArray(int[] array, int endiannes, int precision)
ENDIAN_BIG
or
ENDIAN_LITTLE
) indicates the byte-order the data should be
stored in. The precision indicates the number of bits for each element
in the integer array.
For the precision only 32 is supported, as 64 does not make sense on
the Java platform.
array
- The array with the integer-values.endiannes
- The byte-order in which the data has been stored (either ENDIAN_BIG
or ENDIAN_LITTLE
).precision
- The number of bits for each element in the array.
public static byte[] toByteArray(long[] array, int endiannes, int precision)
ENDIAN_BIG
or
ENDIAN_LITTLE
) indicates the byte-order the data should be
stored in. The precision indicates the number of bits for each element
in the long array.
array
- The array with the long-values.endiannes
- The byte-order in which the data has been stored (either ENDIAN_BIG
or ENDIAN_LITTLE
).precision
- The number of bits for each element in the array.
public static byte[] toByteArray(double[] array, int endiannes, int precision)
ENDIAN_BIG
or
ENDIAN_LITTLE
) indicates the byte-order the data should be
stored in. The precision indicates the number of bits for each element
in the integer array.
array
- The array with the double-values.endiannes
- The byte-order in which the data has been stored (either ENDIAN_BIG
or ENDIAN_LITTLE
).precision
- The number of bits for each element in the array.
public static int[] toIntArray(byte[] array, int endiannes, int precision)
ENDIAN_BIG
or
ENDIAN_LITTLE
) indicates the byte-order the data has been
stored in. The precision indicates the number of bits for each element
in the integer array.
For the precision only 32 is supported, as 64 does not make sense on
the Java platform.
array
- The byte-array to be converted.endiannes
- The byte-order in which the data has been stored (either ENDIAN_BIG
or ENDIAN_LITTLE
).precision
- The number of bits for each element in the long-array.
public static long[] toLongArray(byte[] array, int endiannes, int precision)
ENDIAN_BIG
or
ENDIAN_LITTLE
) indicates the byte-order the data has been
stored in. The precision indicates the number of bits for each element
in the long array.
array
- The byte-array to be converted.endiannes
- The byte-order in which the data has been stored (either ENDIAN_BIG
or ENDIAN_LITTLE
).precision
- The number of bits for each element in the long-array.
public static double[] toDoubleArray(byte[] array, int endiannes, int precision)
ENDIAN_BIG
or
ENDIAN_LITTLE
) indicates the byte-order the data has been
stored in. The precision indicates the number of bits for each element
in the double array.
array
- The byte-array to be converted.endiannes
- The byte-order in which the data has been stored (either ENDIAN_BIG
or ENDIAN_LITTLE
).precision
- The number of bits for each element in the double-array.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |