FixedWidthParser)
In addition to the configuration options provided by CommonParserSettings, the FixedWidthParserSettings include:
false): Indicates whether or not any trailing characters beyond the record's length should be skipped until the newline is reached
For example, if the record length is 5, but the row contains "12345678\n", then portion containing "678" will be discarded and not considered part of the next record
false): Indicates whether or not a record is considered parsed when a newline is reached.
For example, if recordEndsOnNewline is set to true, then given a record of length 4, and the input "12\n3456", the parser will identify [12] and [3456]
If recordEndsOnNewline is set to false, then given a record of length 4, and the input "12\n3456", the parser will identify a multi-line record [12\n3] and [456 ]
The FixedWidthParserSettings need a definition of the field lengths of each record in the input. This must provided using an instance of FixedWidthFields.
com.univocity.parsers.fixed.FixedWidthParser , com.univocity.parsers.fixed.FixedWidthFormat , FixedWidthFields, com.univocity.parsers.common.CommonParserSettings
| Modifier and Type | Field and Description |
|---|---|
| private FixedWidthFields | |
| private boolean | |
| private Map | |
| private Map | |
| protected boolean | |
| protected boolean | |
| private boolean |
| Access | Constructor and Description |
|---|---|
| public | FixedWidthParserSettings(FixedWidthFields
the instance of fieldLengths)FixedWidthFields which provides the lengths of each field in the fixed-width records to be parsedYou can only create an instance of this class by providing a definition of the field lengths of each record in the input. |
| public | FixedWidthParserSettings()
Creates a basic configuration object for the Fixed-Width parser with no field length configuration. |
| Modifier and Type | Method and Description |
|---|---|
| protected void | |
| public void | addFormatForLookahead(String
the lookahead value that when found in the input,
will notify the parser to switch to a new record format, with different field lengths lookahead, FixedWidthFields the field lengths of the record format identified by the given lookahead symbol. lengths)Defines the format of records identified by a lookahead symbol. |
| public void | addFormatForLookbehind(String
the lookbehind value that when found in the previous input row,
will notify the parser to switch to a new record format, with different field lengths lookbehind, FixedWidthFields the field lengths of the record format identified by the given lookbehind symbol. lengths)Defines the format of records identified by a lookbehind symbol. |
| private int[] | |
| public final FixedWidthParserSettings | Returns: a copy of all configurations applied to the current instance.Overrides com. |
| protected final FixedWidthParserSettings | Returns: a copy of all configurations applied to the current instance.flag indicating whether to clear settings that are likely to be associated with a given input. clearInputSpecificSettings)Overrides com.
Deprecated
doesn't really make sense for fixed-width.
Clones this configuration object to reuse most user-provided settings.
|
| public final FixedWidthParserSettings | Returns: a copy of the general configurations applied to the current instance.the fixed-width field configuration to be used by the cloned settings object. fields)Clones this configuration object to reuse most user-provided settings. |
| private FixedWidthParserSettings | |
| protected void | configureFromAnnotations(Class<?>
the classes whose annotations will be processed to derive configurations for parsing beanClass)Overrides com. |
| protected FixedWidthFormat | Returns: and instance of FixedWidthFormat configured to handle Fixed-Width inputsImplements abstract com. |
| pack-priv int[] | |
| pack-priv FieldAlignment[] | Returns: the sequence of alignments to consider for each field of each record.Returns the sequence of alignments to consider for each field of each record. |
| pack-priv int[] | Returns: the sequence of lengths to be read by the parser to form a record.Returns the sequence of lengths to be read by the parser to form a record. |
| pack-priv char[] | Returns: the sequence of paddings used by each field of each record.Returns the sequence of paddings used by each field of each record. |
| pack-priv boolean[] | Returns: the sequence of fields to ignore.Returns the sequence of fields to ignore. |
| public final boolean | Returns: flag indicating the padding character should be kept in the parsed valueIndicate the padding character should be kept in the parsed value
(defaults to |
| pack-priv Boolean[] | Returns: the sequence that have an explicit 'keepPadding' flag.Returns the sequence of fields whose padding character must/must not be retained in the parsed value |
| pack-priv Lookup[] | |
| pack-priv Lookup[] | |
| public int | Returns: The maximum number of characters allowed for any given value being written/readOverrides com. |
| public int | Returns: The maximum number of columns a record can have.Overrides com. |
| public boolean | Returns: true if a record should be considered parsed when a newline is reached; false otherwiseIndicates whether or not a record is considered parsed when a newline is reached. |
| public boolean | Returns: returns true if any trailing characters beyond the record's length should be skipped until the newline is reached, false otherwiseIndicates whether or not any trailing characters beyond the record's length should be skipped until the newline is reached (defaults to For example, if the record length is 5, but the row contains "12345678\n", then the portion containing "678\n" will be discarded and not considered part of the next record |
| public boolean | Returns: true if the default padding is to be used when reading headers, otherwise falseIndicates whether headers should be parsed using the default padding specified in |
| protected CharAppender | Returns: an instance of CharAppender with the configured limit of maximum characters per column and, default value used to represent a null value (when the String parsed from the input is empty), and the padding character to handle unwritten positionsOverrides com. This overrides the parent implementation to create a CharAppender capable of handling padding characters that represent unwritten positions. |
| public final void | setKeepPadding(boolean
flag indicating the padding character should be kept in the parsed value keepPadding)Configures the fixed-width parser to retain the padding character in any parsed values
(defaults to |
| public void | setRecordEndsOnNewline(boolean
a flag indicating whether or not a record is considered parsed when a newline is reached recordEndsOnNewline)Defines whether or not a record is considered parsed when a newline is reached. |
| public void | setSkipTrailingCharsUntilNewline(boolean
a flag indicating if any trailing characters beyond the record's length should be skipped until the newline is reached skipTrailingCharsUntilNewline)Defines whether or not any trailing characters beyond the record's length should be skipped until the newline is reached (defaults to For example, if the record length is 5, but the row contains "12345678\n", then the portion containing "678\n" will be discarded and not considered part of the next record |
| public void | setUseDefaultPaddingForHeaders(boolean
flag indicating whether the default padding is to be used when parsing headers useDefaultPaddingForHeaders)Defines whether headers should be parsed using the default padding specified in |
| fieldLengths | back to summary |
|---|---|
| private FixedWidthFields fieldLengths | |
| keepPadding | back to summary |
|---|---|
| private boolean keepPadding | |
| lookaheadFormats | back to summary |
|---|---|
| private Map<String, FixedWidthFields> lookaheadFormats | |
| lookbehindFormats | back to summary |
|---|---|
| private Map<String, FixedWidthFields> lookbehindFormats | |
| recordEndsOnNewline | back to summary |
|---|---|
| protected boolean recordEndsOnNewline | |
| skipTrailingCharsUntilNewline | back to summary |
|---|---|
| protected boolean skipTrailingCharsUntilNewline | |
| useDefaultPaddingForHeaders | back to summary |
|---|---|
| private boolean useDefaultPaddingForHeaders | |
| FixedWidthParserSettings | back to summary |
|---|---|
| public FixedWidthParserSettings(FixedWidthFields fieldLengths) You can only create an instance of this class by providing a definition of the field lengths of each record in the input. This must provided using an instance of
| |
| FixedWidthParserSettings | back to summary |
|---|---|
| public FixedWidthParserSettings() Creates a basic configuration object for the Fixed-Width parser with no field length configuration.
This constructor is intended to be used when the record length varies depending of the input row.
Refer to | |
| addConfiguration | back to summary |
|---|---|
| protected void addConfiguration(Map<String, Object> out) Overrides com.
| |
| addFormatForLookahead | back to summary |
|---|---|
| public void addFormatForLookahead(String lookahead, FixedWidthFields lengths) Defines the format of records identified by a lookahead symbol.
| |
| addFormatForLookbehind | back to summary |
|---|---|
| public void addFormatForLookbehind(String lookbehind, FixedWidthFields lengths) Defines the format of records identified by a lookbehind symbol.
| |
| calculateMaxFieldLengths | back to summary |
|---|---|
| private int[] calculateMaxFieldLengths() | |
| clone | back to summary |
|---|---|
| public final FixedWidthParserSettings clone() Overrides com. Clones this configuration object to reuse all user-provided settings, including the fixed-width field configuration.
| |
| clone | back to summary |
|---|---|
| protected final FixedWidthParserSettings clone(boolean clearInputSpecificSettings) Overrides com. Deprecated doesn't really make sense for fixed-width. Use alternative method Clones this configuration object to reuse most user-provided settings. This includes the fixed-width field configuration, but doesn't include other input-specific settings. This method is meant to be used internally only.
| |
| clone | back to summary |
|---|---|
| public final FixedWidthParserSettings clone(FixedWidthFields fields) Clones this configuration object to reuse most user-provided settings. Properties that are specific to a given
input (such as header names and selection of fields) will be reset to their defaults.
To obtain a full copy, use
| |
| clone | back to summary |
|---|---|
| private FixedWidthParserSettings clone(boolean clearInputSpecificSettings, FixedWidthFields fields) | |
| configureFromAnnotations | back to summary |
|---|---|
| protected void configureFromAnnotations(Class<?> beanClass) Overrides com. Doc from com. Configures the parser based on the annotations provided in a given class | |
| createDefaultFormat | back to summary |
|---|---|
| protected FixedWidthFormat createDefaultFormat() Implements abstract com. Returns the default FixedWidthFormat configured to handle Fixed-Width inputs
| |
| getAllLengths | back to summary |
|---|---|
| pack-priv int[] getAllLengths() | |
| getFieldAlignments | back to summary |
|---|---|
| pack-priv FieldAlignment[] getFieldAlignments() Returns the sequence of alignments to consider for each field of each record.
| |
| getFieldLengths | back to summary |
|---|---|
| pack-priv int[] getFieldLengths() Returns the sequence of lengths to be read by the parser to form a record.
| |
| getFieldPaddings | back to summary |
|---|---|
| pack-priv char[] getFieldPaddings() Returns the sequence of paddings used by each field of each record.
| |
| getFieldsToIgnore | back to summary |
|---|---|
| pack-priv boolean[] getFieldsToIgnore() Returns the sequence of fields to ignore.
| |
| getKeepPadding | back to summary |
|---|---|
| public final boolean getKeepPadding() Indicate the padding character should be kept in the parsed value
(defaults to
| |
| getKeepPaddingFlags | back to summary |
|---|---|
| pack-priv Boolean[] getKeepPaddingFlags() Returns the sequence of fields whose padding character must/must not be retained in the parsed value
| |
| getLookaheadFormats | back to summary |
|---|---|
| pack-priv Lookup[] getLookaheadFormats() | |
| getLookbehindFormats | back to summary |
|---|---|
| pack-priv Lookup[] getLookbehindFormats() | |
| getMaxCharsPerColumn | back to summary |
|---|---|
| public int getMaxCharsPerColumn() Overrides com. The maximum number of characters allowed for any given value being written/read. Used to avoid OutOfMemoryErrors (defaults to a minimum of 4096 characters). This overrides the parent implementation and calculates the absolute minimum number of characters required to store the values of a record If the sum of all field lengths is greater than the configured maximum number of characters per column, the calculated amount will be returned.
| |
| getMaxColumns | back to summary |
|---|---|
| public int getMaxColumns() Overrides com. Returns the hard limit of how many columns a record can have (defaults to a maximum of 512). You need this to avoid OutOfMemory errors in case of inputs that might be inconsistent with the format you are dealing with. This overrides the parent implementation and calculates the absolute minimum number of columns required to store the values of a record If the sum of all fields is greater than the configured maximum number columns, the calculated amount will be returned.
| |
| getRecordEndsOnNewline | back to summary |
|---|---|
| public boolean getRecordEndsOnNewline() Indicates whether or not a record is considered parsed when a newline is reached. Examples:
defaults to
| |
| getSkipTrailingCharsUntilNewline | back to summary |
|---|---|
| public boolean getSkipTrailingCharsUntilNewline() Indicates whether or not any trailing characters beyond the record's length should be skipped until the newline is reached (defaults to For example, if the record length is 5, but the row contains "12345678\n", then the portion containing "678\n" will be discarded and not considered part of the next record
| |
| getUseDefaultPaddingForHeaders | back to summary |
|---|---|
| public boolean getUseDefaultPaddingForHeaders() Indicates whether headers should be parsed using the default padding specified in
| |
| newCharAppender | back to summary |
|---|---|
| protected CharAppender newCharAppender() Overrides com. Returns an instance of CharAppender with the configured limit of maximum characters per column and, default value used to represent a null value (when the String parsed from the input is empty), and the padding character to handle unwritten positions This overrides the parent implementation to create a CharAppender capable of handling padding characters that represent unwritten positions.
| |
| setKeepPadding | back to summary |
|---|---|
| public final void setKeepPadding(boolean keepPadding) Configures the fixed-width parser to retain the padding character in any parsed values
(defaults to
| |
| setRecordEndsOnNewline | back to summary |
|---|---|
| public void setRecordEndsOnNewline(boolean recordEndsOnNewline) Defines whether or not a record is considered parsed when a newline is reached. Examples:
| |
| setSkipTrailingCharsUntilNewline | back to summary |
|---|---|
| public void setSkipTrailingCharsUntilNewline(boolean skipTrailingCharsUntilNewline) Defines whether or not any trailing characters beyond the record's length should be skipped until the newline is reached (defaults to For example, if the record length is 5, but the row contains "12345678\n", then the portion containing "678\n" will be discarded and not considered part of the next record
| |
| setUseDefaultPaddingForHeaders | back to summary |
|---|---|
| public void setUseDefaultPaddingForHeaders(boolean useDefaultPaddingForHeaders) Defines whether headers should be parsed using the default padding specified in
| |