|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectuk.ac.starlink.table.StreamStarTableWriter
uk.ac.starlink.table.formats.AbstractTextTableWriter
public abstract class AbstractTextTableWriter
A 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 Summary | |
---|---|
protected |
AbstractTextTableWriter(boolean writeParams)
Constructor. |
Method Summary | |
---|---|
protected abstract String |
formatValue(Object val,
ValueInfo vinfo,
int width)
Formats a data value for output. |
protected byte[] |
getBytes(String str)
Returns a byte array corresponding to a given string. |
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. |
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(OutputStream strm,
int[] colwidths,
ColumnInfo[] cinfos)
Outputs headings for the table columns. |
protected abstract void |
printLine(OutputStream strm,
int[] colwidths,
String[] data)
Outputs a line of table data. |
protected abstract void |
printParam(OutputStream strm,
String name,
String value,
Class clazz)
Outputs a parameter and its value. |
protected abstract 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 |
setWriteParameters(boolean writeParams)
Set whether the output should include table parameters. |
void |
writeStarTable(StarTable startab,
OutputStream strm)
Writes a StarTable object to a given output stream. |
Methods inherited from class uk.ac.starlink.table.StreamStarTableWriter |
---|
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.StarTableWriter |
---|
looksLikeFile |
Constructor Detail |
---|
protected AbstractTextTableWriter(boolean writeParams)
writeParams
- whether parameters will be written by defaultMethod Detail |
---|
public String getFormatName()
public String getMimeType()
StarTableWriter
application/octet-stream
"
(for binary formats) or "text/plain
" for ASCII ones)
is recommended.
public void writeStarTable(StarTable startab, OutputStream strm) throws 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
written
TableFormatException
- if this table cannot be written to a
stream
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 metadata
public int getSampledRows()
protected abstract String formatValue(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 formatted
protected abstract void printSeparator(OutputStream strm, int[] colwidths) throws IOException
strm
- stream to write intocolwidths
- column widths in characters
IOException
protected abstract void printColumnHeads(OutputStream strm, int[] colwidths, ColumnInfo[] cinfos) throws IOException
strm
- stream to write intocolwidths
- column widths in characterscinfos
- array of column headings
IOException
protected abstract void printLine(OutputStream strm, int[] colwidths, String[] data) throws IOException
strm
- stream to write intocolwidths
- column widths in charactersdata
- array of strings to be output, one per column
IOException
protected abstract void printParam(OutputStream strm, String name, String value, Class clazz) throws IOException
strm
- stream to write intoname
- parameter namevalue
- formatted parameter valueclazz
- type of value
IOException
protected byte[] getBytes(String str)
str
- string to decode
|
Copyright © 2004 CLRC: Central Laboratory of the Research Councils. All rights reserved. | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |