Class BinaryArrayImpl

java.lang.Object
com.compomics.util.BinaryArrayImpl

public class BinaryArrayImpl
extends Object

Persistence independent object model implementation class:

Implements a binary array of the kind found in mzData/spectrumList/spectrum/mzArrayBinary or mzData/spectrumList/spectrum/intenArrayBinary.  Holds both the data itself and meta data describing the encoding of the data.

Author:
Philip Jones
  • Field Summary

    Fields 
    Modifier and Type Field Description
    static String BIG_ENDIAN_LABEL
    Defines the valid String indicating big endian byte order.
    static int BYTES_TO_HOLD_DOUBLE
    Defines the number of bytes required in an UNENCODED byte array to hold a dingle double value.
    static int BYTES_TO_HOLD_FLOAT
    Defines the number of bytes required in an UNENCODED byte array to hold a single float value.
    static String DOUBLE_PRECISION
    Defines the valid String indicating the correct precision for encoded doubles.
    static String FLOAT_PRECISION
    Defines the valid String indicating the correct precision for encoded floats.
    protected String iBase64String
    Represents the binary contents of the array as an array of bytes.
    protected String iDataEndian
    Represents the endian value of the binary array (mzData element .../data/endian).
    protected long iDataLength
    Represents the length of the binary array (mzData element .../data/length).
    protected String iDataPrecision
    Represents the precision of the binary array (mzData element .../data/precision).
    static String LITTLE_ENDIAN_LABEL
    Defines the valid String indicating little endian byte order.
  • Constructor Summary

    Constructors 
    Modifier Constructor Description
    protected BinaryArrayImpl()
    Default constructor with protected access.
      BinaryArrayImpl​(double[] doubleArray, String aDataEndian)
    Constructor that allows the creation of a BinaryArray object using an array of double values.
      BinaryArrayImpl​(float[] floatArray, String aDataEndian)
    Constructor that allows the creation of a BinaryArray object using an array of float values.
      BinaryArrayImpl​(String aBase64String, long aDataLength, String aDataEndian, String aDataPrecision)
    Creates an instance of this BinaryArray object, setting all fields as per description below.
  • Method Summary

    Modifier and Type Method Description
    boolean equals​(Object o)
    Performs equals methods dependent on values of instance variables and class of Object o.
    String getBase64String()  
    String getDataEndian()
    Returns the endian value of the binary array (mzData element .../data/endian).
    long getDataLength()
    Returns the length of the binary array (mzData element .../data/length).
    String getDataPrecision()
    Returns the precision of the binary array (mzData element .../data/precision).
    byte[] getDecodedByteArray()
    Returns the contents of the binary array decoded using the Base64 algorithm.
    double[] getDoubleArray()
    Checks if all the necessary information is provided and then converts the decoded binary array into an array of double values (that for example could be used to draw a spectra).
    int hashCode()  
    String toString()
    Returns a useful String representation of this Imlplementation instance that includes details of all fields.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • BIG_ENDIAN_LABEL

      public static final String BIG_ENDIAN_LABEL
      Defines the valid String indicating big endian byte order.
      See Also:
      Constant Field Values
    • LITTLE_ENDIAN_LABEL

      public static final String LITTLE_ENDIAN_LABEL
      Defines the valid String indicating little endian byte order.
      See Also:
      Constant Field Values
    • FLOAT_PRECISION

      public static final String FLOAT_PRECISION
      Defines the valid String indicating the correct precision for encoded floats.
      See Also:
      Constant Field Values
    • DOUBLE_PRECISION

      public static final String DOUBLE_PRECISION
      Defines the valid String indicating the correct precision for encoded doubles.
      See Also:
      Constant Field Values
    • BYTES_TO_HOLD_FLOAT

      public static final int BYTES_TO_HOLD_FLOAT
      Defines the number of bytes required in an UNENCODED byte array to hold a single float value.
      See Also:
      Constant Field Values
    • BYTES_TO_HOLD_DOUBLE

      public static final int BYTES_TO_HOLD_DOUBLE
      Defines the number of bytes required in an UNENCODED byte array to hold a dingle double value.
      See Also:
      Constant Field Values
    • iBase64String

      protected String iBase64String

      Represents the binary contents of the array as an array of bytes. (mzData element .../binaryDataGroup.)

      Note that the contents of this field can be obtained from a database by calling the java.sql.Blob.getBytes():byte[] method.

    • iDataLength

      protected long iDataLength

      Represents the length of the binary array (mzData element .../data/length).

    • iDataEndian

      protected String iDataEndian

      Represents the endian value of the binary array (mzData element .../data/endian).

    • iDataPrecision

      protected String iDataPrecision

      Represents the precision of the binary array (mzData element .../data/precision).

  • Constructor Details

    • BinaryArrayImpl

      protected BinaryArrayImpl()

      Default constructor with protected access.

    • BinaryArrayImpl

      public BinaryArrayImpl​(String aBase64String, long aDataLength, String aDataEndian, String aDataPrecision)

      Creates an instance of this BinaryArray object, setting all fields as per description below.

      Parameters:
      aBase64String - the binary contents of the array as an array of bytes. (mzData element .../binaryDataGroup.) Note that the contents of this field can be obtained from a database by calling the java.sql.Blob.getBytes():byte[] method.
      aDataLength - the length of the binary array (mzData element .../data/length).
      aDataEndian - The byte order is used when reading or writing multibyte values stored as mzData element .../data/endian. Only possible values are defined by the static String members of this class 'BIG_ENDIAN_LABEL' (or "big") and 'LITTLE_ENDIAN_LABEL' (or "little").
      aDataPrecision - the precision of the binary array (mzData element .../data/precision) that indicates if the array contains encoded double values or encoded float values. Only possible values for this parameter are defined byt he static String members of this class 'FLOAT_PRECISION' (or "32") and 'DOUBLE_PRECISION' (or "64").
    • BinaryArrayImpl

      public BinaryArrayImpl​(double[] doubleArray, String aDataEndian)
      Constructor that allows the creation of a BinaryArray object using an array of double values.
      Parameters:
      doubleArray - being the array of double values to be converted to base64 and placed in the mzData element .../binaryDataGroup.
      aDataEndian - The byte order is used when reading or writing multibyte values stored as mzData element .../data/endian. Only possible values are defined by the static String members of this class 'BIG_ENDIAN_LABEL' (or "big") and 'LITTLE_ENDIAN_LABEL' (or "little").
    • BinaryArrayImpl

      public BinaryArrayImpl​(float[] floatArray, String aDataEndian)
      Constructor that allows the creation of a BinaryArray object using an array of float values.
      Parameters:
      floatArray - being the array of float values to be converted to base64 and placed in the mzData element .../binaryDataGroup.
      aDataEndian - The byte order is used when reading or writing multibyte values stored as mzData element .../data/endian. Only possible values are defined by the static String members of this class 'BIG_ENDIAN_LABEL' (or "big") and 'LITTLE_ENDIAN_LABEL' (or "little").
  • Method Details

    • getBase64String

      public String getBase64String()
    • getDecodedByteArray

      public byte[] getDecodedByteArray()

      Returns the contents of the binary array decoded using the Base64 algorithm.

      Returns:
      the contents of the binary array decoded using the Base64 algorithm.
    • getDoubleArray

      public double[] getDoubleArray()
      Checks if all the necessary information is provided and then converts the decoded binary array into an array of double values (that for example could be used to draw a spectra).
      Returns:
      the decoded binary array converted into an array of double values.
    • getDataLength

      public long getDataLength()

      Returns the length of the binary array (mzData element .../data/length).

      Returns:
      Returns the length of the binary array (mzData element .../data/length).
    • getDataEndian

      public String getDataEndian()

      Returns the endian value of the binary array (mzData element .../data/endian).

      Returns:
      Returns the endian value of the binary array (mzData element .../data/endian).
    • getDataPrecision

      public String getDataPrecision()

      Returns the precision of the binary array (mzData element .../data/precision).

      Returns:
      Returns the precision of the binary array (mzData element .../data/precision).
    • toString

      public String toString()
      Returns a useful String representation of this Imlplementation instance that includes details of all fields.
      Overrides:
      toString in class Object
      Returns:
      a useful String representation of this Imlplementation instance.
    • equals

      public boolean equals​(Object o)

      Performs equals methods dependent on values of instance variables and class of Object o.

      Overrides:
      equals in class Object
      Parameters:
      o - Object that this is being compared with.
      Returns:
      boolean indicating equality of this object with the parameter Object o
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object