Package com.univocity.parsers.common
Class ParsingContextSnapshot
- java.lang.Object
-
- com.univocity.parsers.common.ContextWrapper<ParsingContext>
-
- com.univocity.parsers.common.ParsingContextWrapper
-
- com.univocity.parsers.common.ParsingContextSnapshot
-
- All Implemented Interfaces:
Context
,ParsingContext
public class ParsingContextSnapshot extends ParsingContextWrapper
A snapshot of aParsingContext
which retains copies of variable attributes of a givenParsingContext
to store the state of the parsing process at a given point in time. All runtime operations such asContextWrapper.stop()
will still work and affect the current parsing process.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<java.lang.Long,java.lang.String>
comments
private long
currentChar
private int
currentColumn
private long
currentLine
private java.lang.String
currentParsedContent
private long
currentRecord
private java.lang.String
lastComment
-
Fields inherited from class com.univocity.parsers.common.ContextWrapper
context
-
-
Constructor Summary
Constructors Constructor Description ParsingContextSnapshot(ParsingContext context)
Creates a snapshot of a givenContext
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Map<java.lang.Long,java.lang.String>
comments()
Returns all comments collected by the parser so far.long
currentChar()
Returns the index of the last char read from the input so far.int
currentColumn()
Returns the column index of the record being processed.long
currentLine()
Returns the current line of text being processed by the parserjava.lang.String
currentParsedContent()
Returns a String with the input character sequence parsed to produce the current record.long
currentRecord()
Returns the index of the last valid record parsed from the inputjava.lang.String
lastComment()
Returns the last comment found in the input.-
Methods inherited from class com.univocity.parsers.common.ParsingContextWrapper
currentParsedContentLength, fieldContentOnError, lineSeparator, parsedHeaders, selectedHeaders, skipLines, toRecord
-
Methods inherited from class com.univocity.parsers.common.ContextWrapper
columnsReordered, errorContentLength, extractedFieldIndexes, headers, indexOf, indexOf, isStopped, recordMetaData, stop
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.univocity.parsers.common.Context
errorContentLength, indexOf, indexOf, isStopped, recordMetaData, stop
-
Methods inherited from interface com.univocity.parsers.common.ParsingContext
columnsReordered, extractedFieldIndexes, headers
-
-
-
-
Field Detail
-
currentLine
private final long currentLine
-
currentChar
private final long currentChar
-
comments
private final java.util.Map<java.lang.Long,java.lang.String> comments
-
lastComment
private final java.lang.String lastComment
-
currentColumn
private final int currentColumn
-
currentParsedContent
private final java.lang.String currentParsedContent
-
currentRecord
private final long currentRecord
-
-
Constructor Detail
-
ParsingContextSnapshot
public ParsingContextSnapshot(ParsingContext context)
Creates a snapshot of a givenContext
- Parameters:
context
- the context object whose variable attributes will be copied over.
-
-
Method Detail
-
currentLine
public long currentLine()
Description copied from interface:ParsingContext
Returns the current line of text being processed by the parser- Specified by:
currentLine
in interfaceParsingContext
- Overrides:
currentLine
in classParsingContextWrapper
- Returns:
- current line of text being processed by the parser
-
currentChar
public long currentChar()
Description copied from interface:ParsingContext
Returns the index of the last char read from the input so far.- Specified by:
currentChar
in interfaceParsingContext
- Overrides:
currentChar
in classParsingContextWrapper
- Returns:
- the index of the last char read from the input so far.
-
comments
public java.util.Map<java.lang.Long,java.lang.String> comments()
Description copied from interface:ParsingContext
Returns all comments collected by the parser so far. An empty map will be returned ifCommonParserSettings.isCommentCollectionEnabled()
evaluates tofalse
.- Specified by:
comments
in interfaceParsingContext
- Overrides:
comments
in classParsingContextWrapper
- Returns:
- a map containing the line numbers and comments found in each.
-
lastComment
public java.lang.String lastComment()
Description copied from interface:ParsingContext
Returns the last comment found in the input.null
will be returned ifCommonParserSettings.isCommentCollectionEnabled()
is evaluated tofalse
.- Specified by:
lastComment
in interfaceParsingContext
- Overrides:
lastComment
in classParsingContextWrapper
- Returns:
- the last comment found in the input.
-
currentColumn
public int currentColumn()
Description copied from interface:Context
Returns the column index of the record being processed.- Specified by:
currentColumn
in interfaceContext
- Overrides:
currentColumn
in classContextWrapper<ParsingContext>
- Returns:
- the column index of the record being processed.
-
currentParsedContent
public java.lang.String currentParsedContent()
Description copied from interface:ParsingContext
Returns a String with the input character sequence parsed to produce the current record.- Specified by:
currentParsedContent
in interfaceParsingContext
- Overrides:
currentParsedContent
in classParsingContextWrapper
- Returns:
- the text content parsed for the current input record.
-
currentRecord
public long currentRecord()
Description copied from interface:Context
Returns the index of the last valid record parsed from the input- Specified by:
currentRecord
in interfaceContext
- Overrides:
currentRecord
in classContextWrapper<ParsingContext>
- Returns:
- the index of the last valid record parsed from the input
-
-