Package uk.ac.starlink.table.formats
Class IpacTableWriter
- java.lang.Object
-
- uk.ac.starlink.table.StreamStarTableWriter
-
- uk.ac.starlink.table.formats.AbstractTextTableWriter
-
- uk.ac.starlink.table.formats.IpacTableWriter
-
- All Implemented Interfaces:
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 java.lang.StringNULLString representation for null values.
-
Constructor Summary
Constructors Constructor Description IpacTableWriter()Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringformatValue(java.lang.Object val, ValueInfo info, int width)Formats a data value for output.java.lang.StringgetFormatName()Returns "IPAC".protected intgetMaximumParameterLength()The comments parameter may be many lines long.intgetMaxWidth()Returns the maximum width for a given column.java.lang.StringgetMimeType()Returns "text/plain".intgetMinNameWidth(ColumnInfo info)Returns the minimum width required to output the actual characters of the name for a given column.booleanlooksLikeFile(java.lang.String location)Returns true for files with extension ".ipac" or ".tbl".voidprintColumnHeads(java.io.OutputStream out, int[] colwidths, ColumnInfo[] cinfos)Outputs headings for the table columns.protected voidprintLine(java.io.OutputStream out, int[] colwidths, java.lang.String[] data)Outputs a line of table data.protected voidprintParam(java.io.OutputStream out, java.lang.String name, java.lang.String value, java.lang.Class<?> clazz)Outputs a parameter and its value.protected voidprintSeparator(java.io.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 uk.ac.starlink.table.formats.AbstractTextTableWriter
getBytes, getSampledRows, getWriteParameters, setWriteParameters, writeStarTable
-
Methods inherited from class uk.ac.starlink.table.StreamStarTableWriter
writeStarTable
-
-
-
-
Method Detail
-
getFormatName
public java.lang.String getFormatName()
Returns "IPAC".- Specified by:
getFormatNamein interfaceStarTableWriter- Overrides:
getFormatNamein classAbstractTextTableWriter- Returns:
- "text"
-
getMimeType
public java.lang.String getMimeType()
Returns "text/plain".- Specified by:
getMimeTypein interfaceStarTableWriter- Overrides:
getMimeTypein classAbstractTextTableWriter- Returns:
- MIME content type
-
looksLikeFile
public boolean looksLikeFile(java.lang.String location)
Returns true for files with extension ".ipac" or ".tbl".- Parameters:
location- the location name (probably filename)- Returns:
- true iff it looks like a file this writer would normally write
-
getMaxWidth
public int getMaxWidth()
Description copied from class:AbstractTextTableWriterReturns the maximum width for a given column. Values longer than this may be truncated.- Specified by:
getMaxWidthin classAbstractTextTableWriter- Returns:
- maximum permitted column width in characters
-
getMinNameWidth
public int getMinNameWidth(ColumnInfo info)
Description copied from class:AbstractTextTableWriterReturns the minimum width required to output the actual characters of the name for a given column. Padding applied subsequently by this object'sAbstractTextTableWriter.printColumnHeads(java.io.OutputStream, int[], uk.ac.starlink.table.ColumnInfo[])method does not need to be included.- Overrides:
getMinNameWidthin classAbstractTextTableWriter- Parameters:
info- column metadata- Returns:
- minimum number of characters required for column title
-
formatValue
public java.lang.String formatValue(java.lang.Object val, ValueInfo info, int width)Description copied from class:AbstractTextTableWriterFormats a data value for output.- Specified by:
formatValuein classAbstractTextTableWriter- Parameters:
val- the valueinfo- the metadata object describing val's typewidth- 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(java.io.OutputStream out, int[] colwidths, ColumnInfo[] cinfos) throws java.io.IOExceptionDescription copied from class:AbstractTextTableWriterOutputs headings for the table columns.- Specified by:
printColumnHeadsin classAbstractTextTableWriter- Parameters:
out- stream to write intocolwidths- column widths in characterscinfos- array of column headings- Throws:
java.io.IOException
-
printLine
protected void printLine(java.io.OutputStream out, int[] colwidths, java.lang.String[] data) throws java.io.IOExceptionDescription copied from class:AbstractTextTableWriterOutputs a line of table data.- Specified by:
printLinein classAbstractTextTableWriter- Parameters:
out- stream to write intocolwidths- column widths in charactersdata- array of strings to be output, one per column- Throws:
java.io.IOException
-
printSeparator
protected void printSeparator(java.io.OutputStream out, int[] colwidths)Description copied from class:AbstractTextTableWriterOutputs a decorative separator line, of the sort you might find between the column headings and the table data.- Specified by:
printSeparatorin classAbstractTextTableWriter- Parameters:
out- stream to write intocolwidths- column widths in characters
-
printParam
protected void printParam(java.io.OutputStream out, java.lang.String name, java.lang.String value, java.lang.Class<?> clazz) throws java.io.IOExceptionDescription copied from class:AbstractTextTableWriterOutputs a parameter and its value.- Specified by:
printParamin classAbstractTextTableWriter- Parameters:
out- stream to write intoname- parameter namevalue- formatted parameter valueclazz- type of value- Throws:
java.io.IOException
-
getMaximumParameterLength
protected int getMaximumParameterLength()
The comments parameter may be many lines long.- Overrides:
getMaximumParameterLengthin classAbstractTextTableWriter- Returns:
- maximum length for output string parameters
-
-