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 aParsingContextwhich retains copies of variable attributes of a givenParsingContextto 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>commentsprivate longcurrentCharprivate intcurrentColumnprivate longcurrentLineprivate java.lang.StringcurrentParsedContentprivate longcurrentRecordprivate java.lang.StringlastComment-
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.longcurrentChar()Returns the index of the last char read from the input so far.intcurrentColumn()Returns the column index of the record being processed.longcurrentLine()Returns the current line of text being processed by the parserjava.lang.StringcurrentParsedContent()Returns a String with the input character sequence parsed to produce the current record.longcurrentRecord()Returns the index of the last valid record parsed from the inputjava.lang.StringlastComment()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:ParsingContextReturns the current line of text being processed by the parser- Specified by:
currentLinein interfaceParsingContext- Overrides:
currentLinein classParsingContextWrapper- 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- Overrides:
currentCharin 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:ParsingContextReturns all comments collected by the parser so far. An empty map will be returned ifCommonParserSettings.isCommentCollectionEnabled()evaluates tofalse.- Specified by:
commentsin interfaceParsingContext- Overrides:
commentsin classParsingContextWrapper- Returns:
- a map containing the line numbers and comments found in each.
-
lastComment
public java.lang.String 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- Overrides:
lastCommentin classParsingContextWrapper- Returns:
- the last comment found in the input.
-
currentColumn
public int currentColumn()
Description copied from interface:ContextReturns the column index of the record being processed.- Specified by:
currentColumnin interfaceContext- Overrides:
currentColumnin classContextWrapper<ParsingContext>- Returns:
- the column index of the record being processed.
-
currentParsedContent
public java.lang.String currentParsedContent()
Description copied from interface:ParsingContextReturns a String with the input character sequence parsed to produce the current record.- Specified by:
currentParsedContentin interfaceParsingContext- Overrides:
currentParsedContentin classParsingContextWrapper- Returns:
- the text content parsed for the current input record.
-
currentRecord
public long currentRecord()
Description copied from interface:ContextReturns the index of the last valid record parsed from the input- Specified by:
currentRecordin interfaceContext- Overrides:
currentRecordin classContextWrapper<ParsingContext>- Returns:
- the index of the last valid record parsed from the input
-
-