uk.ac.starlink.fits
Class AbstractFitsTableWriter

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

public abstract class AbstractFitsTableWriter
extends StreamStarTableWriter

Abstract table writer superclass designed for writing FITS tables.

Since:
27 Jun 2006

Constructor Summary
protected AbstractFitsTableWriter(String formatName)
          Constructor.
 
Method Summary
protected  void addMetadata(nom.tam.fits.Header hdr)
          Adds some standard metadata header cards to a FITS header.
protected abstract  FitsTableSerializer createSerializer(StarTable table)
          Provides a suitable serializer for a given table.
static String getCurrentDate()
          Returns an ISO-8601 data string representing the time at which this method is called.
 String getFormatName()
          Gives the name of the format which is written by this writer.
 String getMimeType()
          Returns "application/fits".
 void setFormatName(String formatName)
          Sets the declared format name.
abstract  void writePrimaryHDU(StarTable table, FitsTableSerializer fitser, DataOutput out)
          Writes the primary HDU.
 void writeStarTable(StarTable table, OutputStream out)
          Writes a StarTable object to a given output stream.
 void writeTableHDU(StarTable table, FitsTableSerializer fitser, DataOutput out)
          Writes the 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
 

Constructor Detail

AbstractFitsTableWriter

protected AbstractFitsTableWriter(String formatName)
Constructor.

Parameters:
formatName - format name
Method Detail

getFormatName

public 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.

Returns:
a short string identifying the output format of this writer

setFormatName

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

Parameters:
formatName - format name

getMimeType

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

Returns:
MIME type

writeStarTable

public void writeStarTable(StarTable table,
                           OutputStream out)
                    throws IOException
Description copied from interface: StarTableWriter
Writes a StarTable object to a given output stream. The implementation can assume that out is suitable for direct writing (for instance it should not normally wrap it in a BufferedOutputStream), and should not close it at the end of the call.

Not all table writers are capable of writing to a stream; an implementation may throw a TableFormatException to indicate that it cannot do so.

Parameters:
table - the table to write
out - the output stream to which startab should be written
Throws:
IOException - if there is some I/O error

writePrimaryHDU

public abstract void writePrimaryHDU(StarTable table,
                                     FitsTableSerializer fitser,
                                     DataOutput out)
                              throws IOException
Writes the primary HDU. This cannot contain the table since BINTABLE HDUs can only be extensions.

Parameters:
table - the table which will be written into the next HDU
fitser - fits serializer initialised from table
out - destination stream
Throws:
IOException

writeTableHDU

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

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

createSerializer

protected abstract FitsTableSerializer createSerializer(StarTable table)
                                                 throws IOException
Provides a suitable serializer for a given table.

Parameters:
table - table to serialize
Returns:
FITS serializer
Throws:
IOException

addMetadata

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

Parameters:
hdr - header to modify

getCurrentDate

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

Returns:
date string

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