gov.nasa.gsfc.drl.rtstps.core.output.hdf5
Class DataProductsReader

java.lang.Object
  extended by gov.nasa.gsfc.drl.rtstps.core.output.hdf5.DataProductsReader
All Implemented Interfaces:
java.util.Iterator<RDRProduct>

public class DataProductsReader
extends java.lang.Object
implements java.util.Iterator<RDRProduct>

Supports the reading of RDR files /Data_Products group using an Iterator. The iterator returns a RDRProduct for each specific RDR found in the group. The HDF file is assumed to have been been opened outside this class.


Field Summary
private  long counter
           
private  int dataProductsGroup
           
private  java.lang.String[] names
           
private  long numObjects
           
private  RDRName[] rdrNames
           
 
Constructor Summary
DataProductsReader(int hdfFile)
          Open the /Data_Products group of the HDF file specified in the input argument as a handle to an already open HDF file.
DataProductsReader(int dataProductsHandle, boolean useProductsHandle)
          Alternate constructor uses a pre-existing "Data_Products" ID instead of the hdf file id, the fake 'useProductsHandle' is just here to differentiate the two constructors
 
Method Summary
 void close()
          Close the data products HDF group handle
private  void finish()
          Common to both constructors
 int getCount()
          Returns the number of items found the /Data_Products area.
 java.lang.String[] getNames()
          Return the string array of the name of the items found in the /Data_Products area.
 RDRProduct getRDRDataProductByName(java.lang.String rdrProductName)
          Given the string name of the RDR DataProduct, return its specific RDRProduct if it can be found.
 boolean hasNext()
          Determine if there are more /Data_Product items to read
 RDRProduct next()
          Get the next RDRProduct, item from the /Data_Product area.
 void remove()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dataProductsGroup

private int dataProductsGroup

numObjects

private long numObjects

counter

private long counter

names

private java.lang.String[] names

rdrNames

private RDRName[] rdrNames
Constructor Detail

DataProductsReader

public DataProductsReader(int hdfFile)
                   throws RtStpsException
Open the /Data_Products group of the HDF file specified in the input argument as a handle to an already open HDF file.

Parameters:
hdfFile - a handle the already open HDF file
Throws:
RtStpsException - Wraps any HDF library exceptions in an RtStpsException

DataProductsReader

public DataProductsReader(int dataProductsHandle,
                          boolean useProductsHandle)
                   throws RtStpsException
Alternate constructor uses a pre-existing "Data_Products" ID instead of the hdf file id, the fake 'useProductsHandle' is just here to differentiate the two constructors

Parameters:
dataProductsHandle - already opened HDF handle to the "Data_Products" area
useProductsHandle - value is ignored but differentiates constructors
Throws:
RtStpsException - Wraps any HDF library exceptions in an RtStpsException
Method Detail

finish

private void finish()
             throws RtStpsException
Common to both constructors

Throws:
RtStpsException - Wraps any HDF library exceptions in an RtStpsException

getRDRDataProductByName

public RDRProduct getRDRDataProductByName(java.lang.String rdrProductName)
                                   throws RtStpsException
Given the string name of the RDR DataProduct, return its specific RDRProduct if it can be found. This is an alternative to the Iterator interface.

Parameters:
rdrProductName - an RDR DataProduct name like SPACECRAFT-DIARY-RDR
Returns:
RDRProduct the designated product or null if it not found
Throws:
RtStpsException - wraps any HDF library exceptions in an RtStpsException

close

public void close()
           throws RtStpsException
Close the data products HDF group handle

Throws:
RtStpsException - wraps any HDF library exceptions in an RtStpsException

getCount

public int getCount()
Returns the number of items found the /Data_Products area.

Returns:
an int count of items

getNames

public java.lang.String[] getNames()
Return the string array of the name of the items found in the /Data_Products area.

Returns:
a String array consisting of the names found in the /Data_Products area
Throws:
throws - an RtStpsRuntimeException exception if it any HDF error occurs

hasNext

public boolean hasNext()
Determine if there are more /Data_Product items to read

Specified by:
hasNext in interface java.util.Iterator<RDRProduct>
Returns:
true if there are, false if not

next

public RDRProduct next()
Get the next RDRProduct, item from the /Data_Product area.

Specified by:
next in interface java.util.Iterator<RDRProduct>
Returns:
the next item as an RDRProduct
Throws:
throws - an RtStpsRuntimeException exception if it any HDF error occurs

remove

public void remove()
Specified by:
remove in interface java.util.Iterator<RDRProduct>