Class ParsingContextWrapper
java.lang.Object
com.univocity.parsers.common.ContextWrapper<ParsingContext>
com.univocity.parsers.common.ParsingContextWrapper
- All Implemented Interfaces:
Context, ParsingContext
- Direct Known Subclasses:
ParsingContextSnapshot
A simple a wrapper for a
ParsingContext.- Author:
- Univocity Software Pty Ltd - parsers@univocity.com
-
Field Summary
Fields inherited from class ContextWrapper
context -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncomments()Returns all comments collected by the parser so far.longReturns the index of the last char read from the input so far.longReturns the current line of text being processed by the parserReturns a String with the input character sequence parsed to produce the current record.intReturns the length of the character sequence parsed to produce the current record.Returns a String with the input character sequence accumulated on a field beforeTextParsingExceptionoccurred.Returns the last comment found in the input.char[]Returns the line separator characters used to separate individual records when parsing.String[]Returns the headers parsed from the input, if and only ifCommonParserSettings.headerExtractionEnabledistrue.String[]Returns the sequence of headers that have been selected.voidskipLines(long lines) Skips a given number of lines from the current position.Converts the given parsed row to aRecordMethods inherited from class ContextWrapper
columnsReordered, currentColumn, currentRecord, errorContentLength, extractedFieldIndexes, headers, indexOf, indexOf, isStopped, recordMetaData, stopMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Context
currentColumn, currentRecord, errorContentLength, indexOf, indexOf, isStopped, recordMetaData, stopMethods inherited from interface ParsingContext
columnsReordered, extractedFieldIndexes, headers
-
Constructor Details
-
ParsingContextWrapper
Wraps aParsingContext.- Parameters:
context- the parsingContext object to be wrapped.
-
-
Method Details
-
currentLine
public long currentLine()Description copied from interface:ParsingContextReturns the current line of text being processed by the parser- Specified by:
currentLinein interfaceParsingContext- Returns:
- current line of text being processed by the parser
-
currentChar
public long currentChar()Description copied from interface:ParsingContextReturns the index of the last char read from the input so far.- Specified by:
currentCharin interfaceParsingContext- Returns:
- the index of the last char read from the input so far.
-
skipLines
public void skipLines(long lines) Description copied from interface:ParsingContextSkips a given number of lines from the current position.- Specified by:
skipLinesin interfaceParsingContext- Parameters:
lines- the number of lines to be skipped.
-
currentParsedContent
Description copied from interface:ParsingContextReturns a String with the input character sequence parsed to produce the current record.- Specified by:
currentParsedContentin interfaceParsingContext- Returns:
- the text content parsed for the current input record.
-
currentParsedContentLength
public int currentParsedContentLength()Description copied from interface:ParsingContextReturns the length of the character sequence parsed to produce the current record.- Specified by:
currentParsedContentLengthin interfaceParsingContext- Returns:
- the length of the text content parsed for the current input record
-
comments
Description copied from interface:ParsingContextReturns all comments collected by the parser so far. An empty map will be returned ifCommonParserSettings.isCommentCollectionEnabled()evaluates tofalse.- Specified by:
commentsin interfaceParsingContext- Returns:
- a map containing the line numbers and comments found in each.
-
lastComment
Description copied from interface:ParsingContextReturns the last comment found in the input.nullwill be returned ifCommonParserSettings.isCommentCollectionEnabled()is evaluated tofalse.- Specified by:
lastCommentin interfaceParsingContext- Returns:
- the last comment found in the input.
-
parsedHeaders
Description copied from interface:ParsingContextReturns the headers parsed from the input, if and only ifCommonParserSettings.headerExtractionEnabledistrue. The result of this method won't return the list of headers manually set by the user inCommonSettings.getHeaders(). Use theParsingContext.headers()method instead to obtain the headers actually used by the parser.- Specified by:
parsedHeadersin interfaceParsingContext- Returns:
- the headers parsed from the input, when
CommonParserSettings.headerExtractionEnabledistrue.
-
lineSeparator
public char[] lineSeparator()Description copied from interface:ParsingContextReturns the line separator characters used to separate individual records when parsing. This could be the line separator defined in theFormat.getLineSeparator()configuration, or the line separator sequence identified automatically whenCommonParserSettings.isLineSeparatorDetectionEnabled()evaluates totrue.- Specified by:
lineSeparatorin interfaceParsingContext- Returns:
- the line separator sequence. Might contain one or two characters.
-
fieldContentOnError
Description copied from interface:ParsingContextReturns a String with the input character sequence accumulated on a field beforeTextParsingExceptionoccurred.- Specified by:
fieldContentOnErrorin interfaceParsingContext- Returns:
- the text content parsed for the current field of the current input record at the time of the error.
-
selectedHeaders
Description copied from interface:ContextReturns 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 methodContext.headers().- Specified by:
selectedHeadersin interfaceContext- Overrides:
selectedHeadersin classContextWrapper<ParsingContext>- Returns:
- the sequence of selected headers, or all headers if no selection has been made.
-
toRecord
Description copied from interface:ContextConverts the given parsed row to aRecord- Specified by:
toRecordin interfaceContext- Overrides:
toRecordin classContextWrapper<ParsingContext>- Parameters:
row- the row to be converted into aRecord- Returns:
- a
Recordrepresenting the given row.
-