public class BinaryConverter
extends java.lang.Object
Note: Some methods of this class accept an array-valued argument in addition to arguments that specify an array offset and possibly also a length.
All such methods will throw an ArrayIndexOutOfBoundsException
if the offset and/or length are not valid for the array.
Modifier and Type | Method and Description |
---|---|
static char[] |
byteArrayToCharArray(byte[] byteValue) |
static double |
byteArrayToDouble(byte[] serverValue,
int offset)
Convert the specified IBM i data type to a double.
|
static float |
byteArrayToFloat(byte[] serverValue,
int offset)
Convert the specified IBM i data type to a float.
|
static int |
byteArrayToInt(byte[] serverValue,
int offset)
Convert the specified IBM i data type to an int.
|
static long |
byteArrayToLong(byte[] serverValue,
int offset)
Convert the specified IBM i data type to a long.
|
static short |
byteArrayToShort(byte[] serverValue,
int offset)
Convert the specified IBM i data type to a short.
|
static long |
byteArrayToUnsignedInt(byte[] serverValue,
int offset)
Convert the specified IBM i data type to a long.
|
static int |
byteArrayToUnsignedShort(byte[] serverValue,
int offset)
Convert the specified IBM i data type to an int.
|
static java.lang.String |
bytesToHexString(byte[] b)
Convert the specified byte array to its hexadecimal String representation.
|
static java.lang.String |
bytesToHexString(byte[] b,
int offset,
int length)
Convert the specified byte array to its hexadecimal String representation.
|
static java.lang.String |
bytesToString(byte[] b)
Deprecated.
Replaced by bytesToHexString(). (Same implementation, better name.)
|
static java.lang.String |
bytesToString(byte[] b,
int offset,
int length)
Deprecated.
Replaced by bytesToHexString(). (Same implementation, better name.)
|
static byte[] |
charArrayToByteArray(char[] charValue) |
static byte[] |
doubleToByteArray(double doubleValue)
Convert the specified double into IBM i format in a byte array.
|
static void |
doubleToByteArray(double doubleValue,
byte[] serverValue,
int offset)
Convert the specified double into IBM i format in the specified byte array.
|
static byte[] |
floatToByteArray(float floatValue)
Convert the specified float into IBM i format in a byte array.
|
static void |
floatToByteArray(float floatValue,
byte[] serverValue,
int offset)
Convert the specified float into IBM i format in the specified byte array.
|
static byte[] |
floatToByteArray(int floatValue)
Deprecated.
Use floatToByteArray(float) instead.
|
static byte[] |
intToByteArray(int intValue)
Convert the specified int into IBM i format in a byte array.
|
static void |
intToByteArray(int intValue,
byte[] serverValue,
int offset)
Convert the specified int into IBM i format in the specified byte array.
|
static byte[] |
longToByteArray(long longValue)
Convert the specified long into IBM i format in a byte array.
|
static void |
longToByteArray(long longValue,
byte[] serverValue,
int offset)
Convert the specified long into IBM i format in the specified byte array.
|
static byte[] |
shortToByteArray(short shortValue)
Convert the specified short into IBM i format in a byte array.
|
static void |
shortToByteArray(short shortValue,
byte[] serverValue,
int offset)
Convert the specified short into IBM i format in the specified byte array.
|
static byte[] |
stringToBytes(java.lang.String s)
Convert the specified hexadecimal String into a byte array containing the byte values for the
hexadecimal characters in the String.
|
static byte[] |
unsignedIntToByteArray(long longValue)
Convert the specified long into IBM i format in a byte array.
|
static void |
unsignedIntToByteArray(long longValue,
byte[] serverValue,
int offset)
Convert the specified long into IBM i format in the specified byte array.
|
static byte[] |
unsignedShortToByteArray(int intValue)
Convert the specified int into IBM i format in a byte array.
|
static void |
unsignedShortToByteArray(int intValue,
byte[] serverValue,
int offset)
Convert the specified int into IBM i format in the specified byte array.
|
public static void shortToByteArray(short shortValue, byte[] serverValue, int offset)
shortValue
- The value to be converted to IBM i format.serverValue
- The array to receive the data type in IBM i format.offset
- The offset into the byte array for the start of the IBM i value.public static byte[] shortToByteArray(short shortValue)
shortValue
- The value to be converted to IBM i format.public static short byteArrayToShort(byte[] serverValue, int offset)
serverValue
- The array containing the data type in IBM i format.offset
- The offset into the byte array for the start of the IBM i value.public static void intToByteArray(int intValue, byte[] serverValue, int offset)
intValue
- The value to be converted to IBM i format.serverValue
- The array to receive the data type in IBM i format.offset
- The offset into the byte array for the start of the IBM i value.public static byte[] intToByteArray(int intValue)
intValue
- The value to be converted to IBM i format.public static int byteArrayToInt(byte[] serverValue, int offset)
serverValue
- The array containing the data type in IBM i format.offset
- The offset into the byte array for the start of the IBM i value.public static void floatToByteArray(float floatValue, byte[] serverValue, int offset)
floatValue
- The value to be converted to IBM i format.serverValue
- The array to receive the data type in IBM i format.offset
- The offset into the byte array for the start of the IBM i value.public static byte[] floatToByteArray(int floatValue)
floatValue
- The value to be converted to IBM i format.public static byte[] floatToByteArray(float floatValue)
floatValue
- The value to be converted to IBM i format.public static float byteArrayToFloat(byte[] serverValue, int offset)
serverValue
- The array containing the data type in IBM i format.offset
- The offset into the byte array for the start of the IBM i value.public static void doubleToByteArray(double doubleValue, byte[] serverValue, int offset)
doubleValue
- The value to be converted to IBM i format.serverValue
- The array to receive the data type in IBM i format.offset
- The offset into the byte array for the start of the IBM i value.public static byte[] doubleToByteArray(double doubleValue)
doubleValue
- The value to be converted to IBM i format.public static double byteArrayToDouble(byte[] serverValue, int offset)
serverValue
- The array containing the data type in IBM i format.offset
- The offset into the byte array for the start of the IBM i value.public static void unsignedShortToByteArray(int intValue, byte[] serverValue, int offset)
intValue
- The value to be converted to IBM i format. The integer should be greater than or equal to zero and representable in two bytes.serverValue
- The array to receive the data type in IBM i format.offset
- The offset into the byte array for the start of the IBM i value.public static byte[] unsignedShortToByteArray(int intValue)
intValue
- The value to be converted to IBM i format. The integer should be greater than or equal to zero and representable in two bytes.public static int byteArrayToUnsignedShort(byte[] serverValue, int offset)
serverValue
- The array containing the data type in IBM i format.offset
- The offset into the byte array for the start of the IBM i value.public static void unsignedIntToByteArray(long longValue, byte[] serverValue, int offset)
longValue
- The value to be converted to IBM i format. The long should be greater than or equal to zero and representable in four bytes.serverValue
- The array to receive the data type in IBM i format.offset
- The offset into the byte array for the start of the IBM i value.public static byte[] unsignedIntToByteArray(long longValue)
longValue
- The value to be converted to IBM i format. The long should be greater than or equal to zero and representable in four bytes.public static long byteArrayToUnsignedInt(byte[] serverValue, int offset)
serverValue
- The array containing the data type in IBM i format.offset
- The offset into the byte array for the start of the IBM i value.public static void longToByteArray(long longValue, byte[] serverValue, int offset)
longValue
- The value to be converted to IBM i format.serverValue
- The array to receive the data type in IBM i format.offset
- The offset into the byte array for the start of the IBM i value.public static byte[] longToByteArray(long longValue)
longValue
- The value to be converted to IBM i format.public static long byteArrayToLong(byte[] serverValue, int offset)
serverValue
- The array containing the data type in IBM i format.offset
- The offset into the byte array for the start of the IBM i value.public static byte[] charArrayToByteArray(char[] charValue)
public static char[] byteArrayToCharArray(byte[] byteValue)
public static final java.lang.String bytesToString(byte[] b)
b
- The array containing the data.public static final java.lang.String bytesToString(byte[] b, int offset, int length)
b
- The array containing the data.offset
- The offset into the array at which to begin reading bytes.length
- The number of bytes to read out of the array.public static final java.lang.String bytesToHexString(byte[] b)
b
- The array containing the data.public static final java.lang.String bytesToHexString(byte[] b, int offset, int length)
b
- The array containing the data.offset
- The offset into the array at which to begin reading bytes.length
- The number of bytes to read out of the array.public static final byte[] stringToBytes(java.lang.String s) throws java.lang.NumberFormatException
s
- The String containing the hexadecimal representation of the data.java.lang.NumberFormatException
- If the number cannot be formatted