Class FixedWidthReader
java.lang.Object
com.northconcepts.datapipeline.core.DataObject
com.northconcepts.datapipeline.core.Endpoint
com.northconcepts.datapipeline.core.DataEndpoint
com.northconcepts.datapipeline.core.DataReader
com.northconcepts.datapipeline.core.AbstractReader
com.northconcepts.datapipeline.core.TextReader
com.northconcepts.datapipeline.fixedwidth.FixedWidthReader
Obtains records from 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.TextReader
EOF, readerFields inherited from class com.northconcepts.datapipeline.core.AbstractReader
currentRecord, fieldNames, lastRow, startingRowFields inherited from class com.northconcepts.datapipeline.core.DataReader
fieldLineage, recordLineageFields 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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddExceptionProperties(DataException exception) Adds this endpoint's current state to aDataException.addField(FixedWidthField field) Appends a left-aligned column that uses the reader's fill character.addField(String name, int width, FixedWidthAlign align, char fillChar) addFields(int... width) Appends unnamed, left-aligned columns of the given widths that use the reader's fill character.protected RecordaddLineage(Record record) Called byDataReader.read()for each record fromDataReader.readImpl()while lineage is saved; the default copiesrecordLineageinto every field along with its original index and name.protected booleanfillRecord(Record record) Populates the given record with the next row's values; returns false at the end of the input.charReturns the character trimmed from values in columns without their own fill character (defaults to space).booleanIndicates if the last field in each record will contain the rest of each line (default is false).booleanIndicates if this reader can capture record and field lineage (false unless overridden by a reader that supports it).voidopen()Makes this endpoint ready for reading or writing.setDescription(String description) Sets the optional text shown for this endpoint inEndpoint.toString()and exception properties.setFieldNames(String... fieldNames) Sets the names given to each record's fields, taking precedence over names in the first row; must be called beforeAbstractReader.open().setFieldNames(Collection<String> fieldNames) Sets the names given to each record's fields, taking precedence over names in the first row; must be called beforeAbstractReader.open().setFieldNamesInFirstRow(boolean fieldNamesInFirstRow) Indicates if the first row holds the field names instead of data (default is false); must be called beforeAbstractReader.open().setFillChar(char fillChar) Sets the character trimmed from values in columns without their own fill character (defaults to space).setLastFieldConsumesRemaining(boolean lastFieldConsumesRemaining) Set whether the last field in each record will contain the rest of each line.setLastRow(int lastRow) Sets the 0-based index of the last row to read or -1 to read to the end (default is -1).setSaveLineage(boolean saveLineage) Indicates if record and field lineage is captured for each record read (default is false); enabling it throws ifDataReader.isLineageSupported()is false or the product edition does not include lineage.setSkipEmptyRows(boolean skipEmptyRows) Indicates that rows with only null values should not be returned by the reader (default is false).setStartingRow(int startingRow) Sets the 0-based index of the first row to read; earlier rows are skipped when the reader is opened (default is 0).skipField(int width) Appends a column of the given width whose text is discarded instead of read into a field.Methods inherited from class com.northconcepts.datapipeline.core.TextReader
available, close, getFile, getLineNumber, readImplMethods inherited from class com.northconcepts.datapipeline.core.AbstractReader
getFieldNames, getLastRow, getStartingRow, isFieldNamesInFirstRow, isSkipEmptyRows, readMethods inherited from class com.northconcepts.datapipeline.core.DataReader
getBufferSize, getNestedEndpoint, getNestedReader, getReader, getRootEndpoint, getRootReader, isExhausted, isSaveLineage, peek, pop, push, skipMethods 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
-
FixedWidthReader
-
FixedWidthReader
-
-
Method Details
-
getFillChar
public char getFillChar()Returns the character trimmed from values in columns without their own fill character (defaults to space). -
setFillChar
Sets the character trimmed from values in columns without their own fill character (defaults to space). -
isLastFieldConsumesRemaining
public boolean isLastFieldConsumesRemaining()Indicates if the last field in each record will contain the rest of each line (default is false). -
setLastFieldConsumesRemaining
Set whether the last field in each record will contain the rest of each line. Default isfalse. -
addField
-
addFields
Appends unnamed, left-aligned columns of the given widths that use the reader's fill character. -
addField
Appends a left-aligned column that uses the reader's fill character. -
addField
-
skipField
Appends a column of the given width whose text is discarded instead of read into a field. -
setFieldNamesInFirstRow
Description copied from class:AbstractReaderIndicates if the first row holds the field names instead of data (default is false); must be called beforeAbstractReader.open().- Overrides:
setFieldNamesInFirstRowin classAbstractReader
-
setFieldNames
Description copied from class:AbstractReaderSets the names given to each record's fields, taking precedence over names in the first row; must be called beforeAbstractReader.open().- Overrides:
setFieldNamesin classAbstractReader
-
setFieldNames
Description copied from class:AbstractReaderSets the names given to each record's fields, taking precedence over names in the first row; must be called beforeAbstractReader.open().- Overrides:
setFieldNamesin classAbstractReader
-
setStartingRow
Description copied from class:AbstractReaderSets the 0-based index of the first row to read; earlier rows are skipped when the reader is opened (default is 0).- Overrides:
setStartingRowin classAbstractReader
-
setLastRow
Description copied from class:AbstractReaderSets the 0-based index of the last row to read or -1 to read to the end (default is -1).- Overrides:
setLastRowin classAbstractReader
-
setSkipEmptyRows
Description copied from class:AbstractReaderIndicates that rows with only null values should not be returned by the reader (default is false).- Overrides:
setSkipEmptyRowsin classAbstractReader
-
setSaveLineage
Description copied from class:DataReaderIndicates if record and field lineage is captured for each record read (default is false); enabling it throws ifDataReader.isLineageSupported()is false or the product edition does not include lineage.- Overrides:
setSaveLineagein classDataReader
-
setDescription
Description copied from class:EndpointSets the optional text shown for this endpoint inEndpoint.toString()and exception properties.- Overrides:
setDescriptionin classEndpoint
-
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 classTextReader
-
open
Description copied from class:DataEndpointMakes this endpoint ready for reading or writing.- Overrides:
openin classTextReader- Throws:
DataException
-
fillRecord
Description copied from class:AbstractReaderPopulates the given record with the next row's values; returns false at the end of the input.- Specified by:
fillRecordin classAbstractReader- Throws:
Throwable
-
isLineageSupported
public boolean isLineageSupported()Description copied from class:DataReaderIndicates if this reader can capture record and field lineage (false unless overridden by a reader that supports it).- Overrides:
isLineageSupportedin classDataReader
-
addLineage
Description copied from class:DataReaderCalled byDataReader.read()for each record fromDataReader.readImpl()while lineage is saved; the default copiesrecordLineageinto every field along with its original index and name. Overrides set their source details onrecordLineagefirst and end withsuper.addLineage(record).- Overrides:
addLineagein classTextReader
-