public abstract class AbstractFitsTableWriter extends StreamStarTableWriter implements MultiStarTableWriter
A couple of Auxiliary metadata items of the ColumnInfo metadata from written tables are respected:
Tables.NULL_VALUE_INFO
:
sets the value of TNULLn
"magic" blank value for
integer columnsTables.UBYTE_FLAG_INFO
:
if set to Boolean.TRUE
and if the column has content class
Short
or short[]
, 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.Modifier | Constructor and Description |
---|---|
protected |
AbstractFitsTableWriter(String formatName)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
protected abstract FitsTableSerializer |
createSerializer(StarTable table)
Provides a suitable serializer for a given table.
|
boolean |
getAllowSignedByte()
Returns a flag indicating how Byte-valued columns are written.
|
boolean |
getAllowZeroLengthString()
Indicates whether zero-length string columns may be output.
|
FitsTableSerializerConfig |
getConfig()
Returns the configuration details for writing FITS files.
|
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.
|
protected List<CardImage> |
getMetadataCards()
Adds some standard metadata header cards to a FITS table header.
|
String |
getMimeType()
Returns "application/fits".
|
byte |
getPadCharacter()
Returns the byte value with which under-length string (character array)
values will be padded.
|
WideFits |
getWide()
Indicates the convention in use for representing over-wide tables.
|
boolean |
getWriteDate()
Indicates whether a datestamp is written to output FITS files.
|
void |
setAllowSignedByte(boolean allowSignedByte)
Configures how Byte-valued columns are written.
|
void |
setAllowZeroLengthString(boolean allowZeroLengthString)
Sets whether zero-length string columns may be written.
|
void |
setFormatName(String formatName)
Sets the declared format name.
|
void |
setPadCharacter(byte padChar)
Sets the byte value with which under-length string (character array)
values should be padded.
|
void |
setWide(WideFits wide)
Sets the convention for representing over-wide (>999 column) tables.
|
void |
setWriteDate(boolean writeDate)
Configures whether a datestamp is written to output FITS files.
|
void |
writePrimaryHDU(OutputStream out)
Writes the primary HDU.
|
void |
writeStarTable(StarTable table,
OutputStream out)
Writes a single table.
|
void |
writeStarTables(TableSequence tableSeq,
OutputStream out)
Writes tables.
|
void |
writeStarTables(TableSequence tableSeq,
String location,
StarTableOutput sto)
|
void |
writeTableHDU(StarTable table,
FitsTableSerializer fitser,
OutputStream out)
Writes a data HDU.
|
writeStarTable, writeStarTable
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
looksLikeFile, writeStarTable
protected AbstractFitsTableWriter(String formatName)
formatName
- format namepublic String getFormatName()
StarTableWriter
getFormatName
in interface StarTableWriter
public void setFormatName(String formatName)
formatName
- format namepublic String getMimeType()
getMimeType
in interface StarTableWriter
public void writeStarTable(StarTable table, OutputStream out) throws IOException
writeStarTables(uk.ac.starlink.table.TableSequence, java.io.OutputStream)
.writeStarTable
in interface StarTableWriter
table
- the table to writeout
- the output stream to which startab
should be
writtenTableFormatException
- if this table cannot be written to a
streamIOException
- if there is some I/O errorpublic void writeStarTables(TableSequence tableSeq, OutputStream out) throws IOException
writePrimaryHDU(java.io.OutputStream)
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).writeStarTables
in interface MultiStarTableWriter
tableSeq
- sequence of tables to writeout
- destination streamIOException
public void writeStarTables(TableSequence tableSeq, String location, StarTableOutput sto) throws IOException
writeStarTables
in interface MultiStarTableWriter
tableSeq
- sequence of tables to writelocation
- destination for tablessto
- StarTableOutput instanceIOException
public void writePrimaryHDU(OutputStream out) throws IOException
out
- destination streamIOException
public void writeTableHDU(StarTable table, FitsTableSerializer fitser, OutputStream out) throws IOException
table
- the table to be written into the HDUfitser
- fits serializer initalised from table
out
- destination streamIOException
public FitsTableSerializerConfig getConfig()
ConfigMethod
s)
on this class.
This covers things that are generally orthogonal to the type
of serialization, so may be set for any kind of FITS output,
which is why it makes sense to manage them in the
AbstractFitsTableWriter
abstract superclass.protected abstract FitsTableSerializer createSerializer(StarTable table) throws IOException
table
- table to serializeIOException
- if the table can't be writtenprotected List<CardImage> getMetadataCards()
@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)
writeDate
- true to include DATE-HDU, false to omit itpublic boolean getWriteDate()
public void setAllowSignedByte(boolean allowSignedByte)
TFORMn='B'
, TZERO=-128
).
If false, they are written as FITS signed 16-bit integers.allowSignedByte
- true to write offset bytes,
false to write shortspublic boolean getAllowSignedByte()
public void setAllowZeroLengthString(boolean allowZeroLengthString)
TFORMn='0A'
) are explicitly permitted
by the FITS standard, but they can cause crashes because of
divide-by-zero errors when encountered by some versions of CFITSIO
(v3.50 and earlier), so FITS writing code may wish to avoid them.
If this is set false, then A repeat values will always be >=1.allowZeroLengthString
- false to prevent zero-length
string columnspublic boolean getAllowZeroLengthString()
public void setWide(WideFits wide)
wide
- wide-table representation policy,
null to avoid wide tablespublic WideFits getWide()
public void setPadCharacter(byte padChar)
padChar
- character data padding bytepublic byte getPadCharacter()
public static String getCurrentDate()
Copyright © 2024 Central Laboratory of the Research Councils. All Rights Reserved.