The table input and output facilities of STIL are handled
by format-specific input and output handlers;
supplied with the package are, amongst others, a VOTable input
handler and output handler, and this means that STIL can read
and write tables in VOTable format. An input handler is
an object which can turn an external resource into a
StarTable
object, and an output handler is one
which can take a StarTable
object and store it
externally in some way.
These handlers are independent components of the system, and
so new ones can be written, allowing all the STIL features
to be used on new table formats without having to make any changes
to the core classes of the library.
There are two ways of using these handlers.
You can either use them directly to read in/write out a table
using a particular format, or you can use the generic I/O facilities
which know about several of these handlers and select an appropriate
one at run time. The generic reader class is
StarTableFactory
,
and will offer a given stream of bytes to all the handlers it
knows about until one of them can turn it into a table;
the generic writer class is
StarTableOutput
,
and will write in a format determined by the filename
or a format string which might be selected by the user at runtime.
The generic approach is more flexible in a multi-format
environment, but if you know what format you want to deal with
then not much is gained by using it.
By way of example: here is how you can load a table which might be in any of the supported formats:
StarTable table = new StarTableFactory().makeStarTable( filename );and here is how you can do it if you know that it's in FITS format:
DataSource datsrc = new FileDataSource( filename ); StarTable table = new FitsTableBuilder().makeStarTable( datsrc, false );
The following sections describe in more detail the generic input and output facilities, followed by descriptions of each of the format-specific I/O handlers which are supplied with the package. There is an additional section (section 3.6) which deals with table reading and writing using an SQL database.