Class DelimitedOutput
java.lang.Object
com.invirgance.convirgance.output.DelimitedOutput
- All Implemented Interfaces:
Output
- Direct Known Subclasses:
PipeDelimitedOutput,TabDelimitedOutput
Support for writing delimited file formats like tab delimited and pipe delimited
formats. Note that this format does not protect against delimiters appearing
in the data. If you are writing a command-delimited file, it is recommended to
use
CSVOutput instead.- Author:
- jbanes
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new DelimitedOutput defaulting to the pipe character '|'.DelimitedOutput(char delimiter) Creates a new DelimitedOutput using the provided character to delimit contentDelimitedOutput(String... columns) Creates a DelimitedOuput with specified columns defaulting to the pipe character '|'DelimitedOutput(String[] columns, char delimiter) Creates a DelimitedOuput with specified columns and delimiter -
Method Summary
Modifier and TypeMethodDescriptionReturnstext/plainfor most delimiters.charGets the current character used when writing delimited outputGets the current text encoding.voidsetDelimiter(char delimiter) Sets the character to use when writing delimited contentvoidsetEncoding(String encoding) Set the text encoding format.Creates a new writer to output delimited data to the specified target.
-
Constructor Details
-
DelimitedOutput
public DelimitedOutput()Creates a new DelimitedOutput defaulting to the pipe character '|'. -
DelimitedOutput
public DelimitedOutput(char delimiter) Creates a new DelimitedOutput using the provided character to delimit content- Parameters:
delimiter- the delimiting character
-
DelimitedOutput
Creates a DelimitedOuput with specified columns defaulting to the pipe character '|'- Parameters:
columns- A String array of column names.
-
DelimitedOutput
Creates a DelimitedOuput with specified columns and delimiter- Parameters:
columns- an array of column names.delimiter- the character to delimit on
-
-
Method Details
-
getDelimiter
public char getDelimiter()Gets the current character used when writing delimited output- Returns:
- the delimiting character
-
setDelimiter
public void setDelimiter(char delimiter) Sets the character to use when writing delimited content- Parameters:
delimiter- the delimiter character
-
getEncoding
Gets the current text encoding. Default encoding is "UTF-8".- Returns:
- the current text encoding format
-
setEncoding
Set the text encoding format. This will override the default of "UTF-8".- Parameters:
encoding- text encoding format
-
write
Creates a new writer to output delimited data to the specified target. Uses the current column definitions of this object to format the output. -
getContentType
Returnstext/plainfor most delimiters. The exception is a comma which returnstext/csvinstead.- Specified by:
getContentTypein interfaceOutput- Returns:
- the MIME type for this format
-