public abstract class TextWriter extends AbstractWriter
TextStreamWriter
, this writer has the concept of
fieldNamesInFirstRow
and assumes the output is line based.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 |
---|
TextWriter(File file) |
TextWriter(File file,
boolean append) |
TextWriter(Writer writer) |
Modifier and Type | Method and Description |
---|---|
DataException |
addExceptionProperties(DataException exception)
Adds this endpoint's current state to a
DataException . |
void |
close()
Indicates that this endpoint has finished reading or writing.
|
File |
getFile() |
BufferedWriter |
getWriter() |
boolean |
isAppend()
Indicates if writing should start at the end of the file (if it exists).
|
boolean |
isAutoCloseWriter()
Indicates if the underlying java.io.BufferedWriter should be closed when this stream closes (defaults to true).
|
boolean |
isFieldNamesInFirstRow() |
boolean |
isFlushOnWrite()
Indicates if the underlying java.io.BufferedWriter should be flushed after each record is written.
|
TextWriter |
setAutoCloseWriter(boolean autoCloseWriter)
Indicates if the underlying java.io.BufferedWriter should be closed when this stream closes (defaults to true).
|
TextWriter |
setFlushOnWrite(boolean flushOnWrite)
Indicates if the underlying java.io.BufferedWriter should be flushed after each record is written (defaults to false).
|
void |
write(Record record)
Writes the specified record to this
DataWriter and increases the record-count by 1. |
open, setFieldNamesInFirstRow, writeImpl, writeRecord
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, setDescription
public TextWriter(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 TextWriter(File file)
public TextWriter(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 AbstractWriter
public BufferedWriter getWriter()
public File getFile()
public boolean isFieldNamesInFirstRow()
isFieldNamesInFirstRow
in class AbstractWriter
public boolean isAppend()
fieldNamesInFirstRow
property
will be set to false
.public boolean isAutoCloseWriter()
public TextWriter setAutoCloseWriter(boolean autoCloseWriter)
public boolean isFlushOnWrite()
public TextWriter setFlushOnWrite(boolean flushOnWrite)
public void close()
DataEndpoint
close
in class DataEndpoint
public void write(Record record) throws DataException
DataWriter
DataWriter
and increases the record-count by 1.
Any exception raised while writing will be converted to a DataException
using DataObject.exception(Throwable)
.
Subclasses generally do not need to override this method, instead they should implement DataWriter.writeImpl(Record)
.
write
in class AbstractWriter
DataException
Copyright (c) 2006-2024 North Concepts Inc. All Rights Reserved.