public class DefaultContext extends Object implements Context
Context interface with essential information about the output being produced.| Modifier and Type | Field and Description |
|---|---|
protected RecordFactory |
recordFactory |
protected boolean |
stopped |
| Constructor and Description |
|---|
DefaultContext(int errorContentLength) |
DefaultContext(ParserOutput output,
int errorContentLength) |
| Modifier and Type | Method and Description |
|---|---|
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 |
errorContentLength()
Returns the length limit of parsed contents appearing in exception messages when an error occurs
|
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.
|
RecordMetaData |
recordMetaData()
Returns the metadata information associated with records produced by the current parsing process.
|
String[] |
selectedHeaders()
Returns the sequence of headers that have been selected.
|
void |
stop()
Stops the parsing process.
|
Record |
toRecord(String[] row)
Converts the given parsed row to a
Record |
protected boolean stopped
protected RecordFactory recordFactory
public DefaultContext(int errorContentLength)
public DefaultContext(ParserOutput output, int errorContentLength)
public String[] headers()
Contextpublic String[] selectedHeaders()
ContextContext.headers().selectedHeaders in interface Contextpublic int[] extractedFieldIndexes()
ContextThe 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.
extractedFieldIndexes in interface ContextCommonSettingspublic boolean columnsReordered()
ContextIf columns are reordered, each parsed record will contain values only for the selected fields, as specified by Context.extractedFieldIndexes()
columnsReordered in interface ContextCommonParserSettings,
CommonSettingspublic int indexOf(String header)
Contextpublic int indexOf(Enum<?> header)
Contextpublic int currentColumn()
ContextcurrentColumn in interface Contextpublic long currentRecord()
ContextcurrentRecord in interface Contextpublic void stop()
Contextpublic boolean isStopped()
Contextpublic int errorContentLength()
ContextIf 0, then no exceptions will include the content being manipulated in their attributes,
and the "<omitted>" string will appear in error messages as the parsed content.
defaults to -1 (no limit)
errorContentLength in interface Contextpublic Record toRecord(String[] row)
ContextRecordpublic RecordMetaData recordMetaData()
ContextrecordMetaData in interface ContextCopyright © 2018 Univocity Software Pty Ltd. All rights reserved.