public class FitsTableBuilder
extends java.lang.Object
implements uk.ac.starlink.table.TableBuilder, uk.ac.starlink.table.MultiTableBuilder
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 and Description |
---|
FitsTableBuilder() |
Modifier and Type | Method and Description |
---|---|
static uk.ac.starlink.table.StarTable |
attemptReadTable(nom.tam.util.ArrayDataInput strm,
boolean wantRandom,
uk.ac.starlink.util.DataSource datsrc,
long[] pos)
Reads the next header, and returns a StarTable based on it if it
represents a table.
|
boolean |
canImport(java.awt.datatransfer.DataFlavor flavor)
Returns true for a flavor with the MIME type "application/fits".
|
static uk.ac.starlink.table.StarTable |
findNamedTable(nom.tam.util.ArrayDataInput strm,
uk.ac.starlink.util.DataSource datsrc,
java.lang.String name,
long[] pos)
Looks through the HDUs in a given FITS stream and if it finds
one which has a given name, attempts to make a table out of it.
|
java.lang.String |
getFormatName()
Returns "FITS".
|
uk.ac.starlink.table.StarTable |
makeStarTable(uk.ac.starlink.util.DataSource datsrc,
boolean wantRandom,
uk.ac.starlink.table.StoragePolicy policy)
Creates a StarTable from a DataSource which refers to a FITS
file or stream.
|
uk.ac.starlink.table.TableSequence |
makeStarTables(uk.ac.starlink.util.DataSource datsrc,
uk.ac.starlink.table.StoragePolicy policy) |
void |
streamStarTable(java.io.InputStream istrm,
uk.ac.starlink.table.TableSink sink,
java.lang.String extnum)
Reads a FITS table from an input stream and writes it to a sink.
|
public java.lang.String getFormatName()
getFormatName
in interface uk.ac.starlink.table.TableBuilder
public uk.ac.starlink.table.StarTable makeStarTable(uk.ac.starlink.util.DataSource datsrc, boolean wantRandom, uk.ac.starlink.table.StoragePolicy policy) throws java.io.IOException
If the EXTNAME happens to be in the form of a positive integer, this means you can't refer to the extension by name. Too bad.
If there is no position attribute, the first HDU which does hold a table is used.
makeStarTable
in interface uk.ac.starlink.table.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 itjava.io.IOException
public uk.ac.starlink.table.TableSequence makeStarTables(uk.ac.starlink.util.DataSource datsrc, uk.ac.starlink.table.StoragePolicy policy) throws java.io.IOException
makeStarTables
in interface uk.ac.starlink.table.MultiTableBuilder
java.io.IOException
public boolean canImport(java.awt.datatransfer.DataFlavor flavor)
canImport
in interface uk.ac.starlink.table.TableBuilder
public void streamStarTable(java.io.InputStream istrm, uk.ac.starlink.table.TableSink sink, java.lang.String extnum) throws java.io.IOException
streamStarTable
in interface uk.ac.starlink.table.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)java.io.IOException
public static uk.ac.starlink.table.StarTable findNamedTable(nom.tam.util.ArrayDataInput strm, uk.ac.starlink.util.DataSource datsrc, java.lang.String name, long[] pos) throws nom.tam.fits.FitsException, java.io.IOException
name
is checked against the EXTNAME
header value (if present), and if that fails, against EXTNAME-EXTVER
(if EXTVER is present too). Matching is case-insensitive.strm
- stream to read from, positioned at the start of an HDU
(before the header)datsrc
- a DataSource which can supply the data
in strmname
- target extension name or name-versionpos
- 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
java.io.IOException
public static uk.ac.starlink.table.StarTable attemptReadTable(nom.tam.util.ArrayDataInput strm, boolean wantRandom, uk.ac.starlink.util.DataSource datsrc, long[] pos) throws nom.tam.fits.FitsException, java.io.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
java.io.IOException
Copyright © 2017 Central Laboratory of the Research Councils. All Rights Reserved.