public class EcsvTableWriter extends StreamStarTableWriter
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 java.lang.String |
UCD_METAKEY
Meta map key for UCD string value.
|
static java.lang.String |
UTYPE_METAKEY
Meta map key for Utype string value.
|
static java.lang.String |
XTYPE_METAKEY
Meta map key for Xtype string value.
|
Constructor and Description |
---|
EcsvTableWriter()
Constructs a writer with default characteristics.
|
EcsvTableWriter(char delimiter,
java.lang.String nameSuffix)
Constructs a writer with a given delimiter character.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getFormatName()
Gives the name of the format which is written by this writer.
|
java.lang.String |
getMimeType()
Returns "text/plain".
|
static StarTableWriter[] |
getStarTableWriters()
Returns a list of ECSV writers with variant characteristics.
|
boolean |
looksLikeFile(java.lang.String location)
Returns true for file extensions ".ecsv" or ".ECSV".
|
void |
writeStarTable(StarTable table,
java.io.OutputStream out)
Writes a StarTable object to a given output stream.
|
writeStarTable
public static final java.lang.String UCD_METAKEY
public static final java.lang.String UTYPE_METAKEY
public static final java.lang.String XTYPE_METAKEY
public static final EcsvTableWriter SPACE_WRITER
public static final EcsvTableWriter COMMA_WRITER
public EcsvTableWriter()
public EcsvTableWriter(char delimiter, java.lang.String nameSuffix)
delimiter
- field delimiter character; should be a space or commanameSuffix
- string to append to "ECSV" to provide the format namepublic java.lang.String getFormatName()
StarTableWriter
public java.lang.String getMimeType()
public boolean looksLikeFile(java.lang.String location)
location
- the location name (probably filename)public void writeStarTable(StarTable table, java.io.OutputStream out) throws java.io.IOException
StarTableWriter
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
streamjava.io.IOException
- if there is some I/O errorpublic static StarTableWriter[] getStarTableWriters()