uk.ac.starlink.table.formats
Class AsciiTableWriter

java.lang.Object
  |
  +--uk.ac.starlink.table.StreamStarTableWriter
        |
        +--uk.ac.starlink.table.formats.TextTableWriter
              |
              +--uk.ac.starlink.table.formats.AsciiTableWriter
All Implemented Interfaces:
StarTableWriter

public class AsciiTableWriter
extends TextTableWriter

A StarTableWriter which outputs text to a simple format machine-readable text file. This format is suitable for reading using AsciiStarTable and AsciiTableBuilder.

Since:
29 Mar 2004

Constructor Summary
AsciiTableWriter()
           
 
Method Summary
protected  String formatValue(Object val, ValueInfo vinfo, int width)
          Formats a data value for output.
 String getFormatName()
          Returns "ascii".
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.
 
Methods inherited from class uk.ac.starlink.table.formats.TextTableWriter
getBytes, getWriteParameters, looksLikeFile, setWriteParameters, writeStarTable
 
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

AsciiTableWriter

public AsciiTableWriter()
Method Detail

formatValue

protected String formatValue(Object val,
                             ValueInfo vinfo,
                             int width)
Description copied from class: TextTableWriter
Formats a data value for output.

Overrides:
formatValue in class TextTableWriter
Parameters:
val - the value
vinfo - the metadata object describing val's type
width - maximum preferred width into which the value should be formatted
Returns:
formatted string meaning value, preferably no longer than width characters

getFormatName

public String getFormatName()
Returns "ascii".

Specified by:
getFormatName in interface StarTableWriter
Overrides:
getFormatName in class TextTableWriter
Returns:
output format

printSeparator

protected void printSeparator(OutputStream strm,
                              int[] colwidths)
Description copied from class: TextTableWriter
Outputs a decorative separator line, of the sort you might find between the column headings and the table data.

Overrides:
printSeparator in class TextTableWriter
Parameters:
strm - stream to write into
colwidths - column widths in characters

printLine

protected void printLine(OutputStream strm,
                         int[] colwidths,
                         String[] data)
                  throws IOException
Description copied from class: TextTableWriter
Outputs a line of table data.

Overrides:
printLine in class TextTableWriter
Parameters:
strm - stream to write into
colwidths - column widths in characters
data - array of strings to be output, one per column
IOException

printColumnHeads

protected void printColumnHeads(OutputStream strm,
                                int[] colwidths,
                                ColumnInfo[] cinfos)
                         throws IOException
Description copied from class: TextTableWriter
Outputs headings for the table columns.

Overrides:
printColumnHeads in class TextTableWriter
Parameters:
strm - stream to write into
colwidths - column widths in characters
IOException

printParam

protected void printParam(OutputStream strm,
                          String name,
                          String value)
                   throws IOException
Description copied from class: TextTableWriter
Outputs a parameter and its value.

Overrides:
printParam in class TextTableWriter
Parameters:
strm - stream to write into
name - parameter name
value - formatted parameter value
IOException

Copyright © 2004 CLRC: Central Laboratory of the Research Councils. All rights reserved.