gov.nasa.gsfc.drl.rtstps.core.output.hdf5.UnitTest
Class FilePacketReader

java.lang.Object
  extended by gov.nasa.gsfc.drl.rtstps.core.output.hdf5.UnitTest.FilePacketReader
All Implemented Interfaces:
PacketReaderI, java.util.Iterator<PacketI>

public class FilePacketReader
extends java.lang.Object
implements java.util.Iterator<PacketI>, PacketReaderI

Reads packets out of a known packet file, return an index to a buffer that holds them using an Iterator interface.


Field Summary
private  int bufLength
           
private static int bufSize
           
(package private) static byte[] dataBuf
           
private  PacketFactoryI factory
           
private  java.io.FileInputStream fis
           
private  int index
           
private  java.io.File inputFile
           
private  int leftToProcess
           
 
Constructor Summary
FilePacketReader(PacketFactoryI factory, java.lang.String fileName)
          Given file name, open the file
 
Method Summary
private  int getAppID()
           
 int getLeftOver()
           
private  int getPacketLength()
           
private  int getPacketSize()
           
 boolean hasNext()
          If there's space for a packet there's another...
private  void mayNeedToReadMore()
           
 PacketI next()
          Return a Packet constructed from an index into the buffer
private  void readInMore()
           
 void remove()
          Remove current packet.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

inputFile

private java.io.File inputFile

fis

private java.io.FileInputStream fis

index

private int index

bufSize

private static final int bufSize
See Also:
Constant Field Values

dataBuf

static byte[] dataBuf

bufLength

private int bufLength

factory

private PacketFactoryI factory

leftToProcess

private int leftToProcess
Constructor Detail

FilePacketReader

public FilePacketReader(PacketFactoryI factory,
                        java.lang.String fileName)
                 throws RtStpsException
Given file name, open the file

Parameters:
fileName -
Throws:
java.io.IOException
RtStpsException
Method Detail

next

public PacketI next()
Return a Packet constructed from an index into the buffer

Specified by:
next in interface PacketReaderI
Specified by:
next in interface java.util.Iterator<PacketI>
Returns:
the next Packet

hasNext

public boolean hasNext()
If there's space for a packet there's another...

Specified by:
hasNext in interface PacketReaderI
Specified by:
hasNext in interface java.util.Iterator<PacketI>
Returns:
true if there is another packet, false if not

remove

public void remove()
Description copied from interface: PacketReaderI
Remove current packet. Generally not supported and throws a runtime exception

Specified by:
remove in interface PacketReaderI
Specified by:
remove in interface java.util.Iterator<PacketI>

getLeftOver

public int getLeftOver()

getAppID

private int getAppID()

getPacketLength

private int getPacketLength()

getPacketSize

private int getPacketSize()

mayNeedToReadMore

private void mayNeedToReadMore()
                        throws java.io.IOException
Throws:
java.io.IOException

readInMore

private void readInMore()
                 throws java.io.IOException
Throws:
java.io.IOException