uk.ac.starlink.fits
Class FitsTableBuilder

java.lang.Object
  |
  +--uk.ac.starlink.fits.FitsTableBuilder
All Implemented Interfaces:
TableBuilder

public class FitsTableBuilder
extends Object
implements TableBuilder

Implementation of the TableBuilder interface which gets StarTables from FITS files.


Constructor Summary
FitsTableBuilder()
           
 
Method Summary
static StarTable attemptReadTable(ArrayDataInput strm, boolean wantRandom, DataSource datsrc, long[] pos)
          Reads the next header, and if it represents a table HDU, makes a StarTable out of it and returns.
 boolean canImport(DataFlavor flavor)
          Returns true for a flavor with the MIME type "application/fits".
 StarTable makeStarTable(DataSource datsrc, boolean wantRandom)
          Creates a StarTable from a DataSource which refers to a FITS file or stream.
 void streamStarTable(InputStream istrm, TableSink sink, String extnum)
          Reads a FITS table from an input stream and writes it to a sink.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FitsTableBuilder

public FitsTableBuilder()
Method Detail

makeStarTable

public StarTable makeStarTable(DataSource datsrc,
                               boolean wantRandom)
                        throws IOException
Creates a StarTable from a DataSource which refers to a FITS file or stream. If the source has a position attribute, it will be interpreted as an integer indicating which HDU the table is in. The first HDU is number 0 (though being a primary HDU this one can't hold a table). If there is no position, the first HDU which does hold a table is used.

Specified by:
makeStarTable in interface TableBuilder
Parameters:
datsrc - the source of the FITS table data
wantRandom - whether a random-access table is preferred
Returns:
a new StarTable based on datsrc
IOException

canImport

public boolean canImport(DataFlavor flavor)
Returns true for a flavor with the MIME type "application/fits".

Specified by:
canImport in interface TableBuilder
Parameters:
flavor - the DataFlavor whose suitability as stream input is to be assessed
Returns:
true iff this builder reckons it stands a good chance of turning a stream of type flavor into a StarTable

streamStarTable

public void streamStarTable(InputStream istrm,
                            TableSink sink,
                            String extnum)
                     throws IOException
Reads a FITS table from an input stream and writes it to a sink.

Parameters:
istrm - input stream containing the FITS data
sink - destination for table data
extnum - may contain a string representation of the HDU number in which the required table is found (otherwise the first table HDU will be used)
IOException

attemptReadTable

public static StarTable attemptReadTable(ArrayDataInput strm,
                                         boolean wantRandom,
                                         DataSource datsrc,
                                         long[] pos)
                                  throws FitsException,
                                         IOException
Reads the next header, and if it represents a table HDU, makes a StarTable out of it and returns. If it is some other kind of HDU, null is returned. In either case, the stream is advanced the end of that HDU.

Parameters:
strm - stream to read from, positioned at the start of an HDU (before the header)
wantRandom - whether a random-access table is preferred
datsrc - a DataSource which can supply the data in strm
pos - a 1-element array holding the position in datsrc at which strm is positioned - it's an array so it can be updated by this routine (sorry)
Returns:
a StarTable made from the HDU at the start of strm or null
FitsException
IOException

Copyright © 2004 CLRC: Central Laboratory of the Research Councils. All rights reserved.