class NoopParsingContext extends java.lang.Object implements ParsingContext
ParsingContext
implementation that does nothing.Modifier and Type | Field and Description |
---|---|
(package private) static NoopParsingContext |
instance |
Modifier | Constructor and Description |
---|---|
private |
NoopParsingContext() |
Modifier and Type | Method and Description |
---|---|
boolean |
columnsReordered()
Indicates whether selected fields (using
CommonSettings.selectFields(java.lang.String...) and friends) are being reordered. |
java.util.Map<java.lang.Long,java.lang.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.
|
int |
currentColumn()
Returns the column index of the record being processed.
|
long |
currentLine()
Returns the current line of text being processed by the parser
|
java.lang.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 |
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 in the parser settings (i.e.
|
java.lang.String |
fieldContentOnError()
Returns a String with the input character sequence accumulated on a field before
TextParsingException occurred. |
java.lang.String[] |
headers()
Returns the file headers that identify each parsed record.
|
int |
indexOf(java.lang.Enum<?> header)
Returns the position of a header (0 based).
|
int |
indexOf(java.lang.String header)
Returns the position of a header (0 based).
|
boolean |
isStopped()
Identifies whether the parser is running.
|
java.lang.String |
lastComment()
Returns the last comment found in the input.
|
char[] |
lineSeparator()
Returns the line separator characters used to separate individual records when parsing.
|
java.lang.String[] |
parsedHeaders()
Returns the headers parsed from the input, if and only if
CommonParserSettings.headerExtractionEnabled is true . |
java.lang.String[] |
selectedHeaders()
Returns the sequence of headers that have been selected.
|
void |
skipLines(long lines)
Skips a given number of lines from the current position.
|
void |
stop()
Stops the parsing process.
|
static final NoopParsingContext instance
public void stop()
Context
public boolean isStopped()
Context
public long currentLine()
ParsingContext
currentLine
in interface ParsingContext
public long currentChar()
ParsingContext
currentChar
in interface ParsingContext
public int currentColumn()
Context
currentColumn
in interface Context
public long currentRecord()
Context
currentRecord
in interface Context
public void skipLines(long lines)
ParsingContext
skipLines
in interface ParsingContext
lines
- the number of lines to be skipped.public java.lang.String[] parsedHeaders()
ParsingContext
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.parsedHeaders
in interface ParsingContext
CommonParserSettings.headerExtractionEnabled
is true
.public java.lang.String currentParsedContent()
ParsingContext
currentParsedContent
in interface ParsingContext
public java.util.Map<java.lang.Long,java.lang.String> comments()
ParsingContext
CommonParserSettings.isCommentCollectionEnabled()
evaluates to false
.comments
in interface ParsingContext
public java.lang.String lastComment()
ParsingContext
null
will be returned if CommonParserSettings.isCommentCollectionEnabled()
is evaluated to false
.lastComment
in interface ParsingContext
public char[] lineSeparator()
ParsingContext
Format.getLineSeparator()
configuration, or the line separator sequence
identified automatically when CommonParserSettings.isLineSeparatorDetectionEnabled()
evaluates to true
.lineSeparator
in interface ParsingContext
public java.lang.String[] headers()
ParsingContext
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.
Note that the user-provided headers will override the header list parsed from the input, if any. To obtain the
original list of headers found in the input use ParsingContext.parsedHeaders()
headers
in interface Context
headers
in interface ParsingContext
CommonParserSettings
,
CommonSettings
public java.lang.String[] selectedHeaders()
Context
Context.headers()
.selectedHeaders
in interface Context
public int[] extractedFieldIndexes()
ParsingContext
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.
extractedFieldIndexes
in interface Context
extractedFieldIndexes
in interface ParsingContext
CommonSettings
public boolean columnsReordered()
ParsingContext
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()
columnsReordered
in interface Context
columnsReordered
in interface ParsingContext
CommonParserSettings
,
CommonSettings
public int indexOf(java.lang.String header)
Context
public int indexOf(java.lang.Enum<?> header)
Context
public java.lang.String fieldContentOnError()
ParsingContext
TextParsingException
occurred.fieldContentOnError
in interface ParsingContext
public int errorContentLength()
Context
If 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 Context