uk.ac.starlink.table.formats
Class AsciiTableWriter

java.lang.Object
  extended by uk.ac.starlink.table.StreamStarTableWriter
      extended by uk.ac.starlink.table.formats.AbstractTextTableWriter
          extended by uk.ac.starlink.table.formats.AsciiTableWriter
All Implemented Interfaces:
StarTableWriter

public class AsciiTableWriter
extends AbstractTextTableWriter

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  java.lang.String formatValue(java.lang.Object val, ValueInfo vinfo, int width)
          Formats a data value for output.
 java.lang.String getFormatName()
          Returns "ascii".
 int getMaxWidth()
          Returns the maximum width for a given column.
 boolean looksLikeFile(java.lang.String location)
          Returns true for if the location ends with ".txt".
protected  void printColumnHeads(java.io.OutputStream strm, int[] colwidths, ColumnInfo[] cinfos)
          Outputs headings for the table columns.
protected  void printLine(java.io.OutputStream strm, int[] colwidths, java.lang.String[] data)
          Outputs a line of table data.
protected  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  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.
 
Methods inherited from class uk.ac.starlink.table.formats.AbstractTextTableWriter
getBytes, getMaximumParameterLength, getMimeType, getMinNameWidth, getSampledRows, getWriteParameters, 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 java.lang.String formatValue(java.lang.Object val,
                                       ValueInfo vinfo,
                                       int width)
Description copied from class: AbstractTextTableWriter
Formats a data value for output.

Specified by:
formatValue in class AbstractTextTableWriter
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 java.lang.String getFormatName()
Returns "ascii".

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

looksLikeFile

public boolean looksLikeFile(java.lang.String location)
Returns true for if the location ends with ".txt".

Parameters:
location - the location name (probably filename)
Returns:
true iff it looks like a file this writer would normally write

getMaxWidth

public int getMaxWidth()
Description copied from class: AbstractTextTableWriter
Returns the maximum width for a given column. Values longer than this may be truncated.

Specified by:
getMaxWidth in class AbstractTextTableWriter
Returns:
maximum permitted column width in characters

printSeparator

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

Specified by:
printSeparator in class AbstractTextTableWriter
Parameters:
strm - stream to write into
colwidths - column widths in characters

printLine

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

Specified by:
printLine in class AbstractTextTableWriter
Parameters:
strm - stream to write into
colwidths - column widths in characters
data - array of strings to be output, one per column
Throws:
java.io.IOException

printColumnHeads

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

Specified by:
printColumnHeads in class AbstractTextTableWriter
Parameters:
strm - stream to write into
colwidths - column widths in characters
cinfos - array of column headings
Throws:
java.io.IOException

printParam

protected void printParam(java.io.OutputStream strm,
                          java.lang.String name,
                          java.lang.String value,
                          java.lang.Class clazz)
                   throws java.io.IOException
Description copied from class: AbstractTextTableWriter
Outputs a parameter and its value.

Specified by:
printParam in class AbstractTextTableWriter
Parameters:
strm - stream to write into
name - parameter name
value - formatted parameter value
clazz - type of value
Throws:
java.io.IOException

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