public class TextTableWriter extends AbstractTextTableWriter implements MultiStarTableWriter
StarTableWriter
which outputs text to
a human-readable text file.
Table parameters (per-table metadata) can optionally be output
as well as the table data themselves.Constructor and Description |
---|
TextTableWriter() |
Modifier and Type | Method and Description |
---|---|
boolean |
docIncludesExample()
Indicates whether the serialization of some (short) example table
should be added to the user documentation for this handler.
|
protected String |
formatValue(Object val,
ValueInfo vinfo,
int width)
Formats a data value for output.
|
String |
getFormatName()
Returns "text";
|
String |
getMimeType()
Returns a string suitable for use as the value of a MIME
Content-Type header.
|
String |
getXmlDescription()
Returns user-directed documentation in XML format.
|
boolean |
looksLikeFile(String location)
Returns true if the location argument is equal to "-",
indicating standard output.
|
protected void |
printColumnHeads(OutputStream strm,
int[] colwidths,
ColumnInfo[] cinfos)
Outputs headings for the table columns.
|
protected void |
printLine(OutputStream strm,
int[] colwidths,
String[] data)
Outputs a line of table data.
|
protected void |
printParam(OutputStream strm,
String name,
String value,
Class<?> clazz)
Outputs a parameter and its value.
|
protected void |
printSeparator(OutputStream strm,
int[] colwidths)
Outputs a decorative separator line, of the sort you might find
between the column headings and the table data.
|
void |
writeStarTables(TableSequence tableSeq,
OutputStream out)
Writes an array of StarTable objects to a given output stream.
|
void |
writeStarTables(TableSequence tableSeq,
String location,
StarTableOutput sto)
Writes an array of StarTable objects to a given location.
|
getBytes, getMaximumParameterLength, getMaxWidth, getMinNameWidth, getSampledRows, getWriteParameters, setMaximumParameterLength, setMaxWidth, setSampledRows, setWriteParameters, writeStarTable
getExtensions, writeStarTable
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
writeStarTable, writeStarTable
matchesExtension, readText, toLink
public String getFormatName()
getFormatName
in interface StarTableWriter
getFormatName
in class AbstractTextTableWriter
public String getMimeType()
StarTableWriter
application/octet-stream
"
(for binary formats) or "text/plain
" for ASCII ones)
is recommended.getMimeType
in interface StarTableWriter
getMimeType
in class AbstractTextTableWriter
public boolean docIncludesExample()
DocumentedIOHandler
Documented.getXmlDescription()
method already includes some example output, should return false.docIncludesExample
in interface DocumentedIOHandler
public String getXmlDescription()
Documented
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.
getXmlDescription
in interface Documented
public boolean looksLikeFile(String location)
looksLikeFile
in interface StarTableWriter
looksLikeFile
in class DocumentedStreamStarTableWriter
location
- the location name (probably filename)true
iff it looks like a file this writer would
normally writepublic void writeStarTables(TableSequence tableSeq, OutputStream out) throws IOException
MultiStarTableWriter
BufferedOutputStream
), and should not close it at
the end of the call.writeStarTables
in interface MultiStarTableWriter
tableSeq
- sequence of tables to writeout
- destination streamIOException
public void writeStarTables(TableSequence tableSeq, String location, StarTableOutput sto) throws IOException
MultiStarTableWriter
location
argument
in any way appropriate for them. Typically however the location
will simply be used to get an output stream (for instance interpreting
it as a filename). In this case the sto
argument should
normally be used to turn location
into a stream.writeStarTables
in interface MultiStarTableWriter
tableSeq
- sequence of tables to writelocation
- destination for tablessto
- StarTableOutput instanceIOException
protected String formatValue(Object val, ValueInfo vinfo, int width)
AbstractTextTableWriter
formatValue
in class AbstractTextTableWriter
val
- the valuevinfo
- the metadata object describing val
's typewidth
- maximum preferred width into which the value should
be formattedvalue
,
preferably no longer than width
charactersprotected void printSeparator(OutputStream strm, int[] colwidths) throws IOException
AbstractTextTableWriter
printSeparator
in class AbstractTextTableWriter
strm
- stream to write intocolwidths
- column widths in charactersIOException
protected void printColumnHeads(OutputStream strm, int[] colwidths, ColumnInfo[] cinfos) throws IOException
AbstractTextTableWriter
printColumnHeads
in class AbstractTextTableWriter
strm
- stream to write intocolwidths
- column widths in characterscinfos
- array of column headingsIOException
protected void printLine(OutputStream strm, int[] colwidths, String[] data) throws IOException
AbstractTextTableWriter
printLine
in class AbstractTextTableWriter
strm
- stream to write intocolwidths
- column widths in charactersdata
- array of strings to be output, one per columnIOException
protected void printParam(OutputStream strm, String name, String value, Class<?> clazz) throws IOException
AbstractTextTableWriter
printParam
in class AbstractTextTableWriter
strm
- stream to write intoname
- parameter namevalue
- formatted parameter valueclazz
- type of valueIOException
Copyright © 2024 Central Laboratory of the Research Councils. All Rights Reserved.