Class TextTableWriter
java.lang.Object
com.northconcepts.datapipeline.core.DataObject
com.northconcepts.datapipeline.core.Endpoint
com.northconcepts.datapipeline.core.DataEndpoint
com.northconcepts.datapipeline.core.DataWriter
com.northconcepts.datapipeline.core.AbstractWriter
com.northconcepts.datapipeline.core.TextWriter
com.northconcepts.datapipeline.texttable.TextTableWriter
Writes records as an easy-to-read, plain-text table with padded, aligned columns — a header row
of field names, a dashed separator line, then one row per record:
Name Account ID Account Balance --------------- ---------- --------------- Richard Winters MJ-01 10567.25 Lewis Nixon LT-01 -298.1
Columns are the union of field names across all records in first-seen order; rows leave a blank
cell where a record has no value for a column. Records are buffered in memory until this writer
closes so column names and widths can be computed across the whole set — the table is only
written on close().
-
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
ConstructorsConstructorDescriptionTextTableWriter(File file) TextTableWriter(File file, boolean append) TextTableWriter(Writer writer) -
Method Summary
Modifier and TypeMethodDescriptionaddExceptionProperties(DataException exception) Adds this endpoint's current state to aDataException.voidclose()Indicates that this endpoint has finished reading or writing.Returns the string written between columns (defaults to two spaces).Returns the string used between each line (defaults to the platform's line separator).setColumnSeparator(String columnSeparator) Assigns the string written between columns (defaults to two spaces).setNewLine(String newLine) Assigns the string used between each line (defaults to "\n" on Linux and "\r\n" on Windows).protected 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
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
-
TextTableWriter
- 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.
-
TextTableWriter
-
TextTableWriter
-
-
Method Details
-
getNewLine
Returns the string used between each line (defaults to the platform's line separator). -
setNewLine
Assigns the string used between each line (defaults to "\n" on Linux and "\r\n" on Windows). -
getColumnSeparator
Returns the string written between columns (defaults to two spaces). -
setColumnSeparator
Assigns the string written between columns (defaults to two spaces). -
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
-
close
public void close()Description copied from class:DataEndpointIndicates that this endpoint has finished reading or writing.- Overrides:
closein classTextWriter
-
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
-