public class CSVWriter extends LinedTextWriter
Modifier and Type | Class and Description |
---|---|
static interface |
CSVWriter.IValuePolicy
The interface used by null and empty string writers.
|
static class |
CSVWriter.ValuePolicy
The default implementation used to write null and empty string.
|
DataEndpoint.State
currentRecord
lastRecord, PRODUCT, PRODUCT_VERSION, VENDOR, XML_INPUT_FACTORY_KEY
BUFFER_SIZE, captureElapsedTime, DEFAULT_READ_BUFFER_SIZE
id, log, name, TIMESTAMP_FORMAT
Constructor and Description |
---|
CSVWriter(File file) |
CSVWriter(File file,
boolean append) |
CSVWriter(Writer writer) |
Modifier and Type | Method and Description |
---|---|
DataException |
addExceptionProperties(DataException exception)
Adds this endpoint's current state to a
DataException . |
protected void |
assembleLine(Record record,
StringBuilder lineBuffer) |
CSVWriter.IValuePolicy |
getEmptyStringValuePolicy()
Returns the object responsible for writing empty string values (defaults to ValuePolicy.QUOTED_EMPTY_STRING).
|
String |
getEndingQuote()
Returns the string used to mark the ending of text values that may contain commas and other special characters (defaults to double quote - ").
|
String |
getFieldSeparator()
Returns the string used between each field value (defaults to comma).
|
CSVWriter.IValuePolicy |
getNullValuePolicy()
Returns the object responsible for writing null values (defaults to ValuePolicy.EMPTY_STRING).
|
String |
getQuoteChar()
Returns the starting quote - same as calling getStartingQuote() (defaults to double quote - ").
|
String |
getStartingQuote()
Returns the string used to mark the beginning of text values that may contain commas and other special characters (defaults to double quote - ").
|
boolean |
isForceQuote()
Returns true if all values will be quoted, even if they are not null or empty strings.
|
CSVWriter |
setAutoCloseWriter(boolean autoCloseWriter)
Indicates if the underlying java.io.BufferedWriter should be closed when this stream closes (defaults to true).
|
CSVWriter |
setDescription(String description) |
CSVWriter |
setEmptyStringValuePolicy(CSVWriter.IValuePolicy emptyStringValuePolicy)
Assigns the object responsible for writing empty string values (defaults to ValuePolicy.QUOTED_EMPTY_STRING).
|
CSVWriter |
setEndingQuote(String endingQuote)
Assigns the string used to mark the ending of text values that may contain commas and other special characters (defaults to double quote - ").
|
CSVWriter |
setFieldNamesInFirstRow(boolean fieldNamesInFirstRow) |
CSVWriter |
setFieldSeparator(char fieldSeparator)
Assigns the string used between each field value (defaults to comma).
|
CSVWriter |
setFieldSeparator(String fieldSeparator)
Assigns the string used between each field value (defaults to comma).
|
CSVWriter |
setFlushOnWrite(boolean flushOnWrite)
Indicates if the underlying java.io.BufferedWriter should be flushed after each record is written (defaults to false).
|
CSVWriter |
setForceQuote(boolean force)
Indicates if all values should be quoted, even if they are not null or empty strings.
|
CSVWriter |
setNewLine(String newLine)
Assigns the string used between each line (defaults to "\n" on Linux and "\r\n" on Windows).
|
CSVWriter |
setNullValuePolicy(CSVWriter.IValuePolicy nullValuePolicy)
Assigns the object responsible for writing null values (defaults to ValuePolicy.EMPTY_STRING).
|
CSVWriter |
setQuoteChar(String quoteChar)
Assigns startingQuote and endingQuote to the same value (defaults to double quote - ").
|
CSVWriter |
setStartingQuote(String startingQuote)
Assigns the string used to mark the beginning of text values that may contain commas and other special characters (defaults to double quote - ").
|
getNewLine, writeRecord
close, getFile, getWriter, isAppend, isAutoCloseWriter, isFieldNamesInFirstRow, isFlushOnWrite, write
open, writeImpl
available, getNestedEndpoint, getNestedWriter, getRootEndpoint, getRootWriter
decrementRecordCount, enableJmx, getLastRecord, getRecordCount, getRecordCountAsBigInteger, getRecordCountAsString, incrementRecordCount, isRecordCountBigInteger, resetRecordCount, toString
addElapsedtime, assertClosed, assertNotOpened, assertOpened, finalize, getClosedOn, getDescription, getElapsedTime, getElapsedTimeAsString, getOpenedOn, getOpenElapsedTime, getOpenElapsedTimeAsString, getSelfTime, getSelfTimeAsString, getState, isCaptureElapsedTime, isClosed, isOpen, setCaptureElapsedTime
public CSVWriter(File file, boolean append)
file
- append
- Indicates if writing should start at the end of the file (if it exists). If the specified file exists and has contents
(more than 0 bytes), then the fieldNamesInFirstRow
property will be set to false
.public CSVWriter(File file)
public CSVWriter(Writer writer)
public DataException addExceptionProperties(DataException exception)
Endpoint
DataException
. Since this method is called whenever an
exception is thrown, subclasses should override it to add their specific information.addExceptionProperties
in class LinedTextWriter
public CSVWriter setNewLine(String newLine)
setNewLine
in class LinedTextWriter
public CSVWriter setForceQuote(boolean force)
public boolean isForceQuote()
public String getFieldSeparator()
public CSVWriter setFieldSeparator(char fieldSeparator)
public CSVWriter setFieldSeparator(String fieldSeparator)
public String getQuoteChar()
getStartingQuote()
public CSVWriter setQuoteChar(String quoteChar)
setStartingQuote(String)
setEndingQuote(String)
public String getStartingQuote()
public CSVWriter setStartingQuote(String startingQuote)
public String getEndingQuote()
public CSVWriter setEndingQuote(String endingQuote)
public CSVWriter.IValuePolicy getNullValuePolicy()
CSVWriter.ValuePolicy.EMPTY_STRING
public CSVWriter setNullValuePolicy(CSVWriter.IValuePolicy nullValuePolicy)
CSVWriter.ValuePolicy.EMPTY_STRING
public CSVWriter.IValuePolicy getEmptyStringValuePolicy()
public CSVWriter setEmptyStringValuePolicy(CSVWriter.IValuePolicy emptyStringValuePolicy)
public CSVWriter setAutoCloseWriter(boolean autoCloseWriter)
TextWriter
setAutoCloseWriter
in class TextWriter
public CSVWriter setFlushOnWrite(boolean flushOnWrite)
TextWriter
setFlushOnWrite
in class TextWriter
public CSVWriter setFieldNamesInFirstRow(boolean fieldNamesInFirstRow)
setFieldNamesInFirstRow
in class AbstractWriter
public CSVWriter setDescription(String description)
setDescription
in class Endpoint
protected void assembleLine(Record record, StringBuilder lineBuffer) throws Throwable
assembleLine
in class LinedTextWriter
Throwable
Copyright (c) 2006-2024 North Concepts Inc. All Rights Reserved.