Class BinaryArrayImpl
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
FieldsModifier and TypeFieldDescriptionstatic final StringDefines the valid String indicating big endian byte order.static final intDefines the number of bytes required in an UNENCODED byte array to hold a dingle double value.static final intDefines the number of bytes required in an UNENCODED byte array to hold a single float value.static final StringDefines the valid String indicating the correct precision for encoded doubles.static final StringDefines the valid String indicating the correct precision for encoded floats.protected StringRepresents the binary contents of the array as an array of bytes.protected StringRepresents the endian value of the binary array (mzData element .../data/endian).protected longRepresents the length of the binary array (mzData element .../data/length).protected StringRepresents the precision of the binary array (mzData element .../data/precision).static final StringDefines the valid String indicating little endian byte order. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedDefault 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 TypeMethodDescriptionbooleanPerforms equals methods dependent on values of instance variables and class of Object o.Returns the endian value of the binary array (mzData element .../data/endian).longReturns the length of the binary array (mzData element .../data/length).Returns the precision of the binary array (mzData element .../data/precision).byte[]Returns the contents of the binary array decoded using the Base64 algorithm.double[]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).inthashCode()toString()Returns a useful String representation of this Imlplementation instance that includes details of all fields.
-
Field Details
-
BIG_ENDIAN_LABEL
Defines the valid String indicating big endian byte order.- See Also:
-
LITTLE_ENDIAN_LABEL
Defines the valid String indicating little endian byte order.- See Also:
-
FLOAT_PRECISION
Defines the valid String indicating the correct precision for encoded floats.- See Also:
-
DOUBLE_PRECISION
Defines the valid String indicating the correct precision for encoded doubles.- See Also:
-
BYTES_TO_HOLD_FLOAT
public static final int BYTES_TO_HOLD_FLOATDefines the number of bytes required in an UNENCODED byte array to hold a single float value.- See Also:
-
BYTES_TO_HOLD_DOUBLE
public static final int BYTES_TO_HOLD_DOUBLEDefines the number of bytes required in an UNENCODED byte array to hold a dingle double value.- See Also:
-
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 iDataLengthRepresents the length of the binary array (mzData element .../data/length).
-
iDataEndian
Represents the endian value of the binary array (mzData element .../data/endian).
-
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
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
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
-
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
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
Returns the precision of the binary array (mzData element .../data/precision).
- Returns:
- Returns the precision of the binary array (mzData element .../data/precision).
-
toString
Returns a useful String representation of this Imlplementation instance that includes details of all fields. -
equals
Performs equals methods dependent on values of instance variables and class of Object o.
-
hashCode
public int hashCode()
-