|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectuk.ac.starlink.fits.FitsTableBuilder
Implementation of the TableBuilder interface which gets StarTables from FITS files.
The table implementation used by uncompressed binary FITS tables
stored on disk maps the file into memory
(MappedByteBuffer
) rather than reading the stream as such;
this makes table construction very fast and cheap on memory, regardless of
storage policy. This behaviour can be inhibited by referring to the
file location as a URL (e.g. "file:spec23.fits" rather than "spec23.fits"),
which fools the handler into thinking that it can't be mapped.
Constructor Summary | |
FitsTableBuilder()
|
Method Summary | |
static StarTable |
attemptReadTable(nom.tam.util.ArrayDataInput strm,
boolean wantRandom,
DataSource datsrc,
long[] pos)
Reads the next header, and returns a StarTable based on it if it represents a table. |
boolean |
canImport(DataFlavor flavor)
Returns true for a flavor with the MIME type "application/fits". |
String |
getFormatName()
Returns "FITS". |
StarTable |
makeStarTable(DataSource datsrc,
boolean wantRandom,
StoragePolicy policy)
Creates a StarTable from a DataSource which refers to a FITS file or stream. |
StarTable[] |
makeStarTables(DataSource datsrc,
StoragePolicy policy)
Constructs an array of StarTables based on a given DataSource. |
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 |
public FitsTableBuilder()
Method Detail |
public String getFormatName()
getFormatName
in interface TableBuilder
public StarTable makeStarTable(DataSource datsrc, boolean wantRandom, StoragePolicy policy) throws IOException
makeStarTable
in interface TableBuilder
datsrc
- the source of the FITS table datawantRandom
- whether a random-access table is preferredpolicy
- a StoragePolicy object which may be used to
supply scratch storage if the builder needs it
IOException
- if an unexpected I/O error occurs during processingpublic StarTable[] makeStarTables(DataSource datsrc, StoragePolicy policy) throws IOException
MultiTableBuilder
TableFormatException
should be thrown. If this builder thinks it should be able to
handle the source but an error occurs during processing, an
IOException
can be thrown.
If the position
of the data source is not null,
then this method should return an array containing a single table,
the one which would be returned by the makeStarTable
method with that position.
makeStarTables
in interface MultiTableBuilder
datsrc
- the DataSource containing the table resourcepolicy
- a StoragePolicy object which may be used to
supply scratch storage if the builder needs it
datsrc
IOException
- if an unexpected I/O error occurs during processingpublic boolean canImport(DataFlavor flavor)
canImport
in interface TableBuilder
flavor
- the DataFlavor whose suitability as stream input
is to be assessed
public void streamStarTable(InputStream istrm, TableSink sink, String extnum) throws IOException
streamStarTable
in interface TableBuilder
istrm
- input stream containing the FITS datasink
- destination for table dataextnum
- 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
- if some other error occurspublic static StarTable attemptReadTable(nom.tam.util.ArrayDataInput strm, boolean wantRandom, DataSource datsrc, long[] pos) throws nom.tam.fits.FitsException, IOException
null
is
returned and the stream is advanced to the end of that HDU;
in this case the stream may continue to be used (e.g. for
further calls to this method).
On exit, the first element of the pos
array
contains the position after the current HDU.
strm
- stream to read from, positioned at the start of an HDU
(before the header)wantRandom
- whether a random-access table is preferreddatsrc
- a DataSource which can supply the data
in strmpos
- 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)
nom.tam.fits.FitsException
IOException
|
Copyright © 2004 CLRC: Central Laboratory of the Research Councils. All rights reserved. | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |