Package uk.ac.starlink.table.formats
Class AsciiTableWriter
- java.lang.Object
-
- uk.ac.starlink.table.formats.DocumentedStreamStarTableWriter
-
- uk.ac.starlink.table.formats.AbstractTextTableWriter
-
- uk.ac.starlink.table.formats.AsciiTableWriter
-
- All Implemented Interfaces:
Documented,DocumentedIOHandler,StarTableWriter
public class AsciiTableWriter extends AbstractTextTableWriter
A StarTableWriter which outputs text to a simple format machine-readable text file. This format is suitable for reading usingAsciiStarTableandAsciiTableBuilder.- Since:
- 29 Mar 2004
- Author:
- Mark Taylor (Starlink)
-
-
Constructor Summary
Constructors Constructor Description AsciiTableWriter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleandocIncludesExample()Indicates whether the serialization of some (short) example table should be added to the user documentation for this handler.protected java.lang.StringformatValue(java.lang.Object val, ValueInfo vinfo, int width)Formats a data value for output.java.lang.StringgetFormatName()Returns "ascii".java.lang.StringgetXmlDescription()Returns user-directed documentation in XML format.protected voidprintColumnHeads(java.io.OutputStream strm, int[] colwidths, ColumnInfo[] cinfos)Outputs headings for the table columns.protected voidprintLine(java.io.OutputStream strm, int[] colwidths, java.lang.String[] data)Outputs a line of table data.protected voidprintParam(java.io.OutputStream strm, java.lang.String name, java.lang.String value, java.lang.Class<?> clazz)Outputs a parameter and its value.protected voidprintSeparator(java.io.OutputStream strm, 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, getMaximumParameterLength, getMaxWidth, getMimeType, getMinNameWidth, getSampledRows, getWriteParameters, setMaximumParameterLength, setMaxWidth, setSampledRows, setWriteParameters, writeStarTable
-
Methods inherited from class uk.ac.starlink.table.formats.DocumentedStreamStarTableWriter
getExtensions, looksLikeFile, writeStarTable
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface uk.ac.starlink.table.formats.DocumentedIOHandler
readText
-
-
-
-
Method Detail
-
formatValue
protected java.lang.String formatValue(java.lang.Object val, ValueInfo vinfo, int width)Description copied from class:AbstractTextTableWriterFormats a data value for output.- Specified by:
formatValuein classAbstractTextTableWriter- Parameters:
val- the valuevinfo- 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
-
getFormatName
public java.lang.String getFormatName()
Returns "ascii".- Specified by:
getFormatNamein interfaceStarTableWriter- Overrides:
getFormatNamein classAbstractTextTableWriter- Returns:
- output format
-
docIncludesExample
public boolean docIncludesExample()
Description copied from interface:DocumentedIOHandlerIndicates whether the serialization of some (short) example table should be added to the user documentation for this handler. Binary formats, or instances for which theDocumented.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 java.lang.String getXmlDescription()
Description copied from interface:DocumentedReturns 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
-
printSeparator
protected void printSeparator(java.io.OutputStream strm, 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:
strm- stream to write intocolwidths- column widths in characters
-
printLine
protected void printLine(java.io.OutputStream strm, int[] colwidths, java.lang.String[] data) throws java.io.IOExceptionDescription copied from class:AbstractTextTableWriterOutputs a line of table data.- Specified by:
printLinein classAbstractTextTableWriter- Parameters:
strm- stream to write intocolwidths- column widths in charactersdata- array of strings to be output, one per column- Throws:
java.io.IOException
-
printColumnHeads
protected void printColumnHeads(java.io.OutputStream strm, int[] colwidths, ColumnInfo[] cinfos) throws java.io.IOExceptionDescription copied from class:AbstractTextTableWriterOutputs headings for the table columns.- Specified by:
printColumnHeadsin classAbstractTextTableWriter- Parameters:
strm- stream to write intocolwidths- column widths in characterscinfos- array of column headings- Throws:
java.io.IOException
-
printParam
protected void printParam(java.io.OutputStream strm, 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:
strm- stream to write intoname- parameter namevalue- formatted parameter valueclazz- type of value- Throws:
java.io.IOException
-
-