# Class EcsvTableWriter

java.lang.Object
uk.ac.starlink.table.formats.DocumentedStreamStarTableWriter
uk.ac.starlink.ecsv.EcsvTableWriter

All Implemented Interfaces:
  `uk.ac.starlink.table.Documented, uk.ac.starlink.table.formats.DocumentedIOHandler, uk.ac.starlink.table.StarTableWriter`

public class EcsvTableWriter extends uk.ac.starlink.table.formats.DocumentedStreamStarTableWriter
TableWriter for ECSV output format. The format currently supported is ECSV 1.0, as documented at Astropy APE6.

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.

Since:
  29 Apr 2020
Author:
  Mark Taylor

## Field Summary

Fields
Modifier and Type
Field
Description
`static final EcsvTableWriter`
`COMMA_WRITER`
Instance using commas for delimiters.
`static final EcsvTableWriter`
`SPACE_WRITER`
Instance using spaces for delimiters.
`static final String`
`TABLENAME_METAKEY`
Meta map key for table name string value.
`static final String`
`UCD_METAKEY`
Meta map key for UCD string value.
`static final String`
`UTYPE_METAKEY`
Meta map key for Utype string value.
`static final String`
`XTYPE_METAKEY`
Meta map key for Xtype string value.

## Constructor Summary

Constructors
Constructor
Description
`EcsvTableWriter()`
Constructs a writer with default characteristics.
`EcsvTableWriter(char delimiter, String nameSuffix)`
Constructs a writer with a given delimiter character.

## Method Summary

Modifier and Type
Method
Description
`boolean`
`docIncludesExample()`
`char`
`getDelimiter()`
Returns the delimiter character, either a space or a comma.
`String`
`getFormatName()`
`String`
`getMimeType()`
Returns "text/plain".
`String`
`getXmlDescription()`
`void`
`setDelimiter(String delimiter)`
Sets the delimiter.
`void`
`writeStarTable(uk.ac.starlink.table.StarTable table, OutputStream out)`

### Methods inherited from class uk.ac.starlink.table.formats.DocumentedStreamStarTableWriter

`getExtensions, looksLikeFile, writeStarTable`

### Methods inherited from class Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface uk.ac.starlink.table.formats.DocumentedIOHandler

`readText`

## Field Details

### TABLENAME_METAKEY

public static final String TABLENAME_METAKEY
Meta map key for table name string value.

See Also:
  - Constant Field Values

### UCD_METAKEY

public static final String UCD_METAKEY
Meta map key for UCD string value.

See Also:
  - Constant Field Values

### UTYPE_METAKEY

public static final String UTYPE_METAKEY
Meta map key for Utype string value.

See Also:
  - Constant Field Values

### XTYPE_METAKEY

public static final String XTYPE_METAKEY
Meta map key for Xtype string value.

See Also:
  - Constant Field Values

### SPACE_WRITER

public static final EcsvTableWriter SPACE_WRITER
Instance using spaces for delimiters.

### COMMA_WRITER

public static final EcsvTableWriter COMMA_WRITER
Instance using commas for delimiters.

## Constructor Details

### EcsvTableWriter

public EcsvTableWriter()
Constructs a writer with default characteristics.

### EcsvTableWriter

public EcsvTableWriter(char delimiter, String nameSuffix)
Constructs a writer with a given delimiter character.

Parameters:
  `delimiter` - field delimiter character; should be a space or comma
  `nameSuffix` - string to append to "ECSV" to provide the format name

## Method Details

### getFormatName

public String getFormatName()

### getMimeType

public String getMimeType()
Returns "text/plain".

### docIncludesExample

public boolean docIncludesExample()

### getXmlDescription

public String getXmlDescription()

### setDelimiter

@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)
Sets the delimiter. ECSV only permits the space or comma.

Parameters:
  `delimiter` - delimiter character; may be "space", "comma", " " or ","
Throws:
  `IllegalArgumentException` - if not one of the permitted values

### getDelimiter

public char getDelimiter()
Returns the delimiter character, either a space or a comma.

Returns:
  delimiter character

### writeStarTable

public void writeStarTable(uk.ac.starlink.table.StarTable table, OutputStream out) throws IOException

Throws:
  `IOException`