Top Description Fields Constructors Methods
com.univocity.parsers.tsv

public Class TsvParser

extends AbstractParser<TsvParserSettings>
Class Inheritance
Imports
com.univocity.parsers.common.*

A very fast TSV parser implementation.
Author
Univocity Software Pty Ltd - [email protected]
See Also
TsvFormat, TsvParserSettings, TsvWriter, AbstractParser

Field Summary

Modifier and TypeField and Description
private final char
private final char
private final boolean
private final char
Inherited from com.univocity.parsers.common.AbstractParser:
chcommentcommentscontextignoreLeadingWhitespaceignoreTrailingWhitespaceinputlastCommentoutputprocessorsettingswhitespaceRangeStart

Constructor Summary

AccessConstructor and Description
public
TsvParser(TsvParserSettings
the parser configuration
settings
)

The TsvParser supports all settings provided by TsvParserSettings, and requires this configuration to be properly initialized.

Method Summary

Modifier and TypeMethod and Description
protected void
private void
protected void
parseRecord()

Implements abstract com.univocity.parsers.common.AbstractParser.parseRecord.

Parser-specific implementation for reading a single record from the input.
Inherited from com.univocity.parsers.common.AbstractParser:
beginParsingbeginParsingbeginParsingbeginParsingbeginParsingbeginParsingbeginParsingconsumeValueOnEOFcreateParsingContextgetContextgetInputAnalysisProcessgetRecordMetadatainCommentiterateiterateiterateiterateiterateiterateiterateiterateRecordsiterateRecordsiterateRecordsiterateRecordsiterateRecordsiterateRecordsiterateRecordsparseparseparseparseparseparseparseparseAllparseAllparseAllparseAllparseAllparseAllparseAllparseAllparseAllparseAllparseAllparseAllparseAllparseAllparseAllparseAllparseAllRecordsparseAllRecordsparseAllRecordsparseAllRecordsparseAllRecordsparseAllRecordsparseAllRecordsparseAllRecordsparseAllRecordsparseAllRecordsparseAllRecordsparseAllRecordsparseAllRecordsparseAllRecordsparseAllRecordsparseAllRecordsparseLineparseNextparseNextRecordparseRecordprocessCommentreloadHeadersstopParsing

Field Detail

escapeCharback to summary
private final char escapeChar
escapedTabCharback to summary
private final char escapedTabChar
joinLinesback to summary
private final boolean joinLines
newLineback to summary
private final char newLine

Constructor Detail

TsvParserback to summary
public TsvParser(TsvParserSettings settings)

The TsvParser supports all settings provided by TsvParserSettings, and requires this configuration to be properly initialized.

Parameters
settings:TsvParserSettings

the parser configuration

Method Detail

initializeback to summary
protected void initialize()

Overrides com.univocity.parsers.common.AbstractParser.initialize.

Annotations
@Override
parseFieldback to summary
private void parseField()
parseRecordback to summary
protected void parseRecord()

Implements abstract com.univocity.parsers.common.AbstractParser.parseRecord.

Doc from com.univocity.parsers.common.AbstractParser.parseRecord.

Parser-specific implementation for reading a single record from the input.

The AbstractParser handles the initialization and processing of the input until it is ready to be parsed.

It then delegates the input to the parser-specific implementation defined by parseRecord(). In general, an implementation of AbstractParser#parseRecord() will perform the following steps:

  • Test the character stored in ch and take some action on it (e.g. is while (ch != '\n'){doSomething()})
  • Request more characters by calling ch = input.nextChar();
  • Append the desired characters to the output by executing, for example, output.appender.append(ch)
  • Notify a value of the record has been fully read by executing output.valueParsed(). This will clear the output appender (CharAppender) so the next call to output.appender.append(ch) will be store the character of the next parsed value
  • Rinse and repeat until all values of the record are parsed

Once the parseRecord() returns, the AbstractParser takes over and handles the information (generally, reorganizing it and passing it on to a RowProcessor).

After the record processing, the AbstractParser reads the next characters from the input, delegating control again to the parseRecord() implementation for processing of the next record.

This cycle repeats until the reading process is stopped by the user, the input is exhausted, or an error happens.

In case of errors, the unchecked exception TextParsingException will be thrown and all resources in use will be closed automatically unless CommonParserSettings#isAutoClosingEnabled() evaluates to false. The exception should contain the cause and more information about where in the input the error happened.

Annotations
@Override