public class CsvTableWriter extends DocumentedStreamStarTableWriter
CsvTableBuilder
.Constructor and Description |
---|
CsvTableWriter()
Constructs a default CSV table writer.
|
CsvTableWriter(boolean writeHeader)
Constructs a CSV table writer which optionally writes headers.
|
Modifier and Type | Method and Description |
---|---|
boolean |
docIncludesExample()
Indicates whether the serialization of some (short) example table
should be added to the user documentation for this handler.
|
String |
getFormatName()
Returns "CSV" or "CSV-noheader".
|
int |
getMaxFieldChars()
Returns the limit on the number of characters that will be written
in a single field.
|
String |
getMimeType()
Returns a string suitable for use as the value of a MIME
Content-Type header.
|
boolean |
getWriteHeader()
Indicates whether an initial row containing column names will be
written.
|
String |
getXmlDescription()
Returns user-directed documentation in XML format.
|
void |
setMaxFieldChars(int maxFieldChars)
Sets a limit on the number of characters that will be written
in a single field.
|
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. |
getExtensions, looksLikeFile, writeStarTable
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
matchesExtension, readText, toLink
public CsvTableWriter()
public CsvTableWriter(boolean writeHeader)
writeHeader
- true iff you want the first output line to contain
column names@ConfigMethod(property="header", doc="<p>If true, the first line of the CSV output will be a header containing the column names; if false, no header line is written and all lines represent data rows.</p>", sequence=1) public void setWriteHeader(boolean writeHeader)
writeHeader
- true iff you want the first output line to contain
column namespublic boolean getWriteHeader()
@ConfigMethod(property="maxCell", doc="<p>Maximum width in characters of an output table cell. Cells longer than this will be truncated.</p>", example="160", sequence=2) public void setMaxFieldChars(int maxFieldChars)
maxFieldChars
- new limitpublic int getMaxFieldChars()
public String getFormatName()
public String getMimeType()
StarTableWriter
application/octet-stream
"
(for binary formats) or "text/plain
" for ASCII ones)
is recommended.public boolean docIncludesExample()
DocumentedIOHandler
Documented.getXmlDescription()
method already includes some example output, should return false.public String getXmlDescription()
Documented
The output should be a sequence of one or more <P> elements, using XHTML-like XML. Since rendering may be done in a number of contexts however, use of the full range of XHTML elements is discouraged. Where possible, the content should stick to simple markup such as the elements P, A, UL, OL, LI, DL, DT, DD EM, STRONG, I, B, CODE, TT, PRE.
public void writeStarTable(StarTable table, OutputStream ostrm) throws IOException
StarTableWriter
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.
table
- the table to writeostrm
- the output stream to which startab
should be
writtenTableFormatException
- if this table cannot be written to a
streamIOException
- if there is some I/O errorCopyright © 2024 Central Laboratory of the Research Councils. All Rights Reserved.