|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--uk.ac.starlink.table.StreamStarTableWriter | +--uk.ac.starlink.table.formats.TextTableWriter
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 | |
TextTableWriter()
|
Method Summary | |
protected String |
formatValue(Object val,
ValueInfo vinfo,
int width)
Formats a data value for output. |
protected static byte[] |
getBytes(String str)
Returns a byte array corresponding to a given string. |
String |
getFormatName()
Returns "text"; |
boolean |
getWriteParameters()
Finds out whether the output will include table parameters. |
boolean |
looksLikeFile(String location)
Returns true for location argument which ends in ".txt" or 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)
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 |
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 |
Constructor Detail |
public TextTableWriter()
Method Detail |
public String getFormatName()
public boolean looksLikeFile(String location)
location
- the intended destination of the output
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
IOException
- if there is some I/O errorpublic void setWriteParameters(boolean writeParams)
writeParams
- true iff you want table parameters to be output as
well as the table datapublic boolean getWriteParameters()
protected 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 void printSeparator(OutputStream strm, int[] colwidths) throws IOException
strm
- stream to write intocolwidths
- column widths in characters
IOException
protected void printColumnHeads(OutputStream strm, int[] colwidths, ColumnInfo[] cinfos) throws IOException
strm
- stream to write intocolwidths
- column widths in characters
IOException
protected 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 void printParam(OutputStream strm, String name, String value) throws IOException
strm
- stream to write intoname
- parameter namevalue
- formatted parameter value
IOException
protected static 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 |