java.lang.Object
com.ibm.dataaccess.ByteArrayMarshaller
Conversion routines to marshall Java binary types (short, int, long, float,
double) to byte arrays.
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
writeDouble
(double value, byte[] byteArray, int offset, boolean bigEndian) Copies the double value into eight consecutive bytes of the byte array starting at the offset.static void
writeFloat
(float value, byte[] byteArray, int offset, boolean bigEndian) Copies the float value into four consecutive bytes of the byte array starting at the offset.static void
writeInt
(int value, byte[] byteArray, int offset, boolean bigEndian) Copies an int value into four consecutive bytes of the byte array starting at the offset.static void
writeInt
(int value, byte[] byteArray, int offset, boolean bigEndian, int numBytes) Copies zero to four bytes of the int value into the byte array starting at the offset.static void
writeLong
(long value, byte[] byteArray, int offset, boolean bigEndian) Copies the long value into eight consecutive bytes of the byte array starting at the offset.static void
writeLong
(long value, byte[] byteArray, int offset, boolean bigEndian, int numBytes) Copies zero to eight bytes of the long value into the byte array starting at the offset.static void
writeShort
(short value, byte[] byteArray, int offset, boolean bigEndian) Copies the short value into two consecutive bytes of the byte array starting at the offset.static void
writeShort
(short value, byte[] byteArray, int offset, boolean bigEndian, int numBytes) Copies zero to two bytes of the short value into the byte array starting at the offset.
-
Method Details
-
writeShort
public static void writeShort(short value, byte[] byteArray, int offset, boolean bigEndian) Copies the short value into two consecutive bytes of the byte array starting at the offset.- Parameters:
value
- the short value to marshallbyteArray
- destinationoffset
- offset in the byte arraybigEndian
- if false the bytes will be copied in reverse (little endian) order- Throws:
NullPointerException
- ifbyteArray
is nullArrayIndexOutOfBoundsException
- if an invalid array access occurs
-
writeShort
public static void writeShort(short value, byte[] byteArray, int offset, boolean bigEndian, int numBytes) Copies zero to two bytes of the short value into the byte array starting at the offset.- Parameters:
value
- the short value to marshallbyteArray
- destinationoffset
- offset in the byte arraybigEndian
- if false the bytes will be copied in reverse (little endian) ordernumBytes
- the number of bytes to marshal, must be 0-2 inclusive- Throws:
NullPointerException
- ifbyteArray
is nullIllegalArgumentException
- ifnumBytes < 0
ornumBytes > 2
ArrayIndexOutOfBoundsException
- if an invalid array access occurs
-
writeInt
public static void writeInt(int value, byte[] byteArray, int offset, boolean bigEndian) Copies an int value into four consecutive bytes of the byte array starting at the offset.- Parameters:
value
- the int value to marshallbyteArray
- destinationoffset
- offset in the byte arraybigEndian
- if false the bytes will be copied in reverse (little endian) order- Throws:
NullPointerException
- ifbyteArray
is nullArrayIndexOutOfBoundsException
- if an invalid array access occurs
-
writeInt
public static void writeInt(int value, byte[] byteArray, int offset, boolean bigEndian, int numBytes) Copies zero to four bytes of the int value into the byte array starting at the offset.- Parameters:
value
- the int value to marshallbyteArray
- destinationoffset
- offset in the byte arraybigEndian
- if false the bytes will be copied in reverse (little endian) ordernumBytes
- the number of bytes to marshall, must be 0-4 inclusive- Throws:
NullPointerException
- if byteArray is nullIllegalArgumentException
- ifnumBytes < 0
ornumBytes > 4
ArrayIndexOutOfBoundsException
- if an invalid array access occurs
-
writeLong
public static void writeLong(long value, byte[] byteArray, int offset, boolean bigEndian) Copies the long value into eight consecutive bytes of the byte array starting at the offset.- Parameters:
value
- the long value to marshallbyteArray
- destinationoffset
- offset in the byte arraybigEndian
- if false the bytes will be copied in reverse (little endian) order- Throws:
NullPointerException
- ifbyteArray
is nullArrayIndexOutOfBoundsException
- if an invalid array access occurs
-
writeLong
public static void writeLong(long value, byte[] byteArray, int offset, boolean bigEndian, int numBytes) Copies zero to eight bytes of the long value into the byte array starting at the offset.- Parameters:
value
- the long value to marshallbyteArray
- destinationoffset
- offset in the byte arraybigEndian
- if false the bytes will be copied in reverse (little endian) ordernumBytes
- the number of bytes to marshal, must be 0-8 inclusive- Throws:
NullPointerException
- ifbyteArray
is nullIllegalArgumentException
- ifnumBytes < 0
ornumBytes > 8
ArrayIndexOutOfBoundsException
- if an invalid array access occurs
-
writeFloat
public static void writeFloat(float value, byte[] byteArray, int offset, boolean bigEndian) Copies the float value into four consecutive bytes of the byte array starting at the offset.- Parameters:
value
- the float value to marshallbyteArray
- destinationoffset
- offset in the byte arraybigEndian
- if false the bytes will be copied in reverse (little endian) order- Throws:
NullPointerException
- ifbyteArray
is nullArrayIndexOutOfBoundsException
- if an invalid array access occurs
-
writeDouble
public static void writeDouble(double value, byte[] byteArray, int offset, boolean bigEndian) Copies the double value into eight consecutive bytes of the byte array starting at the offset.- Parameters:
value
- the double value to marshallbyteArray
- destinationoffset
- offset in the byte arraybigEndian
- if false the bytes will be copied in reverse (little endian) order- Throws:
NullPointerException
- ifbyteArray
is nullArrayIndexOutOfBoundsException
- if an invalid array access occurs
-