uk.ac.starlink.fits
Class AbstractFitsTableWriter

java.lang.Object
  extended by uk.ac.starlink.table.StreamStarTableWriter
      extended by uk.ac.starlink.fits.AbstractFitsTableWriter
All Implemented Interfaces:
MultiStarTableWriter, StarTableWriter
Direct Known Subclasses:
ColFitsTableWriter, FitsTableWriter, HduFitsTableWriter, HealpixFitsTableWriter, VariableFitsTableWriter, VOTableFitsTableWriter

public abstract class AbstractFitsTableWriter
extends StreamStarTableWriter
implements MultiStarTableWriter

Abstract table writer superclass designed for writing FITS tables.

A couple of Auxiliary metadata items of the ColumnInfo metadata from written tables are respected:

Since:
27 Jun 2006

Constructor Summary
protected AbstractFitsTableWriter(java.lang.String formatName)
          Constructor.
 
Method Summary
protected  void addMetadata(nom.tam.fits.Header hdr)
          Adds some standard metadata header cards to a FITS table header.
protected abstract  FitsTableSerializer createSerializer(StarTable table)
          Provides a suitable serializer for a given table.
static java.lang.String getCurrentDate()
          Returns an ISO-8601 data string representing the time at which this method is called.
 java.lang.String getFormatName()
          Gives the name of the format which is written by this writer.
 java.lang.String getMimeType()
          Returns "application/fits".
 void setFormatName(java.lang.String formatName)
          Sets the declared format name.
 void writePrimaryHDU(java.io.DataOutput out)
          Writes the primary HDU.
 void writeStarTable(StarTable table, java.io.OutputStream out)
          Writes a single table.
 void writeStarTables(TableSequence tableSeq, java.io.OutputStream out)
          Writes tables.
 void writeStarTables(TableSequence tableSeq, java.lang.String location, StarTableOutput sto)
          Invokes writeStarTables(uk.ac.starlink.table.TableSequence, java.io.OutputStream).
 void writeTableHDU(StarTable table, FitsTableSerializer fitser, java.io.DataOutput out)
          Writes a data HDU.
 
Methods inherited from class uk.ac.starlink.table.StreamStarTableWriter
writeStarTable
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface uk.ac.starlink.table.StarTableWriter
looksLikeFile, writeStarTable
 

Constructor Detail

AbstractFitsTableWriter

protected AbstractFitsTableWriter(java.lang.String formatName)
Constructor.

Parameters:
formatName - format name
Method Detail

getFormatName

public java.lang.String getFormatName()
Description copied from interface: StarTableWriter
Gives the name of the format which is written by this writer. Matching against this string may be used by callers to identify or select this writer from a list.

Specified by:
getFormatName in interface StarTableWriter
Returns:
a short string identifying the output format of this writer

setFormatName

public void setFormatName(java.lang.String formatName)
Sets the declared format name.

Parameters:
formatName - format name

getMimeType

public java.lang.String getMimeType()
Returns "application/fits".

Specified by:
getMimeType in interface StarTableWriter
Returns:
MIME type

writeStarTable

public void writeStarTable(StarTable table,
                           java.io.OutputStream out)
                    throws java.io.IOException
Writes a single table. Invokes writeStarTables(uk.ac.starlink.table.TableSequence, java.io.OutputStream).

Specified by:
writeStarTable in interface StarTableWriter
Parameters:
table - the table to write
out - the output stream to which startab should be written
Throws:
TableFormatException - if this table cannot be written to a stream
java.io.IOException - if there is some I/O error

writeStarTables

public void writeStarTables(TableSequence tableSeq,
                            java.io.OutputStream out)
                     throws java.io.IOException
Writes tables. Calls writePrimaryHDU(java.io.DataOutput) to write the primary HDU. Subclasses which want to put something related to the input tables into the primary HDU will need to override this method (writeStarTables).

Specified by:
writeStarTables in interface MultiStarTableWriter
Parameters:
tableSeq - sequence of tables to write
out - destination stream
Throws:
java.io.IOException

writeStarTables

public void writeStarTables(TableSequence tableSeq,
                            java.lang.String location,
                            StarTableOutput sto)
                     throws java.io.IOException
Invokes writeStarTables(uk.ac.starlink.table.TableSequence, java.io.OutputStream).

Specified by:
writeStarTables in interface MultiStarTableWriter
Parameters:
tableSeq - sequence of tables to write
location - destination for tables
sto - StarTableOutput instance
Throws:
java.io.IOException

writePrimaryHDU

public void writePrimaryHDU(java.io.DataOutput out)
                     throws java.io.IOException
Writes the primary HDU. This cannot contain a table since BINTABLE HDUs can only be extensions. The AbstractFitsTableWriter implementation writes a minimal, data-less HDU.

Parameters:
out - destination stream
Throws:
java.io.IOException

writeTableHDU

public void writeTableHDU(StarTable table,
                          FitsTableSerializer fitser,
                          java.io.DataOutput out)
                   throws java.io.IOException
Writes a data HDU.

Parameters:
table - the table to be written into the HDU
fitser - fits serializer initalised from table
out - destination stream
Throws:
java.io.IOException

createSerializer

protected abstract FitsTableSerializer createSerializer(StarTable table)
                                                 throws java.io.IOException
Provides a suitable serializer for a given table. Note this should throw an IOException if it can be determined that the submitted table cannot be written by this writer, for instance if it has too many columns.

Parameters:
table - table to serialize
Returns:
FITS serializer
Throws:
java.io.IOException - if the table can't be written

addMetadata

protected void addMetadata(nom.tam.fits.Header hdr)
Adds some standard metadata header cards to a FITS table header. This includes date stamp, STIL version, etc.

Parameters:
hdr - header to modify

getCurrentDate

public static java.lang.String getCurrentDate()
Returns an ISO-8601 data string representing the time at which this method is called.

Returns:
date string