Top Description Methods
com.univocity.parsers.common

public Interface ParsingContext

extends Context
Known Direct Implementers
com.univocity.parsers.common.ParsingContextWrapper, com.univocity.parsers.common.DefaultParsingContext, com.univocity.parsers.common.NoopParsingContext
Imports
com.univocity.parsers.common.processor.*, java.util.*

Parsing context information available to instances of RowProcessor.

The ParsingContext can be used to control and to obtain information about the parsing process.

Author
Univocity Software Pty Ltd - [email protected]
See Also
RowProcessor, DefaultParsingContext

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

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

Redeclares com.univocity.parsers.common.Context.columnsReordered.

Indicates whether selected fields (using CommonSettings#selectFields and friends) are being reordered.
public Map<Long, String>

Returns:

a map containing the line numbers and comments found in each.
comments
()

Returns all comments collected by the parser so far.

public long

Returns:

the index of the last char read from the input so far.
currentChar
()

Returns the index of the last char read from the input so far.

public long

Returns:

current line of text being processed by the parser
currentLine
()

Returns the current line of text being processed by the parser

public String

Returns:

the text content parsed for the current input record.
currentParsedContent
()

Returns a String with the input character sequence parsed to produce the current record.

public int

Returns:

the length of the text content parsed for the current input record
currentParsedContentLength
()

Returns the length of the character sequence parsed to produce the current record.

public int[]

Returns:

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

Redeclares com.univocity.parsers.common.Context.extractedFieldIndexes.

Returns the indexes of each field extracted from the input when fields are selected in the parser settings (i.e. using CommonSettings#selectFields and friends).
public String

Returns:

the text content parsed for the current field of the current input record at the time of the error.
fieldContentOnError
()

Returns a String with the input character sequence accumulated on a field before TextParsingException occurred.

public String[]

Returns:

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

Redeclares com.univocity.parsers.common.Context.headers.

Returns the file headers that identify each parsed record.
public String

Returns:

the last comment found in the input.
lastComment
()

Returns the last comment found in the input.

public char[]

Returns:

the line separator sequence. Might contain one or two characters.
lineSeparator
()

Returns the line separator characters used to separate individual records when parsing.

public String[]

Returns:

the headers parsed from the input, when CommonParserSettings#headerExtractionEnabled is true.
parsedHeaders
()

Returns the headers parsed from the input, if and only if CommonParserSettings#headerExtractionEnabled is true.

public void
skipLines(long
the number of lines to be skipped.
lines
)

Skips a given number of lines from the current position.

Inherited from com.univocity.parsers.common.Context:
currentColumncurrentRecorderrorContentLengthindexOfindexOfisStoppedrecordMetaDataselectedHeadersstoptoRecord

Method Detail

columnsReorderedback to summary
public boolean columnsReordered()

Redeclares com.univocity.parsers.common.Context.columnsReordered.

Indicates whether selected fields (using CommonSettings#selectFields and friends) are being reordered.

If columns are reordered, each parsed record will contain values only for the selected fields, as specified by CommonParserSettings#isColumnReorderingEnabled

Returns:boolean

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

See Also
com.univocity.parsers.common.CommonParserSettings, com.univocity.parsers.common.CommonSettings
commentsback to summary
public Map<Long, String> comments()

Returns all comments collected by the parser so far. An empty map will be returned if CommonParserSettings#isCommentCollectionEnabled() evaluates to false.

Returns:Map<Long, String>

a map containing the line numbers and comments found in each.

currentCharback to summary
public long currentChar()

Returns the index of the last char read from the input so far.

Returns:long

the index of the last char read from the input so far.

currentLineback to summary
public long currentLine()

Returns the current line of text being processed by the parser

Returns:long

current line of text being processed by the parser

currentParsedContentback to summary
public String currentParsedContent()

Returns a String with the input character sequence parsed to produce the current record.

Returns:String

the text content parsed for the current input record.

currentParsedContentLengthback to summary
public int currentParsedContentLength()

Returns the length of the character sequence parsed to produce the current record.

Returns:int

the length of the text content parsed for the current input record

extractedFieldIndexesback to summary
public int[] extractedFieldIndexes()

Redeclares com.univocity.parsers.common.Context.extractedFieldIndexes.

Returns the indexes of each field extracted from the input when fields are selected in the parser settings (i.e. using CommonSettings#selectFields and friends).

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.

See Also
com.univocity.parsers.common.CommonSettings
fieldContentOnErrorback to summary
public String fieldContentOnError()

Returns a String with the input character sequence accumulated on a field before TextParsingException occurred.

Returns:String

the text content parsed for the current field of the current input record at the time of the error.

headersback to summary
public String[] headers()

Redeclares com.univocity.parsers.common.Context.headers.

Returns the file headers that identify each parsed record.

If the headers are extracted from the input (i.e. CommonParserSettings#isHeaderExtractionEnabled() == true), then these values will be returned.

If no headers are extracted from the input, then the configured headers in CommonSettings#getHeaders() will be returned. Note that the user-provided headers will override the header list parsed from the input, if any. To obtain the original list of headers found in the input use ParsingContext#parsedHeaders()

Returns:String[]

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

See Also
com.univocity.parsers.common.CommonParserSettings, com.univocity.parsers.common.CommonSettings
lastCommentback to summary
public String lastComment()

Returns the last comment found in the input. null will be returned if CommonParserSettings#isCommentCollectionEnabled() is evaluated to false.

Returns:String

the last comment found in the input.

lineSeparatorback to summary
public char[] lineSeparator()

Returns the line separator characters used to separate individual records when parsing. This could be the line separator defined in the Format#getLineSeparator() configuration, or the line separator sequence identified automatically when CommonParserSettings#isLineSeparatorDetectionEnabled() evaluates to true.

Returns:char[]

the line separator sequence. Might contain one or two characters.

parsedHeadersback to summary
public String[] parsedHeaders()

Returns the headers parsed from the input, if and only if CommonParserSettings#headerExtractionEnabled is true. The result of this method won't return the list of headers manually set by the user in CommonParserSettings#getHeaders(). Use the headers() method instead to obtain the headers actually used by the parser.

Returns:String[]

the headers parsed from the input, when CommonParserSettings#headerExtractionEnabled is true.

skipLinesback to summary
public void skipLines(long lines)

Skips a given number of lines from the current position.

Parameters
lines:long

the number of lines to be skipped.