uk.ac.starlink.table.formats
Class CsvTableWriter

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

public class CsvTableWriter
extends StreamStarTableWriter

A StarTableWriter which outputs to Comma-Separated Value format. This format is readable by CsvTableBuilder.

Since:
21 Sep 2004

Constructor Summary
CsvTableWriter()
           
 
Method Summary
 String getFormatName()
          Returns "CSV".
 boolean getWriteHeader()
          Indicates whether an initial row containing column names will be written.
 boolean looksLikeFile(String location)
          Returns true for locations ending ".csv" or ".CSV".
 void setWriteHeader(boolean writeHeader)
          Indicate whether an initial row containing column names should be written.
 void writeStarTable(StarTable table, OutputStream ostrm)
          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

CsvTableWriter

public CsvTableWriter()
Method Detail

setWriteHeader

public void setWriteHeader(boolean writeHeader)
Indicate whether an initial row containing column names should be written.

Parameters:
writeHeader - true iff you want the first output line to contain column names

getWriteHeader

public boolean getWriteHeader()
Indicates whether an initial row containing column names will be written.

Returns:
whether the first output line will contain column names

getFormatName

public String getFormatName()
Returns "CSV".


looksLikeFile

public boolean looksLikeFile(String location)
Returns true for locations ending ".csv" or ".CSV".

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

writeStarTable

public void writeStarTable(StarTable table,
                           OutputStream ostrm)
                    throws IOException
Description copied from interface: StarTableWriter
Writes a StarTable object to a given output stream. The implementation can assume that out is suitable for direct writing (for instance it should not normally wrap it in a 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.

Parameters:
table - the table to write
ostrm - the output stream to which startab should be written
Throws:
IOException - if there is some I/O error

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