Class BinaryObjectData

java.lang.Object
binaryFileStorage.BinaryObjectData
Direct Known Subclasses:
PackedBinaryObject

public class BinaryObjectData extends Object
Class to temporarily hold an objected data that has just been read from a binary file. Not all types of object use all the fields and data don't tend to stay in this class for long - it's just a convenient way of getting data from a to b. Note that the format of data within this object is only concerned with the file. Individual modules will have put an additional version number in the module header which will get passed around by whatever is unpacking the data.
Author:
Doug Gillespie
  • Constructor Details

    • BinaryObjectData

      public BinaryObjectData(int fileVersion, int objectType, byte[] data, int dataLength)
      Constructor used when header / footer or other non-data objects are read from a stream.
      Parameters:
      objectType - Object type
      data - binary data
      dataLength - binary data length.
    • BinaryObjectData

      public BinaryObjectData(int fileVersion, int objectType, DataUnitBaseData baseData, int objectNumber, byte[] data, int dataLength)
      Constructor used when data units are being read from a data stream.
      Parameters:
      objectType - object type
      baseData - base data object, which should have already been read and populated.
      objectNumber - object count in stream
      data - binary data
      dataLength - binary data length
    • BinaryObjectData

      public BinaryObjectData(int objectType, byte[] byteArray)
      Version of constructor to replace previous calls to PackedbinaryObject which is now deprecated and removed.
      Parameters:
      objectType - Object type (+ve for data type, -ve for headers and footers)
      byteArray - array of data for the data unit
      moduleVersion - (will have been read back from file, not really used when writing).
  • Method Details

    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getObjectType

      public int getObjectType()
      Returns:
      the objectType
    • getData

      public byte[] getData()
      Returns:
      the data. Note that the data array may be longer than the actual data within it. Use getDataLength() to check.
    • getDataInputStream

      public DataInputStream getDataInputStream()
      Get a data input stream to read actual data from if needed.
      Returns:
      null if no data or a data input stream.
    • getDataLength

      public int getDataLength()
      Returns:
      the dataLength
    • getObjectNumber

      public int getObjectNumber()
      Returns:
      the objectNumber
    • getVersionNumber

      public int getVersionNumber()
      This is the FILE or NETWORK version number, not the module specific version number. For file data, this will be read out of the file header, for network data, it is the second word in every TCP packet. The module specific version number is read for data units separately and is NOT included in this object.
      Returns:
      the versionNumber
    • setVersionNumber

      public void setVersionNumber(int versionNumber)
      This is the FILE or NETWORK version number, not the module specific version number. For file data, this will be read out of the file header, for network data, it is the second word in every TCP packet. The module specific version number is read for data units separately and is NOT included in this object.
      Parameters:
      versionNumber - the versionNumber to set
    • getTimeMilliseconds

      public long getTimeMilliseconds()
    • getDataUnitBaseData

      public DataUnitBaseData getDataUnitBaseData()
      Returns:
      the dataUnitBaseData
    • getAnnotationData

      public byte[] getAnnotationData()
      Will return null if there is no annotation data
      Returns:
      the annotationData
    • setAnnotationData

      public void setAnnotationData(byte[] annotationData)
      Parameters:
      annotationData - the annotationData to set
    • setAnnotationData

      public void setAnnotationData(byte[] annotationData, int annotationDataLength)
      Parameters:
      annotationData - the annotationData to set
      annotationDataLength - length of annotation data (may not be using the full byte array annotationData)
    • getAnnotationDataLength

      public int getAnnotationDataLength()
      Returns:
      the annotationDataLength
    • shiftChannels

      public int shiftChannels(int shift)
      Shift the channels in the base data. Positive will increase channel numbers, -ve reduce them.
      Parameters:
      shift - channel shift
      Returns:
      new channel map