- java.lang.Object
-
- com.ibm.dataaccess.ByteArrayMarshaller
-
public class ByteArrayMarshaller extends Object
Conversion routines to marshall Java binary types (short, int, long, float, double) to byte arrays.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidwriteDouble(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 voidwriteFloat(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 voidwriteInt(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 voidwriteInt(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 voidwriteLong(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 voidwriteLong(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 voidwriteShort(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 voidwriteShort(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 Detail
-
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- ifbyteArrayis 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- ifbyteArrayis nullIllegalArgumentException- ifnumBytes < 0ornumBytes > 2ArrayIndexOutOfBoundsException- 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- ifbyteArrayis 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 < 0ornumBytes > 4ArrayIndexOutOfBoundsException- 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- ifbyteArrayis 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- ifbyteArrayis nullIllegalArgumentException- ifnumBytes < 0ornumBytes > 8ArrayIndexOutOfBoundsException- 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- ifbyteArrayis 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- ifbyteArrayis nullArrayIndexOutOfBoundsException- if an invalid array access occurs
-
-