Package uk.ac.starlink.table.formats
Class LatexTableWriter
- java.lang.Object
-
- uk.ac.starlink.table.StreamStarTableWriter
-
- uk.ac.starlink.table.formats.LatexTableWriter
-
- All Implemented Interfaces:
StarTableWriter
public class LatexTableWriter extends StreamStarTableWriter
A StarTableWriter that outputs text to a LaTeX document. Depending on the value of thestandalone
attribute, the output may either be a complete LaTeX document or just a tabular environment suitable for inserting into an existing document.- Author:
- Mark Taylor (Starlnk)
-
-
Constructor Summary
Constructors Constructor Description LatexTableWriter()
Constructs a new writer with default characteristics.LatexTableWriter(boolean standalone)
Constructs a new writer indicating whether it will produce complete or partial LaTeX documents.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
getFormatName()
Returns the string "LaTeX-document" or "LaTeX";java.lang.String
getMimeType()
Returns a string suitable for use as the value of a MIME Content-Type header.static StarTableWriter[]
getStarTableWriters()
Returns a useful list of LatexTableWriters.boolean
isStandalone()
Indicates whether output tables will be complete LaTeX documents.boolean
looksLikeFile(java.lang.String location)
Indicates whether the destination is of a familiar form for this kind of writer.protected void
printFooter(java.io.OutputStream ostrm, StarTable startab)
For standalone output, this method is invoked to output any text following thetabular
environment.protected void
printHeader(java.io.OutputStream ostrm, StarTable startab)
For standalone output, this method is invoked to output any text preceding thetabular
environment.void
setStandalone(boolean standalone)
Sets whether output tables should be complete LaTeX documents.void
writeStarTable(StarTable startab, java.io.OutputStream ostrm)
Writes a StarTable object to a given output stream.-
Methods inherited from class uk.ac.starlink.table.StreamStarTableWriter
writeStarTable
-
-
-
-
Method Detail
-
setStandalone
public void setStandalone(boolean standalone)
Sets whether output tables should be complete LaTeX documents.- Parameters:
standalone
- true if the output document should be a complete LaTeX document
-
isStandalone
public boolean isStandalone()
Indicates whether output tables will be complete LaTeX documents.- Returns:
- true if the output documents will be complete LaTeX docs
-
getFormatName
public java.lang.String getFormatName()
Returns the string "LaTeX-document" or "LaTeX";- Returns:
- a short string identifying the output format of this writer
-
getMimeType
public java.lang.String getMimeType()
Description copied from interface:StarTableWriter
Returns a string suitable for use as the value of a MIME Content-Type header. If no suitable MIME type is available or known, one of "application/octet-stream
" (for binary formats) or "text/plain
" for ASCII ones) is recommended.- Returns:
- MIME content type
-
looksLikeFile
public boolean looksLikeFile(java.lang.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.- 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 startab, java.io.OutputStream ostrm) throws java.io.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 aBufferedOutputStream
), 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:
startab
- the table to writeostrm
- the output stream to which startab should be written- Throws:
TableFormatException
- if this table cannot be written to a streamjava.io.IOException
- if there is some I/O error
-
getStarTableWriters
public static StarTableWriter[] getStarTableWriters()
Returns a useful list of LatexTableWriters.- Returns:
- array containing one standalone and one tabular-only writer
-
printHeader
protected void printHeader(java.io.OutputStream ostrm, StarTable startab) throws java.io.IOException
For standalone output, this method is invoked to output any text preceding thetabular
environment. May be overridden to modify the form of output documents.- Parameters:
ostrm
- output streamstartab
- table for which header is required- Throws:
java.io.IOException
-
printFooter
protected void printFooter(java.io.OutputStream ostrm, StarTable startab) throws java.io.IOException
For standalone output, this method is invoked to output any text following thetabular
environment. May be overridden to modify the form of output documents.- Parameters:
ostrm
- the stream to write tostartab
- the StarTable which the tabular will contain- Throws:
java.io.IOException
-
-