Class NoopParsingContext
- java.lang.Object
-
- com.univocity.parsers.common.NoopParsingContext
-
- All Implemented Interfaces:
Context,ParsingContext
class NoopParsingContext extends java.lang.Object implements ParsingContext
AParsingContextimplementation that does nothing.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static NoopParsingContextinstanceprivate RecordMetaDatarecordMetaData
-
Constructor Summary
Constructors Modifier Constructor Description privateNoopParsingContext()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancolumnsReordered()Indicates whether selected fields (usingCommonSettings.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.longcurrentChar()Returns the index of the last char read from the input so far.intcurrentColumn()Returns the column index of the record being processed.longcurrentLine()Returns the current line of text being processed by the parserjava.lang.StringcurrentParsedContent()Returns a String with the input character sequence parsed to produce the current record.intcurrentParsedContentLength()Returns the length of the character sequence parsed to produce the current record.longcurrentRecord()Returns the index of the last valid record parsed from the inputinterrorContentLength()Returns the length limit of parsed contents appearing in exception messages when an error occursint[]extractedFieldIndexes()Returns the indexes of each field extracted from the input when fields are selected in the parser settings (i.e.java.lang.StringfieldContentOnError()Returns a String with the input character sequence accumulated on a field beforeTextParsingExceptionoccurred.java.lang.String[]headers()Returns the file headers that identify each parsed record.intindexOf(java.lang.Enum<?> header)Returns the position of a header (0 based).intindexOf(java.lang.String header)Returns the position of a header (0 based).booleanisStopped()Identifies whether the parser is running.java.lang.StringlastComment()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 ifCommonParserSettings.headerExtractionEnabledistrue.RecordMetaDatarecordMetaData()Returns the metadata information associated with records produced by the current parsing process.java.lang.String[]selectedHeaders()Returns the sequence of headers that have been selected.voidskipLines(long lines)Skips a given number of lines from the current position.voidstop()Stops the parsing process.RecordtoRecord(java.lang.String[] row)Converts the given parsed row to aRecord
-
-
-
Field Detail
-
instance
static final NoopParsingContext instance
-
recordMetaData
private RecordMetaData recordMetaData
-
-
Method Detail
-
stop
public void stop()
Description copied from interface:ContextStops 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:ContextIdentifies whether the parser is running.
-
currentLine
public long currentLine()
Description copied from interface:ParsingContextReturns the current line of text being processed by the parser- Specified by:
currentLinein interfaceParsingContext- Returns:
- current line of text being processed by the parser
-
currentChar
public long currentChar()
Description copied from interface:ParsingContextReturns the index of the last char read from the input so far.- Specified by:
currentCharin interfaceParsingContext- Returns:
- the index of the last char read from the input so far.
-
currentColumn
public int currentColumn()
Description copied from interface:ContextReturns the column index of the record being processed.- Specified by:
currentColumnin interfaceContext- Returns:
- the column index of the record being processed.
-
currentRecord
public long currentRecord()
Description copied from interface:ContextReturns the index of the last valid record parsed from the input- Specified by:
currentRecordin interfaceContext- Returns:
- the index of the last valid record parsed from the input
-
skipLines
public void skipLines(long lines)
Description copied from interface:ParsingContextSkips a given number of lines from the current position.- Specified by:
skipLinesin interfaceParsingContext- Parameters:
lines- the number of lines to be skipped.
-
parsedHeaders
public java.lang.String[] parsedHeaders()
Description copied from interface:ParsingContextReturns the headers parsed from the input, if and only ifCommonParserSettings.headerExtractionEnabledistrue. 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:
parsedHeadersin interfaceParsingContext- Returns:
- the headers parsed from the input, when
CommonParserSettings.headerExtractionEnabledistrue.
-
currentParsedContent
public java.lang.String currentParsedContent()
Description copied from interface:ParsingContextReturns a String with the input character sequence parsed to produce the current record.- Specified by:
currentParsedContentin interfaceParsingContext- Returns:
- the text content parsed for the current input record.
-
currentParsedContentLength
public int currentParsedContentLength()
Description copied from interface:ParsingContextReturns the length of the character sequence parsed to produce the current record.- Specified by:
currentParsedContentLengthin interfaceParsingContext- Returns:
- the length of the text content parsed for the current input record
-
comments
public java.util.Map<java.lang.Long,java.lang.String> comments()
Description copied from interface:ParsingContextReturns all comments collected by the parser so far. An empty map will be returned ifCommonParserSettings.isCommentCollectionEnabled()evaluates tofalse.- Specified by:
commentsin interfaceParsingContext- Returns:
- a map containing the line numbers and comments found in each.
-
lastComment
public java.lang.String lastComment()
Description copied from interface:ParsingContextReturns the last comment found in the input.nullwill be returned ifCommonParserSettings.isCommentCollectionEnabled()is evaluated tofalse.- Specified by:
lastCommentin interfaceParsingContext- Returns:
- the last comment found in the input.
-
lineSeparator
public char[] lineSeparator()
Description copied from interface:ParsingContextReturns 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:
lineSeparatorin interfaceParsingContext- Returns:
- the line separator sequence. Might contain one or two characters.
-
headers
public java.lang.String[] headers()
Description copied from interface:ParsingContextReturns 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:
headersin interfaceContext- Specified by:
headersin interfaceParsingContext- Returns:
- the headers used to identify each record parsed from the input.
- See Also:
CommonParserSettings,CommonSettings
-
selectedHeaders
public java.lang.String[] selectedHeaders()
Description copied from interface:ContextReturns 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:
selectedHeadersin interfaceContext- Returns:
- the sequence of selected headers, or all headers if no selection has been made.
-
extractedFieldIndexes
public int[] extractedFieldIndexes()
Description copied from interface:ParsingContextReturns 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:
extractedFieldIndexesin interfaceContext- Specified by:
extractedFieldIndexesin interfaceParsingContext- Returns:
- The indexes of each selected field; null if no fields were selected.
- See Also:
CommonSettings
-
columnsReordered
public boolean columnsReordered()
Description copied from interface:ParsingContextIndicates 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:
columnsReorderedin interfaceContext- Specified by:
columnsReorderedin interfaceParsingContext- Returns:
- true if the parsed records are being reordered by the parser, false otherwise
- See Also:
CommonParserSettings,CommonSettings
-
indexOf
public int indexOf(java.lang.String header)
Description copied from interface:ContextReturns the position of a header (0 based).
-
indexOf
public int indexOf(java.lang.Enum<?> header)
Description copied from interface:ContextReturns the position of a header (0 based).
-
fieldContentOnError
public java.lang.String fieldContentOnError()
Description copied from interface:ParsingContextReturns a String with the input character sequence accumulated on a field beforeTextParsingExceptionoccurred.- Specified by:
fieldContentOnErrorin 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:ContextReturns 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:
errorContentLengthin interfaceContext- Returns:
- the maximum length of the data content to display in exception messages
-
toRecord
public Record toRecord(java.lang.String[] row)
Description copied from interface:ContextConverts the given parsed row to aRecord
-
recordMetaData
public RecordMetaData recordMetaData()
Description copied from interface:ContextReturns the metadata information associated with records produced by the current parsing process.- Specified by:
recordMetaDatain interfaceContext- Returns:
- the record metadata.
-
-