Class FixedWidthWriter
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.core.LinedTextWriter
com.northconcepts.datapipeline.fixedwidth.FixedWidthWriter
Writes records to a fixed width 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
ConstructorsConstructorDescriptionFixedWidthWriter(File file) FixedWidthWriter(File file, boolean append) FixedWidthWriter(Writer writer) -
Method Summary
Modifier and TypeMethodDescriptionaddExceptionProperties(DataException exception) Adds this endpoint's current state to aDataException.addField(int width, FixedWidthAlign align, char fillChar) addField(FixedWidthField field) Appends a column; each record written must have exactly one field per column, matched by position.addFields(int... width) Appends left-aligned columns of the given widths that use the writer's fill character.protected 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()).charReturns the character used to pad values in columns without their own fill character (defaults to space).booleanIndicates if values longer than their column are cut to fit instead of failing the write (default is true).setAutoCloseWriter(boolean autoCloseWriter) Indicates if the underlying java.io.BufferedWriter should be closed when this stream closes (defaults to true).setDescription(String description) Sets the optional text shown for this endpoint inEndpoint.toString()and exception properties.setFieldNamesInFirstRow(boolean fieldNamesInFirstRow) Indicates if a header row of field names is written before the first record (default is true); must be called beforeAbstractWriter.open().setFillChar(char fillChar) Sets the character used to pad values in columns without their own fill character (defaults to space).setFlushOnWrite(boolean flushOnWrite) Indicates if the underlying java.io.BufferedWriter should be flushed after each record is written (defaults to false).setNewLine(String newLine) Assigns the string used between each line (defaults to "\n" on Linux and "\r\n" on Windows).setTruncateFields(boolean truncateFields) Indicates if values longer than their column are cut to fit instead of failing the write (default is true).Methods inherited from class com.northconcepts.datapipeline.core.LinedTextWriter
getNewLine, writeRecordMethods inherited from class com.northconcepts.datapipeline.core.TextWriter
close, getFile, getWriter, isAppend, isAutoCloseWriter, isFieldNamesInFirstRow, isFlushOnWrite, writeMethods inherited from class com.northconcepts.datapipeline.core.AbstractWriter
createHeaderRecord, isHeaderRow, open, 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
-
Constructor Details
-
FixedWidthWriter
- 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.
-
FixedWidthWriter
-
FixedWidthWriter
-
-
Method Details
-
getFillChar
public char getFillChar()Returns the character used to pad values in columns without their own fill character (defaults to space). -
setFillChar
Sets the character used to pad values in columns without their own fill character (defaults to space). -
isTruncateFields
public boolean isTruncateFields()Indicates if values longer than their column are cut to fit instead of failing the write (default is true). -
setTruncateFields
Indicates if values longer than their column are cut to fit instead of failing the write (default is true). -
addField
Appends a column; each record written must have exactly one field per column, matched by position. -
addFields
Appends left-aligned columns of the given widths that use the writer's fill character. -
addField
-
setFieldNamesInFirstRow
Description copied from class:AbstractWriterIndicates if a header row of field names is written before the first record (default is true); must be called beforeAbstractWriter.open().- Overrides:
setFieldNamesInFirstRowin classAbstractWriter
-
setDescription
Description copied from class:EndpointSets the optional text shown for this endpoint inEndpoint.toString()and exception properties.- Overrides:
setDescriptionin classEndpoint
-
setNewLine
Description copied from class:LinedTextWriterAssigns the string used between each line (defaults to "\n" on Linux and "\r\n" on Windows).- Overrides:
setNewLinein classLinedTextWriter
-
setAutoCloseWriter
Description copied from class:TextWriterIndicates if the underlying java.io.BufferedWriter should be closed when this stream closes (defaults to true).- Overrides:
setAutoCloseWriterin classTextWriter
-
setFlushOnWrite
Description copied from class:TextWriterIndicates if the underlying java.io.BufferedWriter should be flushed after each record is written (defaults to false).- Overrides:
setFlushOnWritein 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 classLinedTextWriter
-
assembleLine
Description copied from class:LinedTextWriterAppends the record's output line, without a line terminator, to the empty buffer; also called for the header row (seeAbstractWriter.isHeaderRow()).- Specified by:
assembleLinein classLinedTextWriter- Throws:
Throwable
-