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

public Class DefaultContext

extends Object
implements Context
Class Inheritance
All Implemented Interfaces
com.univocity.parsers.common.Context
Known Direct Subclasses
com.univocity.parsers.common.DefaultParsingContext
Imports
com.univocity.parsers.common.record.*

Default implementation of the Context interface with essential information about the output being produced.
Author
Univocity Software Pty Ltd - [email protected]

Field Summary

Modifier and TypeField and Description
pack-priv final ColumnMap
pack-priv final int
private String[]
pack-priv final ParserOutput
protected RecordFactory
protected boolean

Constructor Summary

AccessConstructor and Description
public
DefaultContext(int errorContentLength)

public
DefaultContext(ParserOutput output, int errorContentLength)

Method Summary

Modifier and TypeMethod and Description
public boolean
columnsReordered()

Implements com.univocity.parsers.common.Context.columnsReordered.

Indicates whether selected fields are being reordered.
public int
currentColumn()

Implements com.univocity.parsers.common.Context.currentColumn.

Returns the column index of the record being processed.
public long
currentRecord()

Implements com.univocity.parsers.common.Context.currentRecord.

Returns the index of the last valid record parsed from the input
public int
errorContentLength()

Implements com.univocity.parsers.common.Context.errorContentLength.

Returns the length limit of parsed contents appearing in exception messages when an error occurs

If 0, then no exceptions will include the content being manipulated in their attributes, and the "<omitted>" string will appear in error messages as the parsed content.

public int[]
extractedFieldIndexes()

Implements com.univocity.parsers.common.Context.extractedFieldIndexes.

Returns the indexes of each field extracted from the input when fields are selected.
public String[]
headers()

Implements com.univocity.parsers.common.Context.headers.

Returns the file headers that identify each parsed record.
public int
indexOf(String
the header whose position will be returned
header
)

Implements com.univocity.parsers.common.Context.indexOf.

Returns the position of a header (0 based).
public int
indexOf(Enum<?>
the header whose position will be returned
header
)

Implements com.univocity.parsers.common.Context.indexOf.

Returns the position of a header (0 based).
public boolean
isStopped()

Implements com.univocity.parsers.common.Context.isStopped.

Identifies whether the parser is running.
public RecordMetaData
recordMetaData()

Implements com.univocity.parsers.common.Context.recordMetaData.

Returns the metadata information associated with records produced by the current parsing process.
pack-priv void
public String[]
selectedHeaders()

Implements com.univocity.parsers.common.Context.selectedHeaders.

Returns the sequence of headers that have been selected.
public void
stop()

Implements com.univocity.parsers.common.Context.stop.

Stops the parsing process.
public Record
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

columnMapback to summary
pack-priv final ColumnMap columnMap
errorContentLengthback to summary
pack-priv final int errorContentLength
headersback to summary
private String[] headers
outputback to summary
pack-priv final ParserOutput output
recordFactoryback to summary
protected RecordFactory recordFactory
stoppedback to summary
protected boolean stopped

Constructor Detail

DefaultContextback to summary
public DefaultContext(int errorContentLength)
DefaultContextback to summary
public DefaultContext(ParserOutput output, int errorContentLength)

Method Detail

columnsReorderedback to summary
public boolean columnsReordered()

Implements com.univocity.parsers.common.Context.columnsReordered.

Doc from com.univocity.parsers.common.Context.columnsReordered.

Indicates whether selected fields are being reordered.

If columns are reordered, each parsed record will contain values only for the selected fields, as specified by extractedFieldIndexes()

Returns:boolean

true if the parsed records are being reordered by the parser, false otherwise

Annotations
@Override
currentColumnback to summary
public int currentColumn()

Implements com.univocity.parsers.common.Context.currentColumn.

Doc from com.univocity.parsers.common.Context.currentColumn.

Returns the column index of the record being processed.

Returns:int

the column index of the record being processed.

Annotations
@Override
currentRecordback to summary
public long currentRecord()

Implements com.univocity.parsers.common.Context.currentRecord.

Doc from com.univocity.parsers.common.Context.currentRecord.

Returns the index of the last valid record parsed from the input

Returns:long

the index of the last valid record parsed from the input

Annotations
@Override
errorContentLengthback to summary
public int errorContentLength()

Implements com.univocity.parsers.common.Context.errorContentLength.

Doc from com.univocity.parsers.common.Context.errorContentLength.

Returns the length limit of parsed contents appearing in exception messages when an error occurs

If 0, then no exceptions will include the content being manipulated in their attributes, and the "<omitted>" string will appear in error messages as the parsed content.

defaults to -1 (no limit)

.
Returns:int

the maximum length of the data content to display in exception messages

Annotations
@Override
extractedFieldIndexesback to summary
public int[] extractedFieldIndexes()

Implements com.univocity.parsers.common.Context.extractedFieldIndexes.

Doc from com.univocity.parsers.common.Context.extractedFieldIndexes.

Returns the indexes of each field extracted from the input when fields are selected.

The indexes are relative to their original position in the input.

For example, if the input has the fields "A, B, C, D", and the selected fields are "A, D", then the extracted field indexes will return [0, 3]

If no fields were selected, then this method will return null. This means all fields are being parsed.

Returns:int[]

The indexes of each selected field; null if no fields were selected.

Annotations
@Override
headersback to summary
public String[] headers()

Implements com.univocity.parsers.common.Context.headers.

Doc from com.univocity.parsers.common.Context.headers.

Returns the file headers that identify each parsed record.

Returns:String[]

the headers used to identify each record parsed from the input.

Annotations
@Override
indexOfback to summary
public int indexOf(String header)

Implements com.univocity.parsers.common.Context.indexOf.

Doc from com.univocity.parsers.common.Context.indexOf.

Returns the position of a header (0 based).

Parameters
header:String

the header whose position will be returned

Returns:int

the position of the given header, or -1 if it could not be found.

Annotations
@Override
indexOfback to summary
public int indexOf(Enum<?> header)

Implements com.univocity.parsers.common.Context.indexOf.

Doc from com.univocity.parsers.common.Context.indexOf.

Returns the position of a header (0 based).

Parameters
header:Enum<?>

the header whose position will be returned

Returns:int

the position of the given header, or -1 if it could not be found.

Annotations
@Override
isStoppedback to summary
public boolean isStopped()

Implements com.univocity.parsers.common.Context.isStopped.

Doc from com.univocity.parsers.common.Context.isStopped.

Identifies whether the parser is running.

Returns:boolean

true if the parser is stopped, false otherwise.

Annotations
@Override
recordMetaDataback to summary
public RecordMetaData recordMetaData()

Implements com.univocity.parsers.common.Context.recordMetaData.

Doc from com.univocity.parsers.common.Context.recordMetaData.

Returns the metadata information associated with records produced by the current parsing process.

Returns:RecordMetaData

the record metadata.

Annotations
@Override
resetback to summary
pack-priv void reset()
selectedHeadersback to summary
public String[] selectedHeaders()

Implements com.univocity.parsers.common.Context.selectedHeaders.

Doc from com.univocity.parsers.common.Context.selectedHeaders.

Returns the sequence of headers that have been selected. If no selection has been made, all available headers will be returned, producing the same output as a call to method headers().

Returns:String[]

the sequence of selected headers, or all headers if no selection has been made.

stopback to summary
public void stop()

Implements com.univocity.parsers.common.Context.stop.

Doc from com.univocity.parsers.common.Context.stop.

Stops the parsing process. Any open resources in use by the parser are closed automatically unless CommonParserSettings#isAutoClosingEnabled() evaluates to false.

Annotations
@Override
toRecordback to summary
public Record toRecord(String[] row)

Implements com.univocity.parsers.common.Context.toRecord.

Doc from com.univocity.parsers.common.Context.toRecord.

Converts the given parsed row to a com.univocity.parsers.common.record.Record

Parameters
row:String[]

the row to be converted into a com.univocity.parsers.common.record.Record

Returns:Record

a com.univocity.parsers.common.record.Record representing the given row.

Annotations
@Override