StarTableWriter
AsciiTableWriter
, IpacTableWriter
, TextTableWriter
public abstract class AbstractTextTableWriter extends StreamStarTableWriter
Modifier | Constructor | Description |
---|---|---|
protected |
AbstractTextTableWriter(boolean writeParams) |
Constructor.
|
Modifier and Type | Method | Description |
---|---|---|
protected abstract java.lang.String |
formatValue(java.lang.Object val,
ValueInfo vinfo,
int width) |
Formats a data value for output.
|
protected byte[] |
getBytes(java.lang.String str) |
Returns a byte array corresponding to a given string.
|
java.lang.String |
getFormatName() |
Returns "text";
|
protected int |
getMaximumParameterLength() |
Returns the maximum length for the value of a parameter as passed to
printParam(java.io.OutputStream, java.lang.String, java.lang.String, java.lang.Class) . |
abstract int |
getMaxWidth() |
Returns the maximum width for a given column.
|
java.lang.String |
getMimeType() |
Returns a string suitable for use as the value of a MIME
Content-Type header.
|
int |
getMinNameWidth(ColumnInfo info) |
Returns the minimum width required to output the actual characters
of the name for a given column.
|
int |
getSampledRows() |
Returns the number of columns which will be sampled to
work out the column width.
|
boolean |
getWriteParameters() |
Finds out whether the output will include table parameters.
|
protected abstract void |
printColumnHeads(java.io.OutputStream strm,
int[] colwidths,
ColumnInfo[] cinfos) |
Outputs headings for the table columns.
|
protected abstract void |
printLine(java.io.OutputStream strm,
int[] colwidths,
java.lang.String[] data) |
Outputs a line of table data.
|
protected abstract void |
printParam(java.io.OutputStream strm,
java.lang.String name,
java.lang.String value,
java.lang.Class clazz) |
Outputs a parameter and its value.
|
protected abstract void |
printSeparator(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.
|
void |
setWriteParameters(boolean writeParams) |
Set whether the output should include table parameters.
|
void |
writeStarTable(StarTable startab,
java.io.OutputStream strm) |
Writes a StarTable object to a given output stream.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
looksLikeFile
writeStarTable
protected AbstractTextTableWriter(boolean writeParams)
writeParams
- whether parameters will be written by defaultpublic java.lang.String getFormatName()
public java.lang.String getMimeType()
StarTableWriter
application/octet-stream
"
(for binary formats) or "text/plain
" for ASCII ones)
is recommended.public void writeStarTable(StarTable startab, java.io.OutputStream strm) throws java.io.IOException
StarTableWriter
BufferedOutputStream
), and should not close it
at the end of the call.
Not all table writers are capable of writing to a stream;
an implementation may throw a TableFormatException
to
indicate that it cannot do so.
startab
- the table to writestrm
- the output stream to which startab should be
writtenTableFormatException
- if this table cannot be written to a
streamjava.io.IOException
- if there is some I/O errorprotected int getMaximumParameterLength()
printParam(java.io.OutputStream, java.lang.String, java.lang.String, java.lang.Class)
. The default implementation currently returns 160.public void setWriteParameters(boolean writeParams)
writeParams
- true iff you want table parameters to be output as
well as the table datapublic boolean getWriteParameters()
public abstract int getMaxWidth()
public int getMinNameWidth(ColumnInfo info)
printColumnHeads(java.io.OutputStream, int[], uk.ac.starlink.table.ColumnInfo[])
method does not need
to be included.info
- column metadatapublic int getSampledRows()
protected abstract java.lang.String formatValue(java.lang.Object val, ValueInfo vinfo, int width)
val
- the valuevinfo
- the metadata object describing val's typewidth
- maximum preferred width into which the value should
be formattedprotected abstract void printSeparator(java.io.OutputStream strm, int[] colwidths) throws java.io.IOException
strm
- stream to write intocolwidths
- column widths in charactersjava.io.IOException
protected abstract void printColumnHeads(java.io.OutputStream strm, int[] colwidths, ColumnInfo[] cinfos) throws java.io.IOException
strm
- stream to write intocolwidths
- column widths in characterscinfos
- array of column headingsjava.io.IOException
protected abstract void printLine(java.io.OutputStream strm, int[] colwidths, java.lang.String[] data) throws java.io.IOException
strm
- stream to write intocolwidths
- column widths in charactersdata
- array of strings to be output, one per columnjava.io.IOException
protected abstract void printParam(java.io.OutputStream strm, java.lang.String name, java.lang.String value, java.lang.Class clazz) throws java.io.IOException
strm
- stream to write intoname
- parameter namevalue
- formatted parameter valueclazz
- type of valuejava.io.IOException
protected byte[] getBytes(java.lang.String str)
str
- string to decodeCopyright © 2018 Central Laboratory of the Research Councils. All Rights Reserved.