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

public Class DefaultParsingContext

extends DefaultContext
implements ParsingContext
Class Inheritance
All Implemented Interfaces
com.univocity.parsers.common.ParsingContext, com.univocity.parsers.common.Context
Imports
com.univocity.parsers.common.input.*, java.util.*

The default ParsingContext implementation used internally by AbstractParser to expose information about a parsing process in execution.
Author
Univocity Software Pty Ltd - [email protected]
See Also
com.univocity.parsers.common.ParsingContext, com.univocity.parsers.common.AbstractParser, com.univocity.parsers.common.processor.RowProcessor

Field Summary

Modifier and TypeField and Description
private final CharInputReader
private final AbstractParser<?>
Inherited from com.univocity.parsers.common.DefaultContext:
columnMaperrorContentLengthoutputrecordFactorystopped

Constructor Summary

AccessConstructor and Description
public
DefaultParsingContext(AbstractParser<?> parser, int errorContentLength)

Method Summary

Modifier and TypeMethod and Description
public Map<Long, String>
comments()

Implements com.univocity.parsers.common.ParsingContext.comments.

Returns all comments collected by the parser so far.
public long
currentChar()

Implements com.univocity.parsers.common.ParsingContext.currentChar.

Returns the index of the last char read from the input so far.
public long
currentLine()

Implements com.univocity.parsers.common.ParsingContext.currentLine.

Returns the current line of text being processed by the parser
public String
currentParsedContent()

Implements com.univocity.parsers.common.ParsingContext.currentParsedContent.

Returns a String with the input character sequence parsed to produce the current record.
public int
currentParsedContentLength()

Implements com.univocity.parsers.common.ParsingContext.currentParsedContentLength.

Returns the length of the character sequence parsed to produce the current record.
public String
fieldContentOnError()

Implements com.univocity.parsers.common.ParsingContext.fieldContentOnError.

Returns a String with the input character sequence accumulated on a field before TextParsingException occurred.
public String
lastComment()

Implements com.univocity.parsers.common.ParsingContext.lastComment.

Returns the last comment found in the input.
public char[]
lineSeparator()

Implements com.univocity.parsers.common.ParsingContext.lineSeparator.

Returns the line separator characters used to separate individual records when parsing.
public String[]
parsedHeaders()

Implements com.univocity.parsers.common.ParsingContext.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
)

Implements com.univocity.parsers.common.ParsingContext.skipLines.

Skips a given number of lines from the current position.
Inherited from com.univocity.parsers.common.DefaultContext:
columnsReorderedcurrentColumncurrentRecorderrorContentLengthextractedFieldIndexesheadersindexOfindexOfisStoppedrecordMetaDataresetselectedHeadersstoptoRecord

Field Detail

inputback to summary
private final CharInputReader input
parserback to summary
private final AbstractParser<?> parser

Constructor Detail

DefaultParsingContextback to summary
public DefaultParsingContext(AbstractParser<?> parser, int errorContentLength)

Method Detail

commentsback to summary
public Map<Long, String> comments()

Implements com.univocity.parsers.common.ParsingContext.comments.

Doc from com.univocity.parsers.common.ParsingContext.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.

Annotations
@Override
currentCharback to summary
public long currentChar()

Implements com.univocity.parsers.common.ParsingContext.currentChar.

Doc from com.univocity.parsers.common.ParsingContext.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.

Annotations
@Override
currentLineback to summary
public long currentLine()

Implements com.univocity.parsers.common.ParsingContext.currentLine.

Doc from com.univocity.parsers.common.ParsingContext.currentLine.

Returns the current line of text being processed by the parser

Returns:long

current line of text being processed by the parser

Annotations
@Override
currentParsedContentback to summary
public String currentParsedContent()

Implements com.univocity.parsers.common.ParsingContext.currentParsedContent.

Doc from com.univocity.parsers.common.ParsingContext.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.

Annotations
@Override
currentParsedContentLengthback to summary
public int currentParsedContentLength()

Implements com.univocity.parsers.common.ParsingContext.currentParsedContentLength.

Doc from com.univocity.parsers.common.ParsingContext.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

Annotations
@Override
fieldContentOnErrorback to summary
public String fieldContentOnError()

Implements com.univocity.parsers.common.ParsingContext.fieldContentOnError.

Doc from com.univocity.parsers.common.ParsingContext.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.

Annotations
@Override
lastCommentback to summary
public String lastComment()

Implements com.univocity.parsers.common.ParsingContext.lastComment.

Doc from com.univocity.parsers.common.ParsingContext.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.

Annotations
@Override
lineSeparatorback to summary
public char[] lineSeparator()

Implements com.univocity.parsers.common.ParsingContext.lineSeparator.

Doc from com.univocity.parsers.common.ParsingContext.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.

Annotations
@Override
parsedHeadersback to summary
public String[] parsedHeaders()

Implements com.univocity.parsers.common.ParsingContext.parsedHeaders.

Doc from com.univocity.parsers.common.ParsingContext.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.

Annotations
@Override
skipLinesback to summary
public void skipLines(long lines)

Implements com.univocity.parsers.common.ParsingContext.skipLines.

Doc from com.univocity.parsers.common.ParsingContext.skipLines.

Skips a given number of lines from the current position.

Parameters
lines:long

the number of lines to be skipped.

Annotations
@Override