binaryFileStorage
Class BinaryInputStream

java.lang.Object
  extended by binaryFileStorage.BinaryInputStream

public class BinaryInputStream
extends java.lang.Object

Used to read data back from a binary data file and either send it off to the associated PamDataBlock or hand it back to the BinaryStore controller, e.g. for writing into a new file if data are being updated.

Author:
Doug Gillespie.

Field Summary
private  BinaryFooter binaryFooter
           
private  BinaryStore binaryStore
           
private  java.io.DataInputStream inputStream
           
private  long lastObjectTime
           
private  PamDataBlock pamDataBlock
           
private  int unitsRead
           
 
Constructor Summary
BinaryInputStream(BinaryStore binaryStore, PamDataBlock pamDataBlock)
           
 
Method Summary
protected  void closeFile()
           
protected  void finalize()
           
 BinaryFooter getBinaryFooter()
           
 long getLastObjectTime()
           
 int getUnitsRead()
           
protected  boolean openFile(java.io.File inputFile)
          Open an input file for reading.
protected  BinaryHeader readHeader()
          Reads the binary header from the file.
protected  BinaryObjectData readNextObject()
          Read the next object from the file.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

pamDataBlock

private PamDataBlock pamDataBlock

binaryStore

private BinaryStore binaryStore

inputStream

private java.io.DataInputStream inputStream

binaryFooter

private BinaryFooter binaryFooter

unitsRead

private int unitsRead

lastObjectTime

private long lastObjectTime
Constructor Detail

BinaryInputStream

public BinaryInputStream(BinaryStore binaryStore,
                         PamDataBlock pamDataBlock)
Method Detail

finalize

protected void finalize()
                 throws java.lang.Throwable
Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable

openFile

protected boolean openFile(java.io.File inputFile)
Open an input file for reading.

Parameters:
inputFile - file to open.
Returns:
true is successful.

closeFile

protected void closeFile()

readHeader

protected BinaryHeader readHeader()
Reads the binary header from the file.

Returns:
a binary header or null if the header could not be read

readNextObject

protected BinaryObjectData readNextObject()
Read the next object from the file.

The object data will be packed up in a BinaryObjectData which will have various fields filled in depending on the type of object.

null will be returned when there is an eof or when the file footer has been identified.

The calling function can check the file was complete by testing whether or not the file footer is null.

Returns:
data object.

getBinaryFooter

public BinaryFooter getBinaryFooter()
Returns:
the binaryFooter

getUnitsRead

public int getUnitsRead()
Returns:
the unitsRead

getLastObjectTime

public long getLastObjectTime()
Returns:
the lastObjectTime