Package uk.ac.starlink.fits
Class AbstractFitsTableWriter
- java.lang.Object
-
- uk.ac.starlink.table.StreamStarTableWriter
-
- uk.ac.starlink.fits.AbstractFitsTableWriter
-
- All Implemented Interfaces:
uk.ac.starlink.table.MultiStarTableWriter,uk.ac.starlink.table.StarTableWriter
- Direct Known Subclasses:
ColFitsTableWriter,FitsTableWriter,HduFitsTableWriter,HealpixFitsTableWriter,VariableFitsTableWriter
public abstract class AbstractFitsTableWriter extends uk.ac.starlink.table.StreamStarTableWriter implements uk.ac.starlink.table.MultiStarTableWriterAbstract table writer superclass designed for writing FITS tables.A couple of Auxiliary metadata items of the ColumnInfo metadata from written tables are respected:
Tables.NULL_VALUE_INFO: sets the value ofTNULLn"magic" blank value for integer columnsTables.UBYTE_FLAG_INFO: if set toBoolean.TRUEand if the column has content classShortorshort[], the data will be written as unsigned bytes (TFORMn='B') not 16-bit signed integers (TFORMn='I').BintableStarTable.LONGOFF_INFO: if this is set to a string representation of an integer value, and the column has content class String or String[], then the data will be written as long integers (TFORMn='K') with the given offset (TZEROn=...). This option supports round-tripping of offset long values (typically representing unsigned longs) which are converted to strings on read.
- Since:
- 27 Jun 2006
- Author:
- Mark Taylor
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractFitsTableWriter(java.lang.String formatName)Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidaddMetadata(nom.tam.fits.Header hdr)Adds some standard metadata header cards to a FITS table header.protected abstract FitsTableSerializercreateSerializer(uk.ac.starlink.table.StarTable table)Provides a suitable serializer for a given table.static java.lang.StringgetCurrentDate()Returns an ISO-8601 data string representing the time at which this method is called.java.lang.StringgetFormatName()java.lang.StringgetMimeType()Returns "application/fits".booleangetWriteDate()Indicates whether a datestamp is written to output FITS files.voidsetFormatName(java.lang.String formatName)Sets the declared format name.voidsetWriteDate(boolean writeDate)Configures whether a datestamp is written to output FITS files.voidwritePrimaryHDU(java.io.DataOutput out)Writes the primary HDU.voidwriteStarTable(uk.ac.starlink.table.StarTable table, java.io.OutputStream out)Writes a single table.voidwriteStarTables(uk.ac.starlink.table.TableSequence tableSeq, java.io.OutputStream out)Writes tables.voidwriteStarTables(uk.ac.starlink.table.TableSequence tableSeq, java.lang.String location, uk.ac.starlink.table.StarTableOutput sto)voidwriteTableHDU(uk.ac.starlink.table.StarTable table, FitsTableSerializer fitser, java.io.DataOutput out)Writes a data HDU.-
Methods inherited from class uk.ac.starlink.table.StreamStarTableWriter
writeStarTable, writeStarTable
-
-
-
-
Method Detail
-
getFormatName
public java.lang.String getFormatName()
- Specified by:
getFormatNamein interfaceuk.ac.starlink.table.StarTableWriter
-
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:
getMimeTypein interfaceuk.ac.starlink.table.StarTableWriter- Returns:
- MIME type
-
writeStarTable
public void writeStarTable(uk.ac.starlink.table.StarTable table, java.io.OutputStream out) throws java.io.IOExceptionWrites a single table. InvokeswriteStarTables(uk.ac.starlink.table.TableSequence, java.io.OutputStream).- Specified by:
writeStarTablein interfaceuk.ac.starlink.table.StarTableWriter- Throws:
java.io.IOException
-
writeStarTables
public void writeStarTables(uk.ac.starlink.table.TableSequence tableSeq, java.io.OutputStream out) throws java.io.IOExceptionWrites tables. CallswritePrimaryHDU(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:
writeStarTablesin interfaceuk.ac.starlink.table.MultiStarTableWriter- Throws:
java.io.IOException
-
writeStarTables
public void writeStarTables(uk.ac.starlink.table.TableSequence tableSeq, java.lang.String location, uk.ac.starlink.table.StarTableOutput sto) throws java.io.IOException- Specified by:
writeStarTablesin interfaceuk.ac.starlink.table.MultiStarTableWriter- Throws:
java.io.IOException
-
writePrimaryHDU
public void writePrimaryHDU(java.io.DataOutput out) throws java.io.IOExceptionWrites 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(uk.ac.starlink.table.StarTable table, FitsTableSerializer fitser, java.io.DataOutput out) throws java.io.IOExceptionWrites a data HDU.- Parameters:
table- the table to be written into the HDUfitser- fits serializer initalised fromtableout- destination stream- Throws:
java.io.IOException
-
createSerializer
protected abstract FitsTableSerializer createSerializer(uk.ac.starlink.table.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
-
setWriteDate
@ConfigMethod(property="date", doc="<p>If true, the DATE-HDU header is filled in with the current date; otherwise it is not included.</p>") public void setWriteDate(boolean writeDate)Configures whether a datestamp is written to output FITS files.- Parameters:
writeDate- true to include DATE-HDU, false to omit it
-
getWriteDate
public boolean getWriteDate()
Indicates whether a datestamp is written to output FITS files.- Returns:
- true to include DATE-HDU, false to omit it
-
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
-
-