Top Description Fields Constructors Methods
com.univocity.parsers.common

public Class ParserOutput

extends Object
Class Inheritance
Imports
com.univocity.parsers.common.fields.*, com.univocity.parsers.common.input.*, java.util.*

The ParserOutput is the component that manages records parsed by AbstractParser and their values. It is solely responsible for deciding when: Implementations of this class are made available to concrete parser implementations of AbstractParser.
Author
Univocity Software Pty Ltd - [email protected]
See Also
AbstractParser, CommonSettings

Field Summary

Modifier and TypeField and Description
public CharAppender
appender

The appender available to parsers for accumulating characters read from the input.

private final CharAppender
private final 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
private boolean
private boolean
private long
private NormalizedString[]
private String[]
private final String
pack-priv String[]
parsedHeaders

Headers parsed from the input when CommonParserSettings#headerExtractionEnabled is true, irrespective of any user-provided headers in CommonParserSettings#getHeaders()

protected final String[]
parsedValues

Stores the values parsed for a record.

private final AbstractParser<?>
public final Deque<String[]>
private int[]
protected final CommonParserSettings<?>
private final boolean
public boolean

Constructor Summary

AccessConstructor and Description
public
ParserOutput(CommonParserSettings<?>
the parser configuration
settings
)

Initializes the ParserOutput with the configuration specified in CommonParserSettings

public
ParserOutput(AbstractParser<?>
the parser whose output will be managed by this class.
parser
,
CommonParserSettings<?>
the parser configuration
settings
)

Initializes the ParserOutput with the configuration specified in CommonParserSettings

Method Summary

Modifier and TypeMethod and Description
public final void
discardValues()

Discards the values parsed so far

public 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.

public int

Returns:

the position of the current parsed value
getCurrentColumn
()

Returns the position of the current parsed value

public long

Returns:

the current record index.
getCurrentRecord
()

Returns the current record index.

pack-priv FieldSelector
public String[]
public NormalizedString[]

Returns:

the headers each field in the input
getHeaders
()

Returns the sequence of values that represent the headers each field in the input.

public int[]

Returns:

the selected indexes of all fields as defined in CommonSettings. Null if no fields were selected.
getSelectedIndexes
()

Returns the selected indexes of all fields as defined in CommonSettings.

private void
initializeColumnsToExtract(NormalizedString[]
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()
values
)

Initializes the sequence of selected fields, if any.

protected void
public boolean

Returns:

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()

isColumnReorderingEnabled
()

Indicates whether fields selected using the field selection methods (in CommonSettings) are being reordered.

pack-priv final void
reset()

Resets the parser output and prepares for a new parsing process.

public String[]

Returns:

the sequence of parsed values in a record.
rowParsed
()

Gets all values parsed in the ParserOutput#parsedValues array

public 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.

public void
valueParsed(String
the value to be added to the current record position.
value
)

Adds a value processed externally to the output and prepares the next position in the record to receive more values

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

appenderback to summary
public CharAppender appender

The appender available to parsers for accumulating characters read from the input.

This attribute is assigned to different instances of CharAppender during parsing process, namely, a (potentially) different CharAppender for each parsed column, taken from ParserOutput#appenders[ParserOutput#column]

appenderInstanceback to summary
private final CharAppender appenderInstance
appendersback to summary
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 ParserOutput#appender will do nothing.

Selected fields (given by CommonParserSettings) will receive a functional CharAppender.

columnback to summary
protected int column

Keeps track of the current column being parsed in the input. Calls to ParserOutput#valueParsed and ParserOutput#emptyParsed will increase the column count. This value is reset to zero after a row is parsed.

columnReorderingEnabledSettingback to summary
private boolean columnReorderingEnabledSetting
columnsReorderedback to summary
private boolean columnsReordered
columnsToExtractInitializedback to summary
private boolean columnsToExtractInitialized
currentRecordback to summary
private long currentRecord
headersback to summary
private NormalizedString[] headers
headerStringsback to summary
private String[] headerStrings
nullValueback to summary
private final String nullValue
parsedHeadersback to summary
pack-priv String[] parsedHeaders

Headers parsed from the input when CommonParserSettings#headerExtractionEnabled is true, irrespective of any user-provided headers in CommonParserSettings#getHeaders()

parsedValuesback to summary
protected final String[] parsedValues

Stores the values parsed for a record.

parserback to summary
private final AbstractParser<?> parser
pendingRecordsback to summary
public final Deque<String[]> pendingRecords
selectedIndexesback to summary
private int[] selectedIndexes
settingsback to summary
protected final CommonParserSettings<?> settings
skipEmptyLinesback to summary
private final boolean skipEmptyLines
trimback to summary
public boolean trim

Constructor Detail

ParserOutputback to summary
public ParserOutput(CommonParserSettings<?> settings)

Initializes the ParserOutput with the configuration specified in CommonParserSettings

Parameters
settings:CommonParserSettings<?>

the parser configuration

ParserOutputback to summary
public ParserOutput(AbstractParser<?> parser, CommonParserSettings<?> settings)

Initializes the ParserOutput with the configuration specified in CommonParserSettings

Parameters
parser:AbstractParser<?>

the parser whose output will be managed by this class.

settings:CommonParserSettings<?>

the parser configuration

Method Detail

discardValuesback to summary
public final void discardValues()

Discards the values parsed so far

emptyParsedback to summary
public 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.

getCurrentColumnback to summary
public int getCurrentColumn()

Returns the position of the current parsed value

Returns:int

the position of the current parsed value

getCurrentRecordback to summary
public long getCurrentRecord()

Returns the current record index. The number returned here reflects the number of actually parsed and valid records sent to the output of ParserOutput#rowParsed.

Returns:long

the current record index.

getFieldSelectorback to summary
pack-priv FieldSelector getFieldSelector()
getHeaderAsStringArrayback to summary
public String[] getHeaderAsStringArray()
getHeadersback to summary
public NormalizedString[] getHeaders()

Returns the sequence of values that represent the headers each field in the input. This can be either a parsed record or the headers as defined in CommonSettings#getHeaders()

Returns:NormalizedString[]

the headers each field in the input

getSelectedIndexesback to summary
public int[] getSelectedIndexes()

Returns the selected indexes of all fields as defined in CommonSettings. Null if no fields were selected.

Returns:int[]

the selected indexes of all fields as defined in CommonSettings. Null if no fields were selected.

initializeColumnsToExtractback to summary
private void initializeColumnsToExtract(NormalizedString[] values)

Initializes the sequence of selected fields, if any.

Parameters
values:NormalizedString[]

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()

initializeHeadersback to summary
protected void initializeHeaders()
isColumnReorderingEnabledback to summary
public boolean isColumnReorderingEnabled()

Indicates whether fields selected using the field selection methods (in CommonSettings) are being reordered.

Returns:boolean

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()

resetback to summary
pack-priv final void reset()

Resets the parser output and prepares for a new parsing process.

rowParsedback to summary
public String[] rowParsed()

Gets all values parsed in the ParserOutput#parsedValues array

Returns:String[]

the sequence of parsed values in a record.

valueParsedback to summary
public 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.

valueParsedback to summary
public void valueParsed(String value)

Adds a value processed externally to the output and prepares the next position in the record to receive more values

Parameters
value:String

the value to be added to the current record position.