uk.ac.starlink.table.formats
Class HTMLTableWriter

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

public class HTMLTableWriter
extends Object
implements StarTableWriter

A StarTableWriter that outputs text to HTML. Depending on the value of the standalone attribute, the output may either be a complete HTML document or just a <TABLE> element suitable for inserting into an existing document. The output HTML is intended to conform to HTML 3.2.

See Also:

Constructor Summary
HTMLTableWriter()
          Constructs a new writer with default characteristics.
HTMLTableWriter(boolean standalone)
          Constructs a new writer indicating whether it will produce complete or partial HTML documents.
 
Method Summary
 String getFormatName()
          Gives the name of the format which is written by this writer.
static StarTableWriter[] getStarTableWriters()
          Returns a selection of useful HTMLTableWriters.
 boolean isStandalone()
          Indicates whether output tables will be complete HTML documents.
 boolean looksLikeFile(String location)
          Indicates whether the destination is of a familiar form for this kind of writer.
protected  void printFooter(OutputStream ostrm)
          For standalone output, this method is invoked to output any text following the </TABLE> end tag.
protected  void printHeader(OutputStream ostrm, StarTable table)
          For standalone output, this method is invoked to output any text preceding the <TABLE> start tag.
 void setStandalone(boolean standalone)
          Sets whether output tables should be complete HTML documents.
 void writeStarTable(StarTable table, 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

HTMLTableWriter

public HTMLTableWriter()
Constructs a new writer with default characteristics.


HTMLTableWriter

public HTMLTableWriter(boolean standalone)
Constructs a new writer indicating whether it will produce complete or partial HTML documents.

Method Detail

setStandalone

public void setStandalone(boolean standalone)
Sets whether output tables should be complete HTML documents.

Parameters:
standalone - true if the output document should be a complete HTML document

isStandalone

public boolean isStandalone()
Indicates whether output tables will be complete HTML documents.

Returns:
true if the output documents will be complete HTML docs

getFormatName

public String getFormatName()
Description copied from interface: StarTableWriter
Gives the name of the format which is written by this writer. Matching against this string may be used by callers to identify or select this writer from a list.

Specified by:
getFormatName in interface StarTableWriter

looksLikeFile

public boolean looksLikeFile(String location)
Description copied from interface: StarTableWriter
Indicates whether the destination is of a familiar form for this kind of writer. This may be used to guess what kind of format a table should be written in. Implementations should return true for values of location which look like the normal form for their output format, for instance one with the usual file extension.

Specified by:
looksLikeFile in interface StarTableWriter
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,
                           String location)
                    throws IOException
Description copied from interface: StarTableWriter
Writes a StarTable object to a given location. If possible, a location of "-" should be taken as a request to write to standard output.

Specified by:
writeStarTable in interface StarTableWriter
Parameters:
table - the table to write
location - the destination of the written object (probably, but not necessarily, a filename)
IOException

getStarTableWriters

public static StarTableWriter[] getStarTableWriters()
Returns a selection of useful HTMLTableWriters.

Returns:
array containing one standalone and one TABLE-only writer

printHeader

protected void printHeader(OutputStream ostrm,
                           StarTable table)
                    throws IOException
For standalone output, this method is invoked to output any text preceding the <TABLE> start tag. May be overridden to modify the form of output documents.

Parameters:
ostrm - output stream
table - table for which header is required
IOException

printFooter

protected void printFooter(OutputStream ostrm)
                    throws IOException
For standalone output, this method is invoked to output any text following the </TABLE> end tag. May be overridden to modify the form of output documents.

Parameters:
ostrm - output stream
IOException

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