Class LinedTextWriter
- Direct Known Subclasses:
CSVWriter,FixedWidthWriter,JsonLinesWriter
Abstract super-class for writing records to a text stream.
-
Nested Class Summary
Nested classes/interfaces inherited from class com.northconcepts.datapipeline.core.DataEndpoint
DataEndpoint.State -
Field Summary
Fields inherited from class com.northconcepts.datapipeline.core.AbstractWriter
currentRecordFields inherited from class com.northconcepts.datapipeline.core.DataEndpoint
lastRecord, PRODUCT, PRODUCT_VERSION, VENDOR, XML_INPUT_FACTORY_KEYFields inherited from class com.northconcepts.datapipeline.core.Endpoint
BUFFER_SIZE, captureElapsedTime, DEFAULT_READ_BUFFER_SIZEFields inherited from class com.northconcepts.datapipeline.core.DataObject
id, log, name, TIMESTAMP_FORMAT -
Constructor Summary
ConstructorsConstructorDescriptionLinedTextWriter(File file) Creates a writer that overwrites the file, which this constructor opens immediately rather than inopen().LinedTextWriter(File file, boolean append) LinedTextWriter(Writer writer) -
Method Summary
Modifier and TypeMethodDescriptionaddExceptionProperties(DataException exception) Adds this endpoint's current state to aDataException.protected abstract voidassembleLine(Record record, StringBuilder lineBuffer) Appends the record's output line, without a line terminator, to the empty buffer; also called for the header row (seeAbstractWriter.isHeaderRow()).Returns the string written after each line (defaults to the platform line separator).setNewLine(String newLine) Assigns the string used between each line (defaults to "\n" on Linux and "\r\n" on Windows).protected final voidwriteRecord(Record record) Writes one row; called first for the header row (seeAbstractWriter.isHeaderRow()) when field names are written, then for each record.Methods inherited from class com.northconcepts.datapipeline.core.TextWriter
close, getFile, getWriter, isAppend, isAutoCloseWriter, isFieldNamesInFirstRow, isFlushOnWrite, setAutoCloseWriter, setFlushOnWrite, writeMethods inherited from class com.northconcepts.datapipeline.core.AbstractWriter
createHeaderRecord, isHeaderRow, open, setFieldNamesInFirstRow, writeImplMethods inherited from class com.northconcepts.datapipeline.core.DataWriter
available, getNestedEndpoint, getNestedWriter, getRootEndpoint, getRootWriter, getWriterMethods inherited from class com.northconcepts.datapipeline.core.DataEndpoint
decrementRecordCount, enableJmx, getLastRecord, getRecordCount, getRecordCountAsBigInteger, getRecordCountAsString, incrementRecordCount, isRecordCountBigInteger, resetRecordCount, toStringMethods inherited from class com.northconcepts.datapipeline.core.Endpoint
addElapsedtime, assertClosed, assertNotOpened, assertOpened, finalize, getClosedOn, getDescription, getElapsedTime, getElapsedTimeAsString, getOpenedOn, getOpenElapsedTime, getOpenElapsedTimeAsString, getSelfTime, getSelfTimeAsString, getState, isCaptureElapsedTime, isClosed, isOpen, setCaptureElapsedTime, setDescription
-
Constructor Details
-
LinedTextWriter
- Parameters:
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 thefieldNamesInFirstRowproperty will be set tofalse.
-
LinedTextWriter
Creates a writer that overwrites the file, which this constructor opens immediately rather than inopen(). -
LinedTextWriter
-
-
Method Details
-
addExceptionProperties
Description copied from class:EndpointAdds this endpoint's current state to aDataException. Since this method is called whenever an exception is thrown, subclasses should override it to add their specific information.- Overrides:
addExceptionPropertiesin classTextWriter
-
getNewLine
Returns the string written after each line (defaults to the platform line separator). -
setNewLine
Assigns the string used between each line (defaults to "\n" on Linux and "\r\n" on Windows). -
writeRecord
Description copied from class:AbstractWriterWrites one row; called first for the header row (seeAbstractWriter.isHeaderRow()) when field names are written, then for each record.- Specified by:
writeRecordin classAbstractWriter- Throws:
Throwable
-
assembleLine
Appends the record's output line, without a line terminator, to the empty buffer; also called for the header row (seeAbstractWriter.isHeaderRow()).- Throws:
Throwable
-