Class BinaryOutputStream

java.lang.Object
binaryFileStorage.BinaryOutputStream

public class BinaryOutputStream extends Object
Handles writing of an actual binary data file.

Is used during data analysis and also to rewrite files if they are changed during offline analysis using the PAMGUARD viewer.

Author:
Doug Gillespie
See Also:
  • Constructor Details

  • Method Details

    • openOutputFiles

      public boolean openOutputFiles(long dataTime)
      Open an output file.

      this call is used in real time ops to create a new file name based on the time and information from the datablock name.

      Parameters:
      dataTime - time in Java milliseconds
      Returns:
      true if successful, false otherwise.
    • openPGDFFile

      public boolean openPGDFFile(File outputFile)
      Open an output file.

      This version is also used when rewriting files when data have been changed offline. Generally the file will be a .tmp file

      Parameters:
      outputFile - output file
      Returns:
      true if successful
    • openNoiseFile

      public boolean openNoiseFile(File anyOldFile)
    • closeFile

      public boolean closeFile()
    • writeHeader

      public boolean writeHeader(long dataTime, long analTime)
    • writeModuleHeader

      public boolean writeModuleHeader()
      Called just after datafiles are opened to put a header in the main output pgdf file.
      Returns:
      true if OK.
    • writeModuleHeader

      public boolean writeModuleHeader(byte[] headerData)
      Only writes module header to main pgdf file.
      Parameters:
      headerData -
      Returns:
    • writeModuleHeader

      public boolean writeModuleHeader(DataOutputStream outputStream, byte[] headerData)
    • writeModuleFooter

      public boolean writeModuleFooter()
    • writeModuleFooter

      public boolean writeModuleFooter(ModuleFooter moduleFooter)
      Write a module footer to the output stream.
      Parameters:
      moduleFooter - module footer
      Returns:
      true if successful
    • writeModuleFooter

      public boolean writeModuleFooter(byte[] footerData)
      Write module footer data to the output stream. Note that this is the data alone, without the first 12 bytes of identifier and length information.
      Parameters:
      footerData - footer data as a binary array
      Returns:
      true if successful
    • writeModuleFooter

      public boolean writeModuleFooter(DataOutputStream outputStream, byte[] footerData)
      Write module footer data to a specific output stream.
      Parameters:
      outputStream - output stream
      footerData - footer data in a binary array
      Returns:
      true if sucessful.
    • writeFooter

      public boolean writeFooter(long dataTime, long analTime, int endReason)
    • getFileSize

      public long getFileSize()
    • storeData

      public boolean storeData(int objectId, DataUnitBaseData baseData, BinaryObjectData binaryObjectData)
    • storeData

      public boolean storeData(DataOutputStream outputStream, int objectId, DataUnitBaseData baseData, BinaryObjectData binaryObjectData)
      Writes data to a file. Note that the length of data may be greater than the actual length of useful data which is held in onjectLength
      Parameters:
      objectId - unique object identifier.
      timeMillis - time of object in java milliseconds
      data - byte array of binary data to store.
      objectLength - length of useful data in data (often = data.length)
      Returns:
      true if written successfully.
    • createIndexFile

      public boolean createIndexFile()
    • createIndexFile

      public boolean createIndexFile(File indexFile, BinaryOfflineDataMapPoint mapPoint)
    • writeDatagram

      public boolean writeDatagram(Datagram datagram)
      Write a Datagram to an output stream
      Parameters:
      datagram -
      Returns:
      true if successful.
      See Also:
    • writeFileFooter

      public boolean writeFileFooter(BinaryFooter footer)
      Write a file footer to the binary output stream.
      Parameters:
      footer - file footer.
      Returns:
      true if successful.
    • getMainFileName

      public String getMainFileName()
      Returns:
      the mainFileName
    • getStoredObjects

      public int getStoredObjects()
      Get the number of objects stored in the current file.
      Returns:
      the number of objects stored in the current file.