Class ByteArrayMarshaller

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

    Modifier and Type
    Method
    Description
    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.
    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.

    Methods declared in class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 marshall
      byteArray - destination
      offset - offset in the byte array
      bigEndian - if false the bytes will be copied in reverse (little endian) order
      Throws:
      NullPointerException - if byteArray is null
      ArrayIndexOutOfBoundsException - 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 marshall
      byteArray - destination
      offset - offset in the byte array
      bigEndian - if false the bytes will be copied in reverse (little endian) order
      numBytes - the number of bytes to marshal, must be 0-2 inclusive
      Throws:
      NullPointerException - if byteArray is null
      IllegalArgumentException - if numBytes < 0 or numBytes > 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 marshall
      byteArray - destination
      offset - offset in the byte array
      bigEndian - if false the bytes will be copied in reverse (little endian) order
      Throws:
      NullPointerException - if byteArray is null
      ArrayIndexOutOfBoundsException - 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 marshall
      byteArray - destination
      offset - offset in the byte array
      bigEndian - if false the bytes will be copied in reverse (little endian) order
      numBytes - the number of bytes to marshall, must be 0-4 inclusive
      Throws:
      NullPointerException - if byteArray is null
      IllegalArgumentException - if numBytes < 0 or numBytes > 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 marshall
      byteArray - destination
      offset - offset in the byte array
      bigEndian - if false the bytes will be copied in reverse (little endian) order
      Throws:
      NullPointerException - if byteArray is null
      ArrayIndexOutOfBoundsException - 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 marshall
      byteArray - destination
      offset - offset in the byte array
      bigEndian - if false the bytes will be copied in reverse (little endian) order
      numBytes - the number of bytes to marshal, must be 0-8 inclusive
      Throws:
      NullPointerException - if byteArray is null
      IllegalArgumentException - if numBytes < 0 or numBytes > 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 marshall
      byteArray - destination
      offset - offset in the byte array
      bigEndian - if false the bytes will be copied in reverse (little endian) order
      Throws:
      NullPointerException - if byteArray is null
      ArrayIndexOutOfBoundsException - 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 marshall
      byteArray - destination
      offset - offset in the byte array
      bigEndian - if false the bytes will be copied in reverse (little endian) order
      Throws:
      NullPointerException - if byteArray is null
      ArrayIndexOutOfBoundsException - if an invalid array access occurs