public class EcsvTableWriter extends DocumentedStreamStarTableWriter
The current implementation avoids use of any YAML serialization library, it just uses print statements. This may facilitate its use in some contexts, and doing it like this seems straightforward enough. However if it turns out that the serialization is more complicated or error-prone than I thought it was, it might be worth revisiting this decision and using for instance the serialization facilities of the YAML parser library that is in any case a dependency of this package.
Modifier and Type | Field and Description |
---|---|
static EcsvTableWriter |
COMMA_WRITER
Instance using commas for delimiters.
|
static EcsvTableWriter |
SPACE_WRITER
Instance using spaces for delimiters.
|
static String |
TABLENAME_METAKEY
Meta map key for table name string value.
|
static String |
UCD_METAKEY
Meta map key for UCD string value.
|
static String |
UTYPE_METAKEY
Meta map key for Utype string value.
|
static String |
XTYPE_METAKEY
Meta map key for Xtype string value.
|
Constructor and Description |
---|
EcsvTableWriter()
Constructs a writer with default characteristics.
|
EcsvTableWriter(char delimiter,
String nameSuffix)
Constructs a writer with a given delimiter character.
|
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.
|
char |
getDelimiter()
Returns the delimiter character, either a space or a comma.
|
String |
getFormatName()
Gives the name of the format which is written by this writer.
|
String |
getMimeType()
Returns "text/plain".
|
String |
getXmlDescription()
Returns user-directed documentation in XML format.
|
void |
setDelimiter(String delimiter)
Sets the delimiter.
|
void |
writeStarTable(StarTable table,
OutputStream out)
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 static final String TABLENAME_METAKEY
public static final String UCD_METAKEY
public static final String UTYPE_METAKEY
public static final String XTYPE_METAKEY
public static final EcsvTableWriter SPACE_WRITER
public static final EcsvTableWriter COMMA_WRITER
public EcsvTableWriter()
public EcsvTableWriter(char delimiter, String nameSuffix)
delimiter
- field delimiter character; should be a space or commanameSuffix
- string to append to "ECSV" to provide the format namepublic String getFormatName()
StarTableWriter
public String getMimeType()
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.
@ConfigMethod(property="delimiter", doc="<p>Delimiter character, which for ECSV may be either a space or a comma. Permitted values are \"<code>space</code>\" or \"<code>comma</code>\".</p>", usage="comma|space", example="comma") public void setDelimiter(String delimiter)
delimiter
- delimiter character;
may be "space", "comma", " " or ","IllegalArgumentException
- if not one of the permitted valuespublic char getDelimiter()
public void writeStarTable(StarTable table, OutputStream out) 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 writeout
- 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 © 2025 Central Laboratory of the Research Councils. All Rights Reserved.