public class ParserOutput
extends java.lang.Object
AbstractParser
and their values.
It is solely responsible for deciding when:
CommonSettings
AbstractParser.parseRecord()
should be retained or discardedAbstractParser.parseRecord()
or from CommonSettings.getHeaders()
AbstractParser
.AbstractParser
,
CommonSettings
Modifier and Type | Field and Description |
---|---|
CharAppender |
appender
The appender available to parsers for accumulating characters read from the input.
|
private CharAppender |
appenderInstance |
private CharAppender[] |
appenders
Stores (shared) references to
CharAppender for each potential column (as given by CommonSettings.getMaxColumns() ). |
protected int |
column
Keeps track of the current column being parsed in the input.
|
private boolean |
columnsReordered |
private boolean |
columnsToExtractInitialized |
private long |
currentRecord |
private java.lang.String[] |
headers |
private java.lang.String |
nullValue |
(package private) java.lang.String[] |
parsedHeaders
Headers parsed from the input when
CommonParserSettings.headerExtractionEnabled is true ,
irrespective of any user-provided headers in CommonSettings.getHeaders() |
protected java.lang.String[] |
parsedValues
Stores the values parsed for a record.
|
private AbstractParser<?> |
parser |
private java.lang.String[] |
selectedHeaders |
private int[] |
selectedIndexes |
protected CommonParserSettings<?> |
settings |
private boolean |
skipEmptyLines |
boolean |
trim |
Constructor and Description |
---|
ParserOutput(AbstractParser<?> parser,
CommonParserSettings<?> settings)
Initializes the ParserOutput with the configuration specified in
CommonParserSettings |
ParserOutput(CommonParserSettings<?> settings)
Initializes the ParserOutput with the configuration specified in
CommonParserSettings |
Modifier and Type | Method and Description |
---|---|
void |
discardValues()
Discards the values parsed so far
|
void |
emptyParsed()
Adds a nullValue (as specified in
CommonSettings.getNullValue() ) to the output and prepares the next position in the record to receive more values. |
int |
getCurrentColumn()
Returns the position of the current parsed value
|
long |
getCurrentRecord()
Returns the current record index.
|
(package private) FieldSelector |
getFieldSelector() |
java.lang.String[] |
getHeaders()
Returns the sequence of values that represent the headers each field in the input.
|
int[] |
getSelectedIndexes()
Returns the selected indexes of all fields as defined in
CommonSettings . |
private void |
initializeColumnsToExtract(java.lang.String[] values)
Initializes the sequence of selected fields, if any.
|
protected void |
initializeHeaders() |
boolean |
isColumnReorderingEnabled()
Indicates whether fields selected using the field selection methods (in
CommonSettings ) are being reordered. |
(package private) void |
reset()
Resets the parser output and prepares for a new parsing process.
|
java.lang.String[] |
rowParsed()
Gets all values parsed in the
parsedValues array |
void |
valueParsed()
Adds the accumulated value in the appender object to the output and prepares the next position in the record to receive more values.
|
void |
valueParsed(java.lang.String value)
Adds a value processed externally to the output and prepares the next position in the record to receive more values
|
protected int column
valueParsed()
and emptyParsed()
will increase the column count.
This value is reset to zero after a row is parsed.protected final java.lang.String[] parsedValues
private final CharAppender[] appenders
Stores (shared) references to CharAppender
for each potential column (as given by CommonSettings.getMaxColumns()
).
Fields that are not selected will receive an instance of NoopCharAppender
so all parser calls in AbstractParser.parseRecord()
to appender
will do nothing.
Selected fields (given by CommonParserSettings
) will receive a functional CharAppender
.
protected final CommonParserSettings<?> settings
private final boolean skipEmptyLines
private final java.lang.String nullValue
public CharAppender appender
private final CharAppender appenderInstance
private boolean columnsToExtractInitialized
private boolean columnsReordered
private java.lang.String[] selectedHeaders
private java.lang.String[] headers
private int[] selectedIndexes
private long currentRecord
public boolean trim
java.lang.String[] parsedHeaders
CommonParserSettings.headerExtractionEnabled
is true
,
irrespective of any user-provided headers in CommonSettings.getHeaders()
private final AbstractParser<?> parser
public ParserOutput(CommonParserSettings<?> settings)
CommonParserSettings
settings
- the parser configurationpublic ParserOutput(AbstractParser<?> parser, CommonParserSettings<?> settings)
CommonParserSettings
parser
- the parser whose output will be managed by this class.settings
- the parser configurationprotected void initializeHeaders()
public java.lang.String[] rowParsed()
parsedValues
arrayFieldSelector getFieldSelector()
private void initializeColumnsToExtract(java.lang.String[] values)
values
- a sequence of values that represent the headers of the input. This can be either a parsed record or the headers as defined in CommonSettings.getHeaders()
public java.lang.String[] getHeaders()
CommonSettings.getHeaders()
public int[] getSelectedIndexes()
CommonSettings
. Null if no fields were selected.CommonSettings
. Null if no fields were selected.public boolean isColumnReorderingEnabled()
CommonSettings
) are being reordered. false if no fields were selected or column reordering has been disabled in CommonParserSettings.isColumnReorderingEnabled()
true if fields were selected and column reordering has been enabled in CommonParserSettings.isColumnReorderingEnabled()
public int getCurrentColumn()
public void emptyParsed()
CommonSettings.getNullValue()
) to the output and prepares the next position in the record to receive more values.public void valueParsed()
public void valueParsed(java.lang.String value)
value
- the value to be added to the current record position.public long getCurrentRecord()
rowParsed()
.public final void discardValues()
final void reset()