|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--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,
String location)
Writes a StarTable object to a given location. |
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()
getFormatName
in interface StarTableWriter
public boolean looksLikeFile(String location)
looksLikeFile
in interface StarTableWriter
location
- the intended destination of the output
public void writeStarTable(StarTable startab, String location) throws IOException
StarTableWriter
writeStarTable
in interface StarTableWriter
startab
- the table to writelocation
- the destination of the written object
(probably, but not necessarily, a filename)
IOException
public 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 |