|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectucar.unidata.io.Swap
public class Swap
The Swap class provides static methods for swapping the bytes of chars, shorts, ints, longs, floats, and doubles.
Constructor Summary | |
---|---|
Swap()
|
Method Summary | |
---|---|
static byte[] |
intToBytes(int v)
Convert an int to an array of 4 bytes. |
static byte[] |
longToBytes(long v)
Convert a long to an array of 8 bytes. |
static byte[] |
shortToBytes(short v)
Convert a short to an array of 2 bytes. |
static char |
swapChar(byte[] b,
int offset)
Returns the char resulting from swapping 2 bytes at a specified offset in a byte array. |
static double |
swapDouble(byte[] b,
int offset)
Returns the double resulting from reversing 8 bytes at a specified offset in a byte array. |
static double |
swapDouble(double v)
Returns the double resulting from reversing 8 bytes of a specified double. |
static float |
swapFloat(byte[] b,
int offset)
Returns the float resulting from reversing 4 bytes at a specified offset in a byte array. |
static float |
swapFloat(float v)
Returns the float resulting from reversing 4 bytes of a specified float. |
static int |
swapInt(byte[] b,
int offset)
Returns the int resulting from reversing 4 bytes at a specified offset in a byte array. |
static int |
swapInt(int v)
Returns the int resulting from reversing 4 bytes of a specified int. |
static long |
swapLong(byte[] b,
int offset)
Returns the long resulting from reversing 8 bytes at a specified offset in a byte array. |
static long |
swapLong(long l)
Returns the long resulting from reversing 8 bytes of a specified long. |
static short |
swapShort(byte[] b,
int offset)
Returns the short resulting from swapping 2 bytes at a specified offset in a byte array. |
static short |
swapShort(short s)
Returns the short resulting from swapping 2 bytes of a specified short. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Swap()
Method Detail |
---|
public static short swapShort(byte[] b, int offset)
b
- the byte arrayoffset
- the offset of the first byte
b[offset+1], b[offset]
public static int swapInt(byte[] b, int offset)
b
- the byte arrayoffset
- the offset of the first byte
b[offset+3], b[offset+2], ..., b[offset]
public static long swapLong(byte[] b, int offset)
b
- the byte arrayoffset
- the offset of the first byte
b[offset+7], b[offset+6], ..., b[offset]
public static float swapFloat(byte[] b, int offset)
b
- the byte arrayoffset
- the offset of the first byte
b[offset+3], b[offset+2], ..., b[offset]
public static double swapDouble(byte[] b, int offset)
b
- the byte arrayoffset
- the offset of the first byte
b[offset+7], b[offset+6], ..., b[offset]
public static char swapChar(byte[] b, int offset)
b
- the byte arrayoffset
- the offset of the first byte
b[offset+1], b[offset]
public static short swapShort(short s)
s
- input value for which byte reversal is desired
s
reversedpublic static int swapInt(int v)
v
- input value for which byte reversal is desired
v
reversedpublic static long swapLong(long l)
l
- input value for which byte reversal is desired
l
reversedpublic static float swapFloat(float v)
v
- input value for which byte reversal is desired
v
reversedpublic static double swapDouble(double v)
v
- input value for which byte reversal is desired
v
reversedpublic static byte[] shortToBytes(short v)
v
- input value
public static byte[] intToBytes(int v)
v
- input value
public static byte[] longToBytes(long v)
v
- input value
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |