Package ucar.unidata.io
Class Swap
java.lang.Object
ucar.unidata.io.Swap
Deprecated.
do not use
The Swap class provides static methods for swapping the bytes of chars,
shorts, ints, longs, floats, and doubles.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]intToBytes(int v) Deprecated.Convert an int to an array of 4 bytes.static byte[]longToBytes(long v) Deprecated.Convert a long to an array of 8 bytes.static byte[]shortToBytes(short v) Deprecated.Convert a short to an array of 2 bytes.static charswapChar(byte[] b, int offset) Deprecated.Returns the char resulting from swapping 2 bytes at a specified offset in a byte array.static doubleswapDouble(byte[] b, int offset) Deprecated.Returns the double resulting from reversing 8 bytes at a specified offset in a byte array.static doubleswapDouble(double v) Deprecated.Returns the double resulting from reversing 8 bytes of a specified double.static floatswapFloat(byte[] b, int offset) Deprecated.Returns the float resulting from reversing 4 bytes at a specified offset in a byte array.static floatswapFloat(float v) Deprecated.Returns the float resulting from reversing 4 bytes of a specified float.static intswapInt(byte[] b, int offset) Deprecated.Returns the int resulting from reversing 4 bytes at a specified offset in a byte array.static intswapInt(int v) Deprecated.Returns the int resulting from reversing 4 bytes of a specified int.static longswapLong(byte[] b, int offset) Deprecated.Returns the long resulting from reversing 8 bytes at a specified offset in a byte array.static longswapLong(long l) Deprecated.Returns the long resulting from reversing 8 bytes of a specified long.static shortswapShort(byte[] b, int offset) Deprecated.Returns the short resulting from swapping 2 bytes at a specified offset in a byte array.static shortswapShort(short s) Deprecated.Returns the short resulting from swapping 2 bytes of a specified short.
-
Constructor Details
-
Swap
public Swap()Deprecated.
-
-
Method Details
-
swapShort
public static short swapShort(byte[] b, int offset) Deprecated.Returns the short resulting from swapping 2 bytes at a specified offset in a byte array.- Parameters:
b- the byte arrayoffset- the offset of the first byte- Returns:
- the short represented by the bytes
b[offset+1], b[offset]
-
swapInt
public static int swapInt(byte[] b, int offset) Deprecated.Returns the int resulting from reversing 4 bytes at a specified offset in a byte array.- Parameters:
b- the byte arrayoffset- the offset of the first byte- Returns:
- the int represented by the bytes
b[offset+3], b[offset+2], ..., b[offset]
-
swapLong
public static long swapLong(byte[] b, int offset) Deprecated.Returns the long resulting from reversing 8 bytes at a specified offset in a byte array.- Parameters:
b- the byte arrayoffset- the offset of the first byte- Returns:
- the long represented by the bytes
b[offset+7], b[offset+6], ..., b[offset]
-
swapFloat
public static float swapFloat(byte[] b, int offset) Deprecated.Returns the float resulting from reversing 4 bytes at a specified offset in a byte array.- Parameters:
b- the byte arrayoffset- the offset of the first byte- Returns:
- the float represented by the bytes
b[offset+3], b[offset+2], ..., b[offset]
-
swapDouble
public static double swapDouble(byte[] b, int offset) Deprecated.Returns the double resulting from reversing 8 bytes at a specified offset in a byte array.- Parameters:
b- the byte arrayoffset- the offset of the first byte- Returns:
- the double represented by the bytes
b[offset+7], b[offset+6], ..., b[offset]
-
swapChar
public static char swapChar(byte[] b, int offset) Deprecated.Returns the char resulting from swapping 2 bytes at a specified offset in a byte array.- Parameters:
b- the byte arrayoffset- the offset of the first byte- Returns:
- the char represented by the bytes
b[offset+1], b[offset]
-
swapShort
public static short swapShort(short s) Deprecated.Returns the short resulting from swapping 2 bytes of a specified short.- Parameters:
s- input value for which byte reversal is desired- Returns:
- the value represented by the bytes of
sreversed
-
swapInt
public static int swapInt(int v) Deprecated.Returns the int resulting from reversing 4 bytes of a specified int.- Parameters:
v- input value for which byte reversal is desired- Returns:
- the value represented by the bytes of
vreversed
-
swapLong
public static long swapLong(long l) Deprecated.Returns the long resulting from reversing 8 bytes of a specified long.- Parameters:
l- input value for which byte reversal is desired- Returns:
- the value represented by the bytes of
lreversed
-
swapFloat
public static float swapFloat(float v) Deprecated.Returns the float resulting from reversing 4 bytes of a specified float.- Parameters:
v- input value for which byte reversal is desired- Returns:
- the value represented by the bytes of
vreversed
-
swapDouble
public static double swapDouble(double v) Deprecated.Returns the double resulting from reversing 8 bytes of a specified double.- Parameters:
v- input value for which byte reversal is desired- Returns:
- the value represented by the bytes of
vreversed
-
shortToBytes
public static byte[] shortToBytes(short v) Deprecated.Convert a short to an array of 2 bytes.- Parameters:
v- input value- Returns:
- the corresponding array of bytes
-
intToBytes
public static byte[] intToBytes(int v) Deprecated.Convert an int to an array of 4 bytes.- Parameters:
v- input value- Returns:
- the corresponding array of bytes
-
longToBytes
public static byte[] longToBytes(long v) Deprecated.Convert a long to an array of 8 bytes.- Parameters:
v- input value- Returns:
- the corresponding array of bytes
-