public class FixedWidthParser extends AbstractParser<FixedWidthParserSettings>
Modifier and Type | Field and Description |
---|---|
private FieldAlignment |
alignment |
private FieldAlignment[] |
alignments |
private char |
defaultPadding |
private boolean[] |
ignore |
private boolean |
initializeLookaheadInput |
private boolean |
keepPadding |
private java.lang.Boolean[] |
keepPaddingFlags |
private int |
length |
private int[] |
lengths |
private Lookup[] |
lookaheadFormats |
private LookaheadCharInputReader |
lookaheadInput |
private Lookup |
lookbehindFormat |
private Lookup[] |
lookbehindFormats |
private Lookup |
lookupFormat |
private int |
maxLookupLength |
private char |
newLine |
private char |
padding |
private char[] |
paddings |
private boolean |
recordEndsOnNewLine |
private FieldAlignment[] |
rootAlignments |
private boolean[] |
rootIgnore |
private java.lang.Boolean[] |
rootKeepPaddingFlags |
private int[] |
rootLengths |
private char[] |
rootPaddings |
private boolean |
skipEmptyLines |
private boolean |
skipToNewLine |
private boolean |
useDefaultPadding |
private char |
wildcard |
ch, comment, comments, context, ignoreLeadingWhitespace, ignoreTrailingWhitespace, input, lastComment, output, processor, settings, whitespaceRangeStart
Constructor and Description |
---|
FixedWidthParser(FixedWidthParserSettings settings)
The FixedWidthParser supports all settings provided by
FixedWidthParserSettings , and requires this configuration to be properly initialized. |
Modifier and Type | Method and Description |
---|---|
protected ParsingContext |
createParsingContext() |
protected void |
parseRecord()
Parser-specific implementation for reading a single record from the input.
|
private void |
readValue(boolean ignorePadding) |
private void |
readValueUntilNewLine(boolean ignorePadding) |
private void |
skipPadding(boolean lastFieldOfRecord) |
private void |
skipToNewLine() |
private void |
skipWhitespace(boolean lastFieldOfRecord) |
beginParsing, beginParsing, beginParsing, beginParsing, beginParsing, beginParsing, beginParsing, consumeValueOnEOF, getContext, getInputAnalysisProcess, getRecordMetadata, inComment, initialize, iterate, iterate, iterate, iterate, iterate, iterate, iterate, iterateRecords, iterateRecords, iterateRecords, iterateRecords, iterateRecords, iterateRecords, iterateRecords, parse, parse, parse, parse, parse, parse, parse, parseAll, parseAll, parseAll, parseAll, parseAll, parseAll, parseAll, parseAll, parseAll, parseAll, parseAll, parseAll, parseAll, parseAll, parseAll, parseAll, parseAllRecords, parseAllRecords, parseAllRecords, parseAllRecords, parseAllRecords, parseAllRecords, parseAllRecords, parseAllRecords, parseAllRecords, parseAllRecords, parseAllRecords, parseAllRecords, parseAllRecords, parseAllRecords, parseAllRecords, parseAllRecords, parseLine, parseNext, parseNextRecord, parseRecord, processComment, reloadHeaders, stopParsing
private int[] lengths
private int[] rootLengths
private boolean[] ignore
private boolean[] rootIgnore
private FieldAlignment[] alignments
private FieldAlignment[] rootAlignments
private char[] paddings
private char[] rootPaddings
private java.lang.Boolean[] keepPaddingFlags
private java.lang.Boolean[] rootKeepPaddingFlags
private final Lookup[] lookaheadFormats
private final Lookup[] lookbehindFormats
private Lookup lookupFormat
private Lookup lookbehindFormat
private int maxLookupLength
private final boolean skipToNewLine
private final boolean recordEndsOnNewLine
private final boolean skipEmptyLines
private final boolean keepPadding
private boolean useDefaultPadding
private final char defaultPadding
private char padding
private FieldAlignment alignment
private final char newLine
private int length
private boolean initializeLookaheadInput
private LookaheadCharInputReader lookaheadInput
private final char wildcard
public FixedWidthParser(FixedWidthParserSettings settings)
FixedWidthParserSettings
, and requires this configuration to be properly initialized.settings
- the parser configurationprotected ParsingContext createParsingContext()
createParsingContext
in class AbstractParser<FixedWidthParserSettings>
protected void parseRecord()
AbstractParser
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 AbstractParser.parseRecord()
. In general, an implementation of
AbstractParser.parseRecord()
will perform the following steps:
CharAppender
) so the next call to output.appender.append(ch) will be store the character of the next parsed value Once the AbstractParser.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.
parseRecord
in class AbstractParser<FixedWidthParserSettings>
CharInputReader
,
CharAppender
,
ParserOutput
,
TextParsingException
,
RowProcessor
private void skipToNewLine()
private void skipPadding(boolean lastFieldOfRecord)
private void skipWhitespace(boolean lastFieldOfRecord)
private void readValueUntilNewLine(boolean ignorePadding)
private void readValue(boolean ignorePadding)