com.univocity.parsers.common
Class ParsingContextWrapper

java.lang.Object
  extended by com.univocity.parsers.common.ContextWrapper<ParsingContext>
      extended by com.univocity.parsers.common.ParsingContextWrapper
All Implemented Interfaces:
Context, ParsingContext
Direct Known Subclasses:
ParsingContextSnapshot

public class ParsingContextWrapper
extends ContextWrapper<ParsingContext>
implements ParsingContext

A simple a wrapper for a ParsingContext.

Author:
uniVocity Software Pty Ltd - parsers@univocity.com

Field Summary
 
Fields inherited from class com.univocity.parsers.common.ContextWrapper
context
 
Constructor Summary
ParsingContextWrapper(ParsingContext context)
          Wraps a ParsingContext.
 
Method Summary
 Map<Long,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.
 long currentLine()
          Returns the current line of text being processed by the parser
 String currentParsedContent()
          Returns a String with the input character sequence parsed to produce the current record.
 String fieldContentOnError()
          Returns a String with the input character sequence accumulated on a field before TextParsingException occurred.
 String lastComment()
          Returns the last comment found in the input.
 char[] lineSeparator()
          Returns the line separator characters used to separate individual records when parsing.
 String[] parsedHeaders()
          Returns the headers parsed from the input, if and only if CommonParserSettings.headerExtractionEnabled is true.
 String[] selectedHeaders()
           
 void skipLines(long lines)
          Skips a given number of lines from the current position.
 
Methods inherited from class com.univocity.parsers.common.ContextWrapper
columnsReordered, currentColumn, currentRecord, extractedFieldIndexes, headers, indexOf, indexOf, isStopped, 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.ParsingContext
columnsReordered, extractedFieldIndexes, headers
 
Methods inherited from interface com.univocity.parsers.common.Context
currentColumn, currentRecord, indexOf, indexOf, isStopped, stop
 

Constructor Detail

ParsingContextWrapper

public ParsingContextWrapper(ParsingContext context)
Wraps a ParsingContext.

Parameters:
context - the parsingContext object to be wrapped.
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 interface ParsingContext
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 interface ParsingContext
Returns:
the index of the last char read from the input so far.

skipLines

public void skipLines(long lines)
Description copied from interface: ParsingContext
Skips a given number of lines from the current position.

Specified by:
skipLines in interface ParsingContext
Parameters:
lines - the number of lines to be skipped.

currentParsedContent

public 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 interface ParsingContext
Returns:
the text content parsed for the current input record.

comments

public Map<Long,String> comments()
Description copied from interface: ParsingContext
Returns all comments collected by the parser so far. An empty map will be returned if CommonParserSettings.isCommentCollectionEnabled() evaluates to false.

Specified by:
comments in interface ParsingContext
Returns:
a map containing the line numbers and comments found in each.

lastComment

public String lastComment()
Description copied from interface: ParsingContext
Returns the last comment found in the input. null will be returned if CommonParserSettings.isCommentCollectionEnabled() is evaluated to false.

Specified by:
lastComment in interface ParsingContext
Returns:
the last comment found in the input.

parsedHeaders

public String[] parsedHeaders()
Description copied from interface: ParsingContext
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 CommonSettings.getHeaders(). Use the ParsingContext.headers() method instead to obtain the headers actually used by the parser.

Specified by:
parsedHeaders in interface ParsingContext
Returns:
the headers parsed from the input, when CommonParserSettings.headerExtractionEnabled is true.

lineSeparator

public char[] lineSeparator()
Description copied from interface: ParsingContext
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.

Specified by:
lineSeparator in interface ParsingContext
Returns:
the line separator sequence. Might contain one or two characters.

fieldContentOnError

public String fieldContentOnError()
Description copied from interface: ParsingContext
Returns a String with the input character sequence accumulated on a field before TextParsingException occurred.

Specified by:
fieldContentOnError in interface ParsingContext
Returns:
the text content parsed for the current field of the current input record at the time of the error.

selectedHeaders

public String[] selectedHeaders()
Specified by:
selectedHeaders in interface Context
Overrides:
selectedHeaders in class ContextWrapper<ParsingContext>


Copyright © 2016 uniVocity Software Pty Ltd. All rights reserved.