# Class IpacTableWriter

java.lang.Object
uk.ac.starlink.table.formats.DocumentedStreamStarTableWriter
uk.ac.starlink.table.formats.AbstractTextTableWriter
uk.ac.starlink.table.formats.IpacTableWriter

All Implemented Interfaces:
  `Documented, DocumentedIOHandler, StarTableWriter`

public class IpacTableWriter extends AbstractTextTableWriter
A StarTableWriter which writes to the IPAC text format. The data format is defined at http://irsa.ipac.caltech.edu/applications/DDGEN/Doc/ipac_tbl.html.

Since:
  20 Sep 2012
Author:
  Mark Taylor

## Field Summary

Fields
Modifier and Type
Field
Description
`static String`
`NULL`
String representation for null values.

## Constructor Summary

Constructors
Constructor
Description
`IpacTableWriter()`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`boolean`
`docIncludesExample()`
Indicates whether the serialization of some (short) example table should be added to the user documentation for this handler.
`String`
`formatValue(Object val, ValueInfo info, int width)`
Formats a data value for output.
`String`
`getFormatName()`
Returns "IPAC".
`String`
`getMimeType()`
Returns "text/plain".
`int`
`getMinNameWidth(ColumnInfo info)`
Returns the minimum width required to output the actual characters of the name for a given column.
`String`
`getXmlDescription()`
Returns user-directed documentation in XML format.
`void`
`printColumnHeads(OutputStream out, int[] colwidths, ColumnInfo[] cinfos)`
Outputs headings for the table columns.
`protected void`
`printLine(OutputStream out, int[] colwidths, String[] data)`
Outputs a line of table data.
`protected void`
`printParam(OutputStream out, String name, String value, Class<?> clazz)`
Outputs a parameter and its value.
`protected void`
`printSeparator(OutputStream out, int[] colwidths)`
Outputs a decorative separator line, of the sort you might find between the column headings and the table data.

### Methods inherited from class AbstractTextTableWriter

`getBytes, getMaximumParameterLength, getMaxWidth, getSampledRows, getWriteParameters, setMaximumParameterLength, setMaxWidth, setSampledRows, setWriteParameters, writeStarTable`

### Methods inherited from class DocumentedStreamStarTableWriter

`getExtensions, looksLikeFile, writeStarTable`

### Methods inherited from class Object

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

### Methods inherited from interface DocumentedIOHandler

`readText`

## Field Details

### NULL

public static String NULL
String representation for null values.

## Constructor Details

### IpacTableWriter

public IpacTableWriter()
Constructor.

## Method Details

### getFormatName

public String getFormatName()
Returns "IPAC".

Specified by:
  `getFormatName` in interface `StarTableWriter`
Overrides:
  `getFormatName` in class `AbstractTextTableWriter`
Returns:
  "text"

### docIncludesExample

public boolean docIncludesExample()
Description copied from interface: `DocumentedIOHandler`
Indicates whether the serialization of some (short) example table should be added to the user documentation for this handler. Binary formats, or instances for which the `Documented.getXmlDescription()` method already includes some example output, should return false.

Returns:
  true if the user documentation would benefit from the addition of an example serialization

### getXmlDescription

public String getXmlDescription()
Description copied from interface: `Documented`
Returns user-directed documentation in XML format.

The output should be a sequence of one or more <P> elements, using XHTML-like XML. Since rendering may be done in a number of contexts however, use of the full range of XHTML elements is discouraged. Where possible, the content should stick to simple markup such as the elements P, A, UL, OL, LI, DL, DT, DD EM, STRONG, I, B, CODE, TT, PRE.

Returns:
  XML description of this object

### getMimeType

public String getMimeType()
Returns "text/plain".

Specified by:
  `getMimeType` in interface `StarTableWriter`
Overrides:
  `getMimeType` in class `AbstractTextTableWriter`
Returns:
  MIME content type

### getMinNameWidth

public int getMinNameWidth(ColumnInfo info)
Description copied from class: `AbstractTextTableWriter`
Returns the minimum width required to output the actual characters of the name for a given column. Padding applied subsequently by this object's `AbstractTextTableWriter.printColumnHeads(OutputStream, int[], ColumnInfo[])` method does not need to be included.

Overrides:
  `getMinNameWidth` in class `AbstractTextTableWriter`
Parameters:
  `info` - column metadata
Returns:
  minimum number of characters required for column title

### formatValue

public String formatValue(Object val, ValueInfo info, int width)
Description copied from class: `AbstractTextTableWriter`
Formats a data value for output.

Specified by:
  `formatValue` in class `AbstractTextTableWriter`
Parameters:
  `val` - the value
  `info` - the metadata object describing `val`'s type
  `width` - maximum preferred width into which the value should be formatted
Returns:
  formatted string meaning `value`, preferably no longer than `width` characters

### printColumnHeads

public void printColumnHeads(OutputStream out, int[] colwidths, ColumnInfo[] cinfos) throws IOException
Description copied from class: `AbstractTextTableWriter`
Outputs headings for the table columns.

Specified by:
  `printColumnHeads` in class `AbstractTextTableWriter`
Parameters:
  `out` - stream to write into
  `colwidths` - column widths in characters
  `cinfos` - array of column headings
Throws:
  `IOException`

### printLine

protected void printLine(OutputStream out, int[] colwidths, String[] data) throws IOException
Description copied from class: `AbstractTextTableWriter`
Outputs a line of table data.

Specified by:
  `printLine` in class `AbstractTextTableWriter`
Parameters:
  `out` - stream to write into
  `colwidths` - column widths in characters
  `data` - array of strings to be output, one per column
Throws:
  `IOException`

### printSeparator

protected void printSeparator(OutputStream out, int[] colwidths)
Description copied from class: `AbstractTextTableWriter`
Outputs a decorative separator line, of the sort you might find between the column headings and the table data.

Specified by:
  `printSeparator` in class `AbstractTextTableWriter`
Parameters:
  `out` - stream to write into
  `colwidths` - column widths in characters

### printParam

protected void printParam(OutputStream out, String name, String value, Class<?> clazz) throws IOException
Description copied from class: `AbstractTextTableWriter`
Outputs a parameter and its value.

Specified by:
  `printParam` in class `AbstractTextTableWriter`
Parameters:
  `out` - stream to write into
  `name` - parameter name
  `value` - formatted parameter value
  `clazz` - type of value
Throws:
  `IOException`