Class NoopParsingContext
- All Implemented Interfaces:
Context
,ParsingContext
ParsingContext
implementation that does nothing.-
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final NoopParsingContext
private RecordMetaData
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
Indicates whether selected fields (usingCommonSettings.selectFields(java.lang.String...)
and friends) are being reordered.comments()
Returns all comments collected by the parser so far.long
Returns the index of the last char read from the input so far.int
Returns the column index of the record being processed.long
Returns the current line of text being processed by the parserReturns a String with the input character sequence parsed to produce the current record.int
Returns the length of the character sequence parsed to produce the current record.long
Returns the index of the last valid record parsed from the inputint
Returns the length limit of parsed contents appearing in exception messages when an error occursint[]
Returns the indexes of each field extracted from the input when fields are selected in the parser settings (i.e.Returns a String with the input character sequence accumulated on a field beforeTextParsingException
occurred.String[]
headers()
Returns the file headers that identify each parsed record.int
Returns the position of a header (0 based).int
Returns the position of a header (0 based).boolean
Identifies whether the parser is running.Returns the last comment found in the input.char[]
Returns the line separator characters used to separate individual records when parsing.String[]
Returns the headers parsed from the input, if and only ifCommonParserSettings.headerExtractionEnabled
istrue
.Returns the metadata information associated with records produced by the current parsing process.String[]
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.Converts the given parsed row to aRecord
-
Field Details
-
instance
-
recordMetaData
-
-
Constructor Details
-
NoopParsingContext
private NoopParsingContext()
-
-
Method Details
-
stop
public void stop()Description copied from interface:Context
Stops the parsing process. Any open resources in use by the parser are closed automatically unlessCommonParserSettings.isAutoClosingEnabled()
evaluates tofalse
. -
isStopped
public boolean isStopped()Description copied from interface:Context
Identifies whether the parser is running. -
currentLine
public long currentLine()Description copied from interface:ParsingContext
Returns the current line of text being processed by the parser- Specified by:
currentLine
in interfaceParsingContext
- 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 interfaceParsingContext
- Returns:
- the index of the last char read from the input so far.
-
currentColumn
public int currentColumn()Description copied from interface:Context
Returns the column index of the record being processed.- Specified by:
currentColumn
in interfaceContext
- 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 interfaceContext
- Returns:
- the index of the last valid record parsed from the input
-
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 interfaceParsingContext
- Parameters:
lines
- the number of lines to be skipped.
-
parsedHeaders
Description copied from interface:ParsingContext
Returns the headers parsed from the input, if and only ifCommonParserSettings.headerExtractionEnabled
istrue
. The result of this method won't return the list of headers manually set by the user inCommonSettings.getHeaders()
. Use theParsingContext.headers()
method instead to obtain the headers actually used by the parser.- Specified by:
parsedHeaders
in interfaceParsingContext
- Returns:
- the headers parsed from the input, when
CommonParserSettings.headerExtractionEnabled
istrue
.
-
currentParsedContent
Description copied from interface:ParsingContext
Returns a String with the input character sequence parsed to produce the current record.- Specified by:
currentParsedContent
in interfaceParsingContext
- Returns:
- the text content parsed for the current input record.
-
currentParsedContentLength
public int currentParsedContentLength()Description copied from interface:ParsingContext
Returns the length of the character sequence parsed to produce the current record.- Specified by:
currentParsedContentLength
in interfaceParsingContext
- Returns:
- the length of the text content parsed for the current input record
-
comments
Description copied from interface:ParsingContext
Returns all comments collected by the parser so far. An empty map will be returned ifCommonParserSettings.isCommentCollectionEnabled()
evaluates tofalse
.- Specified by:
comments
in interfaceParsingContext
- Returns:
- a map containing the line numbers and comments found in each.
-
lastComment
Description copied from interface:ParsingContext
Returns the last comment found in the input.null
will be returned ifCommonParserSettings.isCommentCollectionEnabled()
is evaluated tofalse
.- Specified by:
lastComment
in interfaceParsingContext
- Returns:
- the last comment found in the input.
-
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 theFormat.getLineSeparator()
configuration, or the line separator sequence identified automatically whenCommonParserSettings.isLineSeparatorDetectionEnabled()
evaluates totrue
.- Specified by:
lineSeparator
in interfaceParsingContext
- Returns:
- the line separator sequence. Might contain one or two characters.
-
headers
Description copied from interface:ParsingContext
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. 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 useParsingContext.parsedHeaders()
- Specified by:
headers
in interfaceContext
- Specified by:
headers
in interfaceParsingContext
- Returns:
- the headers used to identify each record parsed from the input.
- See Also:
-
selectedHeaders
Description copied from interface:Context
Returns the sequence of headers that have been selected. If no selection has been made, all available headers will be returned, producing the same output as a call to methodContext.headers()
.- Specified by:
selectedHeaders
in interfaceContext
- Returns:
- the sequence of selected headers, or all headers if no selection has been made.
-
extractedFieldIndexes
public int[] extractedFieldIndexes()Description copied from interface:ParsingContext
Returns the indexes of each field extracted from the input when fields are selected in the parser settings (i.e. usingCommonSettings.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.
- Specified by:
extractedFieldIndexes
in interfaceContext
- Specified by:
extractedFieldIndexes
in interfaceParsingContext
- Returns:
- The indexes of each selected field; null if no fields were selected.
- See Also:
-
columnsReordered
public boolean columnsReordered()Description copied from interface:ParsingContext
Indicates whether selected fields (usingCommonSettings.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()
- Specified by:
columnsReordered
in interfaceContext
- Specified by:
columnsReordered
in interfaceParsingContext
- Returns:
- true if the parsed records are being reordered by the parser, false otherwise
- See Also:
-
indexOf
Description copied from interface:Context
Returns the position of a header (0 based). -
indexOf
Description copied from interface:Context
Returns the position of a header (0 based). -
fieldContentOnError
Description copied from interface:ParsingContext
Returns a String with the input character sequence accumulated on a field beforeTextParsingException
occurred.- Specified by:
fieldContentOnError
in interfaceParsingContext
- Returns:
- the text content parsed for the current field of the current input record at the time of the error.
-
errorContentLength
public int errorContentLength()Description copied from interface:Context
Returns the length limit of parsed contents appearing in exception messages when an error occursIf
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)- Specified by:
errorContentLength
in interfaceContext
- Returns:
- the maximum length of the data content to display in exception messages
-
toRecord
Description copied from interface:Context
Converts the given parsed row to aRecord
-
recordMetaData
Description copied from interface:Context
Returns the metadata information associated with records produced by the current parsing process.- Specified by:
recordMetaData
in interfaceContext
- Returns:
- the record metadata.
-