org.jscience.io.fits
Class RandomAccessFitsFile

java.lang.Object
  extended by org.jscience.io.fits.FitsFile
      extended by org.jscience.io.fits.RandomAccessFitsFile

public class RandomAccessFitsFile
extends FitsFile

*********************************************************************** Represents a FitsFile which can be read from a RandomAccessFile data source. A random access data source allows you to skip over HDUs and then go back to read them later. So this class can take full advantage of the hints given to the getHDU methods. Note however that the "NEED_DATA_LATER" option is not currently well tested and may contain bugs. ************************************************************************


Field Summary
 
Fields inherited from class org.jscience.io.fits.FitsFile
BLOCK_SIZE, DATA_NOT_NEEDED, hdus, index, isComplete, NEED_DATA_LATER, NEED_DATA_NOW
 
Constructor Summary
RandomAccessFitsFile(java.io.RandomAccessFile file)
          *********************************************************************** Create a FITS file object which can be read from the given RandomAccessFile.
 
Method Summary
 FitsHDU getHDU(int number)
          *********************************************************************** returns an HDU specified by number.
 FitsHDU getHDU(int number, int when)
          *************************************************************************** Returns the given HDU, specifying a hint as to when to read the data.
 FitsHDU getHDU(java.lang.String name)
          *********************************************************************** returns an HDU specified by name.
 FitsHDU getHDU(java.lang.String name, int when)
          *********************************************************************** returns an HDU specified by name with a hint as to when to read the data.
 
Methods inherited from class org.jscience.io.fits.FitsFile
add, createEmpty, isComplete, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RandomAccessFitsFile

public RandomAccessFitsFile(java.io.RandomAccessFile file)
                     throws java.io.IOException
*********************************************************************** Create a FITS file object which can be read from the given RandomAccessFile.

Parameters:
file - the data source
Throws:
java.io.IOException - if there was trouble creating the FitsFile ************************************************************************
Method Detail

getHDU

public FitsHDU getHDU(int number)
               throws java.io.IOException
*********************************************************************** returns an HDU specified by number. The data for this HDU will have been read before this method returns. This method is the same as calling getHDU(int,int) with FitsFile.NEED_DATA_NOW.

Overrides:
getHDU in class FitsFile
Parameters:
number - the index of HDU to be read. The primary HDU is numbered 0. ************************************************************************
Returns:
The object representing the specified HDU.
Throws:
java.io.IOException - if there was trouble reading the specified HDU from a file. ************************************************************************

getHDU

public FitsHDU getHDU(int number,
                      int when)
               throws java.io.IOException
*************************************************************************** Returns the given HDU, specifying a hint as to when to read the data. Note that HDUs are not read from the underlying file until needed.

Overrides:
getHDU in class FitsFile
Parameters:
number - the index of HDU to be read. The primary HDU is numbered 0.
when - a hint as to when to read the data part of the HDU.
Returns:
the specified HDU. ****************************************************************************
Throws:
java.io.IOException - if there was trouble with the underlying I/O or with the FITS formating.
NoSuchFitsHDUException - if the file does not have the specified HDU.

getHDU

public FitsHDU getHDU(java.lang.String name)
               throws java.io.IOException
*********************************************************************** returns an HDU specified by name. This is the same as calling getHDU(String,int) with FitsFile.NEED_DATA_NOW

Overrides:
getHDU in class FitsFile
Parameters:
name - the EXTNAME value for the desired HDU or "PRIMARY" for the primary HDU.
Returns:
The named HDU.
Throws:
IOEXCEPTION - if there was a problem with the underlying I/O or the FITS format. ************************************************************************
java.io.IOException - if there was trouble reading the specified HDU from a file. ************************************************************************

getHDU

public FitsHDU getHDU(java.lang.String name,
                      int when)
               throws java.io.IOException
*********************************************************************** returns an HDU specified by name with a hint as to when to read the data.

Parameters:
name - the EXTNAME value for the desired HDU or "PRIMARY" for the primary HDU.
when - a hint as to when to read the data part of the HDU.
Throws:
IOEXCEPTION - if there was a problem with the underlying I/O or the FITS format.
NoSuchFitsHDUException - if the file does not have the named HDU ************************************************************************
java.io.IOException