com.ibm.crypto.fips.provider

Class ByteArrayMarshaller

  • java.lang.Object
    • com.ibm.crypto.fips.provider.ByteArrayMarshaller


  • public class ByteArrayMarshaller
    extends java.lang.Object
    Conversion routines to marshall Java binary types (short, int, long, float, double) to byte arrays.
    • Method Summary

      Methods 
      Modifier and Type Method and 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 inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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 marshall
        byteArray - destination
        offset - offset in the byte array
        bigEndian - if false the bytes will be copied in reverse (little endian) order
        Throws:
        java.lang.NullPointerException - if byteArray is null
        java.lang.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:
        java.lang.NullPointerException - if byteArray is null
        java.lang.IllegalArgumentException - if numBytes < 0 or numBytes > 2
        java.lang.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:
        java.lang.NullPointerException - if byteArray is null
        java.lang.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:
        java.lang.NullPointerException - if byteArray is null
        java.lang.IllegalArgumentException - if numBytes < 0 or numBytes > 4
        java.lang.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:
        java.lang.NullPointerException - if byteArray is null
        java.lang.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:
        java.lang.NullPointerException - if byteArray is null
        java.lang.IllegalArgumentException - if numBytes < 0 or numBytes > 8
        java.lang.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:
        java.lang.NullPointerException - if byteArray is null
        java.lang.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:
        java.lang.NullPointerException - if byteArray is null
        java.lang.ArrayIndexOutOfBoundsException - if an invalid array access occurs
© Portions Copyright 2003, 2014, 2015, 2016 IBM Corporation. All rights reserved.
© Portions Copyright 2003, 2014 Oracle and/or its affiliates. All rights reserved.