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 Link icon

  • Method Details Link icon

    • openOutputFiles Link icon

      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 Link icon

      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 Link icon

      public boolean openNoiseFile(File anyOldFile)
    • closeFile Link icon

      public boolean closeFile()
    • writeHeader Link icon

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

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

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

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

      public boolean writeModuleFooter()
    • writeModuleFooter Link icon

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

      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 Link icon

      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 Link icon

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

      public long getFileSize()
    • storeData Link icon

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

      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 Link icon

      public boolean createIndexFile()
    • createIndexFile Link icon

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

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

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

      public String getMainFileName()
      Returns:
      the mainFileName
    • getStoredObjects Link icon

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