binaryFileStorage
Class BinaryDataSource

java.lang.Object
  extended by binaryFileStorage.BinaryDataSource
Direct Known Subclasses:
AISBinaryDataSource, ClickBinaryDataSource, NoiseBinaryDataSource, WhistleBinaryDataSource

public abstract class BinaryDataSource
extends java.lang.Object

Not just a source, but also a sink for binary data from the binary store. Every BinaryDataSource is tied to a single PamDataBlock

Author:
Doug Gillespie
See Also:
PamDataBlock

Field Summary
private  BinaryOutputStream binaryStorageStream
           
private  PamDataBlock sisterDataBlock
           
 
Constructor Summary
BinaryDataSource(PamDataBlock sisterDataBlock)
           
 
Method Summary
 BinaryOutputStream getBinaryStorageStream()
           
 byte[] getModuleFooterData()
           
abstract  byte[] getModuleHeaderData()
           
 java.lang.String getModuleName()
           
 java.lang.String getModuleType()
           
abstract  int getModuleVersion()
          Get a version number for the module.
 PamDataBlock getSisterDataBlock()
           
 DataMapDrawing getSpecialDrawing()
          REturn a class capable of overriding the normal drawing on the data map
abstract  java.lang.String getStreamName()
           
abstract  int getStreamVersion()
           
abstract  void newFileOpened(java.io.File outputFile)
          Called from the BinaryOutputStream whenever a new output file is opened.
abstract  void saveData(PamDataUnit pamDataUnit)
          Save data into the binary stream
 void setBinaryStorageStream(BinaryOutputStream binaryStorageStream)
           
abstract  PamDataUnit sinkData(BinaryObjectData binaryObjectData, BinaryHeader bh, int moduleVersion)
          Convert data read back in in viewer mode into the correct type of PamDataUnit.
abstract  ModuleFooter sinkModuleFooter(BinaryObjectData binaryObjectData, BinaryHeader bh, ModuleHeader moduleHeader)
          Do something with module footer information
abstract  ModuleHeader sinkModuleHeader(BinaryObjectData binaryObjectData, BinaryHeader bh)
          Do something with module header information
 boolean storeData(int objectId, long timeMillis, byte[] data)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

binaryStorageStream

private BinaryOutputStream binaryStorageStream

sisterDataBlock

private PamDataBlock sisterDataBlock
Constructor Detail

BinaryDataSource

public BinaryDataSource(PamDataBlock sisterDataBlock)
Method Detail

getModuleType

public java.lang.String getModuleType()
Returns:
Module type to be stored in the file header

getModuleName

public java.lang.String getModuleName()
Returns:
Module name to be stored in the file header

getStreamName

public abstract java.lang.String getStreamName()
Returns:
Stream name to be stored in the file header

getStreamVersion

public abstract int getStreamVersion()
Returns:
Stream version name to be stored in the Module Specific Control structure

getModuleVersion

public abstract int getModuleVersion()
Get a version number for the module.

This is different to the version number in the main file header and allows individual modules to update their format and maintain backwards compatibility with old data

Returns:
integer module version number

getModuleHeaderData

public abstract byte[] getModuleHeaderData()
Returns:
Additional information (e.g. a control structure for a detector) to be stored in the Module Specific Control structure

getModuleFooterData

public byte[] getModuleFooterData()
Returns:
data for the binary footer, or null.

sinkData

public abstract PamDataUnit sinkData(BinaryObjectData binaryObjectData,
                                     BinaryHeader bh,
                                     int moduleVersion)
Convert data read back in in viewer mode into the correct type of PamDataUnit.

DO NOT add this unit directly to the datablock, but pass it back to the calling process which will add it to the datablock if necessary.

Parameters:
binaryObjectData - Binary data read back from a file.
bh - binary header from start of file.
moduleVersion -
Returns:
the PamDataUnit created from these data

sinkModuleHeader

public abstract ModuleHeader sinkModuleHeader(BinaryObjectData binaryObjectData,
                                              BinaryHeader bh)
Do something with module header information

Parameters:
binaryObjectData - data for the module header.
bh - Binary header information

sinkModuleFooter

public abstract ModuleFooter sinkModuleFooter(BinaryObjectData binaryObjectData,
                                              BinaryHeader bh,
                                              ModuleHeader moduleHeader)
Do something with module footer information

Parameters:
binaryObjectData - data for the module header.
bh - Binary header information

setBinaryStorageStream

public void setBinaryStorageStream(BinaryOutputStream binaryStorageStream)
Parameters:
binaryStorageStream - the binaryStorageStream to set

getBinaryStorageStream

public BinaryOutputStream getBinaryStorageStream()
Returns:
the binaryStorageStream

saveData

public abstract void saveData(PamDataUnit pamDataUnit)
Save data into the binary stream

Parameters:
pamDataUnit -

storeData

public boolean storeData(int objectId,
                         long timeMillis,
                         byte[] data)
Parameters:
objectId -
timeMillis -
data -
Returns:

getSisterDataBlock

public PamDataBlock getSisterDataBlock()

newFileOpened

public abstract void newFileOpened(java.io.File outputFile)
Called from the BinaryOutputStream whenever a new output file is opened.

Parameters:
outputFile - file information.

getSpecialDrawing

public DataMapDrawing getSpecialDrawing()
REturn a class capable of overriding the normal drawing on the data map

Returns:
null if nothign exists.