com.univocity.parsers.common
Interface ParsingContext

All Known Implementing Classes:
ParsingContextWrapper

public interface ParsingContext

Context information available to instances of RowProcessor.

The ParsingContext can be used to control and to obtain information about the parsing process.

Author:
uniVocity Software Pty Ltd - [email protected]
See Also:
RowProcessor, DefaultParsingContext

Method Summary
 boolean columnsReordered()
          Indicates whether selected fields (using CommonSettings.selectFields(java.lang.String...) and friends) are being reordered.
 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 parser
 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 input
 int[] extractedFieldIndexes()
          Returns the indexes of each field extracted from the input when fields are selected in the parser settings (i.e.
 String[] headers()
          Returns the file headers that identify each parsed record.
 boolean isStopped()
          Identifies whether the parser is running.
 void skipLines(int lines)
          Skips a given number of lines from the current position.
 void stop()
          Stops the parsing process.
 

Method Detail

stop

void stop()
Stops the parsing process. Any open resources in use by the parser are closed automatically.


isStopped

boolean isStopped()
Identifies whether the parser is running.

Returns:
true if the parser is stopped, false otherwise.

currentLine

long currentLine()
Returns the current line of text being processed by the parser

Returns:
current line of text being processed by the parser

currentChar

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

Returns:
the index of the last char read from the input so far.

currentColumn

int currentColumn()
Returns the column index of the record being processed.

Returns:
the column index of the record being processed.

currentRecord

long currentRecord()
Returns the index of the last valid record parsed from the input

Returns:
the index of the last valid record parsed from the input

skipLines

void skipLines(int lines)
Skips a given number of lines from the current position.

Parameters:
lines - the number of lines to be skipped.

headers

String[] headers()
Returns the file headers that identify each parsed record.

If the headers are extracted from the input (i.e. CommonParserSettings.isHeaderExtractionEnabled() == true), then these values will be returned.

If no headers are extracted from the input, then the configured headers in CommonSettings.getHeaders() will be returned.

Returns:
the headers used to identify each record parsed from the input.
See Also:
CommonParserSettings, CommonSettings

extractedFieldIndexes

int[] extractedFieldIndexes()
Returns the indexes of each field extracted from the input when fields are selected in the parser settings (i.e. using CommonSettings.selectFields(java.lang.String...) and friends).

The indexes are relative to their original position in the input.

For example, if the input has the fields "A, B, C, D", and the selected fields are "A, D", then the extracted field indexes will return [0, 3]

If no fields were selected, then this method will return null. This means all fields are being parsed.

Returns:
The indexes of each selected field; null if no fields were selected.
See Also:
CommonSettings

columnsReordered

boolean columnsReordered()
Indicates whether selected fields (using CommonSettings.selectFields(java.lang.String...) and friends) are being reordered.

If columns are reordered, each parsed record will contain values only for the selected fields, as specified by CommonParserSettings.isColumnReorderingEnabled()

Returns:
true if the parsed records are being reordered by the parser, false otherwise
See Also:
CommonParserSettings, CommonSettings

currentParsedContent

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

Returns:
the text content parsed for the current input record.


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