com.univocity.parsers.common
Class DefaultContext

java.lang.Object
  extended by com.univocity.parsers.common.DefaultContext
All Implemented Interfaces:
Context
Direct Known Subclasses:
DefaultParsingContext

public class DefaultContext
extends Object
implements Context

Default implementation of the Context interface with essential information about the output being produced.

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

Field Summary
protected  boolean stopped
           
 
Constructor Summary
DefaultContext(ParserOutput output)
           
 
Method Summary
 boolean columnsReordered()
          Indicates whether selected fields are being reordered.
 int currentColumn()
          Returns the column index of the record being processed.
 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.
 String[] headers()
          Returns the file headers that identify each parsed record.
 int indexOf(Enum<?> header)
          Returns the position of a header (0 based).
 int indexOf(String header)
          Returns the position of a header (0 based).
 boolean isStopped()
          Identifies whether the parser is running.
 String[] selectedHeaders()
           
 void stop()
          Stops the parsing process.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

stopped

protected boolean stopped
Constructor Detail

DefaultContext

public DefaultContext(ParserOutput output)
Method Detail

headers

public String[] headers()
Description copied from interface: Context
Returns the file headers that identify each parsed record.

Specified by:
headers in interface Context
Returns:
the headers used to identify each record parsed from the input.

selectedHeaders

public String[] selectedHeaders()
Specified by:
selectedHeaders in interface Context

extractedFieldIndexes

public int[] extractedFieldIndexes()
Description copied from interface: Context
Returns the indexes of each field extracted from the input when fields are selected.

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.

Specified by:
extractedFieldIndexes in interface Context
Returns:
The indexes of each selected field; null if no fields were selected.
See Also:
CommonSettings

columnsReordered

public boolean columnsReordered()
Description copied from interface: Context
Indicates whether selected fields are being reordered.

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

Specified by:
columnsReordered in interface Context
Returns:
true if the parsed records are being reordered by the parser, false otherwise
See Also:
CommonParserSettings, CommonSettings

indexOf

public int indexOf(String header)
Description copied from interface: Context
Returns the position of a header (0 based).

Specified by:
indexOf in interface Context
Parameters:
header - the header whose position will be returned
Returns:
the position of the given header, or -1 if it could not be found.

indexOf

public int indexOf(Enum<?> header)
Description copied from interface: Context
Returns the position of a header (0 based).

Specified by:
indexOf in interface Context
Parameters:
header - the header whose position will be returned
Returns:
the position of the given header, or -1 if it could not be found.

currentColumn

public int currentColumn()
Description copied from interface: Context
Returns the column index of the record being processed.

Specified by:
currentColumn in interface Context
Returns:
the column index of the record being processed.

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 interface Context
Returns:
the index of the last valid record parsed from the input

stop

public void stop()
Description copied from interface: Context
Stops the parsing process. Any open resources in use by the parser are closed automatically.

Specified by:
stop in interface Context

isStopped

public boolean isStopped()
Description copied from interface: Context
Identifies whether the parser is running.

Specified by:
isStopped in interface Context
Returns:
true if the parser is stopped, false otherwise.


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