|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.xinapse.io.ByteSwap
public abstract class ByteSwap
Abstract class to provide byte swapping facilities, allowing correct interpretation of multi-byte numbers on machines of different byte orders. The Java Virtual Machine is a big-endian Machine, and therefore byte order swapping is needed if the data to be read or written is in little-endian byte order.
| Method Summary | |
|---|---|
static double |
Double(byte[] eightBytes,
java.nio.ByteOrder byteOrder)
Swap the byte order (if necessary) in a eight-byte array and return the value represented by the bit pattern as a double. |
static double |
Double(double d)
Swap the byte order in a double and return the value represented by the bit pattern of the reversed bytes as a double. |
static float |
Float(byte[] fourBytes,
java.nio.ByteOrder byteOrder)
Swap the byte order (if necessary) in a four-byte array and return the value represented by the bit pattern as a float. |
static float |
Float(float f)
Swap the byte order in a float and return the value represented by the bit pattern of the reversed bytes as a float. |
static int |
Integer(byte[] fourBytes,
java.nio.ByteOrder byteOrder)
Swap the byte order (if necessary) in a four-byte array and return the value represented by the bit pattern as an int. |
static int[] |
Integer(byte[] bytes,
int nInt,
java.nio.ByteOrder byteOrder)
Swap the byte order (if necessary) in quartets of bytes in an array of bytes and return the values represented by the bit patterns as an array of ints. |
static int |
Integer(int i)
Swap the byte order in an an int and return the value represented by the bit pattern of the reversed bytes as an int. |
static long |
Long(byte[] eightBytes,
java.nio.ByteOrder byteOrder)
Swap the byte order (if necessary) in a eight-byte array and return the value represented by the bit pattern as a long. |
static long |
Long(long l)
Swap the byte order in a long and return the value represented by the bit pattern of the reversed bytes as a long. |
static short |
Short(byte[] twoBytes,
java.nio.ByteOrder byteOrder)
Swap the byte order (if necessary) in a two-byte array and return the value represented by the bit pattern as a short. |
static short[] |
Short(byte[] bytes,
int nShort,
java.nio.ByteOrder byteOrder)
Swap the byte order (if necessary) in pairs of bytes in an array of bytes and return the values represented by the bit patterns as an array of shorts. |
static short |
Short(short s)
Swap the byte order in an a short and return the value represented by the bit pattern of the reversed bytes as a short. |
static void |
Short(short[] sArray)
Swap the byte order in an an array of shorts in place. |
static void |
swapBytes(byte[] bArray,
java.nio.ByteOrder byteOrder)
Swap the byte order in a byte array. |
static void |
swapBytes(byte[] bArray,
int off,
int nBytes,
java.nio.ByteOrder byteOrder)
Swap the byte order in a byte array. |
static long |
UInteger(byte[] fourBytes,
java.nio.ByteOrder byteOrder)
Swap the byte order (if necessary) in a four-byte array and return the value represented by the bit pattern (interpreted as an unsigned int) as a long. |
static int |
UShort(byte[] twoBytes,
java.nio.ByteOrder byteOrder)
Swap the byte order (if necessary) in a two-byte array and return the value represented by the bit pattern (interpreted as an unsigned short) as an int. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static short Short(short s)
s - an short whose byte order is to be reversed.
public static void Short(short[] sArray)
sArray - an array of shorts whose byte order is to be reversed.
public static short Short(byte[] twoBytes,
java.nio.ByteOrder byteOrder)
twoBytes - an array of length two, holding the bit pattern for the short value.byteOrder - the byte order of the data source from which the bytes of data were read.
If byteOrder is ByteOrder.LITTLE_ENDIAN, then byte reordering takes place; if byteOrder
is ByteOrder.BIG_ENDIAN, then no byte reordering takes place.
public static short[] Short(byte[] bytes,
int nShort,
java.nio.ByteOrder byteOrder)
bytes - an even-length array of bytes, holding the bit patterns for the short values.nShort - the number of short values to be converted.byteOrder - the byte order of the data source from which the bytes of data were read.
If byteOrder is ByteOrder.LITTLE_ENDIAN, then byte reordering takes place; if byteOrder
is ByteOrder.BIG_ENDIAN, then no byte reordering takes place.
public static int UShort(byte[] twoBytes,
java.nio.ByteOrder byteOrder)
twoBytes - an array of length two, holding the bit pattern for the unsigned short value.byteOrder - the byte order of the data source from which the bytes of data were read.
If byteOrder is ByteOrder.LITTLE_ENDIAN, then byte reordering takes place; if byteOrder
is ByteOrder.BIG_ENDIAN, then no byte reordering takes place.
public static int Integer(int i)
i - an int whose byte order is to be reversed.
public static int Integer(byte[] fourBytes,
java.nio.ByteOrder byteOrder)
fourBytes - an array of length four, holding the bit pattern for the signed integer
value.byteOrder - the byte order of the data source from which the bytes of data were read.
If byteOrder is ByteOrder.LITTLE_ENDIAN, then byte reordering takes place; if byteOrder
is ByteOrder.BIG_ENDIAN, then no byte reordering takes place.
public static int[] Integer(byte[] bytes,
int nInt,
java.nio.ByteOrder byteOrder)
bytes - an array of bytes, holding the bit patterns for the int values.nInt - the number of int values to be converted.byteOrder - the byte order of the data source from which the bytes of data were read.
If byteOrder is ByteOrder.LITTLE_ENDIAN, then byte reordering takes place; if byteOrder
is ByteOrder.BIG_ENDIAN, then no byte reordering takes place.
public static long UInteger(byte[] fourBytes,
java.nio.ByteOrder byteOrder)
fourBytes - an array of length four, holding the bit pattern for the unsigned integer
value.byteOrder - the byte order of the data source from which the bytes of data were read.
If byteOrder is ByteOrder.LITTLE_ENDIAN, then byte reordering takes place; if byteOrder
is ByteOrder.BIG_ENDIAN, then no byte reordering takes place.
public static long Long(long l)
l - a long whose byte order is to be reversed.
public static long Long(byte[] eightBytes,
java.nio.ByteOrder byteOrder)
eightBytes - an array of length eight, holding the bit pattern for the signed long
value.byteOrder - the byte order of the data source from which the bytes of data were read.
If byteOrder is ByteOrder.LITTLE_ENDIAN, then byte reordering takes place; if byteOrder
is ByteOrder.BIG_ENDIAN, then no byte reordering takes place.
public static float Float(float f)
f - a float whose byte order is to be reversed.
public static float Float(byte[] fourBytes,
java.nio.ByteOrder byteOrder)
fourBytes - an array of length four, holding the bit pattern for the float value.byteOrder - the byte order of the data source from which the bytes of data were read.
If byteOrder is ByteOrder.LITTLE_ENDIAN, then byte reordering takes place; if byteOrder
is ByteOrder.BIG_ENDIAN, then no byte reordering takes place.
public static double Double(byte[] eightBytes,
java.nio.ByteOrder byteOrder)
eightBytes - an array of length eight, holding the bit pattern for the double value.byteOrder - the byte order of the data source from which the bytes of data were read.
If byteOrder is ByteOrder.LITTLE_ENDIAN, then byte reordering takes place; if byteOrder
is ByteOrder.BIG_ENDIAN, then no byte reordering takes place.
public static double Double(double d)
d - a double whose byte order is to be reversed.
public static void swapBytes(byte[] bArray,
java.nio.ByteOrder byteOrder)
bArray - the byte[] for which to swap the order of bytes.byteOrder - if ByteOrder.LITTLE_ENDIAN, then byte reordering takes place; if
ByteOrder.BIG_ENDIAN, then no byte reordering takes place.
public static void swapBytes(byte[] bArray,
int off,
int nBytes,
java.nio.ByteOrder byteOrder)
bArray - the byte[] for which to swap the order of bytes.off - an offset into the array at which byte swapping starts.nBytes - the number of bytes to swap.byteOrder - if ByteOrder.LITTLE_ENDIAN, then byte reordering takes place; if
ByteOrder.BIG_ENDIAN, then no byte reordering takes place.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||