# Class StandardFitsTableSerializer

java.lang.Object
uk.ac.starlink.fits.StandardFitsTableSerializer

All Implemented Interfaces:
  `FitsTableSerializer`

Direct Known Subclasses:
  `VariableFitsTableSerializer`

public class StandardFitsTableSerializer extends Object implements FitsTableSerializer
Class which knows how to do the various bits of serializing a StarTable to FITS BINTABLE format. A normal (row-oriented) organisation of the data is used. Array-valued columns are all written as fixed size arrays. This class does the hard work for FitsTableWriter.

When writing tables that are marked up using the headers defined in `HealpixTableInfo`, this serializer will attempt to insert FITS headers corresponding to the HEALPix-FITS convention.

Author:
  Mark Taylor (Starlink)
See Also:
  - HEALPix-FITS convention

## Constructor Summary

Constructors
Constructor
Description
`StandardFitsTableSerializer(FitsTableSerializerConfig config, uk.ac.starlink.table.StarTable table)`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`String`
`getBadValue(int icol)`
Returns the bad value (text of the TNULLnn card), if any, used for a given column.
`FitsTableSerializerConfig`
`getConfig()`
Returns the configuration information for this serializer.
`int[]`
`getDimensions(int icol)`
Returns the dimensions of the items which will be output for a given column.
`char`
`getFormatChar(int icol)`
Returns the FITS TFORM letter which describes the type of data output for a given column.
`CardImage[]`
`getHeader()`
Returns header cards suitable for the HDU which will contain the table.
`protected CardImage[]`
`getHealpixHeaders(uk.ac.starlink.table.HealpixTableInfo hpxInfo)`
Returns FITS headers specific for a table containing a HEALPix map.
`long`
`getRowCount()`
Returns the number of rows which will be output.
`void`
`writeData(DataOutput strm)`
Writes the HDU data for the table to an output stream.
`long`
`writeDataOnly(DataOutput strm)`
Writes the table data content without any trailing padding.

### Methods inherited from class Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### StandardFitsTableSerializer

public StandardFitsTableSerializer(FitsTableSerializerConfig config, uk.ac.starlink.table.StarTable table) throws IOException
Constructor.

Parameters:
  `config` - configuration
  `table` - table to serialize
Throws:
  `IOException` - if it won't be possible to write the given table

## Method Details

### getConfig

public FitsTableSerializerConfig getConfig()
Returns the configuration information for this serializer.

Returns:
  config

### getHeader

public CardImage[] getHeader()
Description copied from interface: `FitsTableSerializer`
Returns header cards suitable for the HDU which will contain the table. Additional metadata and an END marker will be added after these cards, so the returned array must not contain the END card.

Specified by:
  `getHeader` in interface `FitsTableSerializer`
Returns:
  header cards

### writeData

public void writeData(DataOutput strm) throws IOException
Description copied from interface: `FitsTableSerializer`
Writes the HDU data for the table to an output stream. This is only intended to be called once following creation of this object. Subsequent calls result in undefined behaviour.

Specified by:
  `writeData` in interface `FitsTableSerializer`
Parameters:
  `strm` - destination stream
Throws:
  `IOException`

### writeDataOnly

public long writeDataOnly(DataOutput strm) throws IOException
Writes the table data content without any trailing padding.

Parameters:
  `strm` - destination stream
Returns:
  number of bytes written
Throws:
  `IOException`

### getFormatChar

public char getFormatChar(int icol)
Description copied from interface: `FitsTableSerializer`
Returns the FITS TFORM letter which describes the type of data output for a given column. This is as described by the FITS standard - 'J' for 4-byte integer, 'A' for characters, etc. If the column is not being output, `(char)0` will be returned.

Specified by:
  `getFormatChar` in interface `FitsTableSerializer`
Parameters:
  `icol` - column to query
Returns:
  format letter for data in column `icol`, or 0 for a column being skipped

### getDimensions

public int[] getDimensions(int icol)
Description copied from interface: `FitsTableSerializer`
Returns the dimensions of the items which will be output for a given column. This will be `null` only if that column is not being output. Otherwise it will be a zero-element array for a scalar, 1-element array for a vector, etc.

Specified by:
  `getDimensions` in interface `FitsTableSerializer`
Parameters:
  `icol` - column to query
Returns:
  dimensions array for data in column `icol` or `null` for a column being skipped

### getBadValue

public String getBadValue(int icol)
Description copied from interface: `FitsTableSerializer`
Returns the bad value (text of the TNULLnn card), if any, used for a given column.

Specified by:
  `getBadValue` in interface `FitsTableSerializer`
Parameters:
  `icol` - column to query
Returns:
  blank value string, or null if there is none or the column is being skipped

### getRowCount

public long getRowCount()
Description copied from interface: `FitsTableSerializer`
Returns the number of rows which will be output.

Specified by:
  `getRowCount` in interface `FitsTableSerializer`
Returns:
  row count

### getHealpixHeaders

protected CardImage[] getHealpixHeaders(uk.ac.starlink.table.HealpixTableInfo hpxInfo) throws uk.ac.starlink.table.TableFormatException
Returns FITS headers specific for a table containing a HEALPix map. If this method is called the assumption is that the table looks like it should be a HEALPix map of some sort. If there are problems with the metadata that prevent a consistent set of headers from being generated, a TableFormatException with an informative message should be thrown.

Parameters:
  `hpxInfo` - non-null healpix description
Returns:
  array of FITS headers describing healpix information
Throws:
  `uk.ac.starlink.table.TableFormatException`