|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.univocity.parsers.common.CommonSettings<F>
com.univocity.parsers.common.CommonParserSettings<FixedWidthFormat>
com.univocity.parsers.fixed.FixedWidthParserSettings
public class FixedWidthParserSettings
This is the configuration class used by the Fixed-Width parser (FixedWidthParser)
In addition to the configuration options provided by CommonParserSettings, the FixedWidthParserSettings include:
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
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.
FixedWidthParser,
FixedWidthFormat,
FixedWidthFields,
CommonParserSettings| Field Summary | |
|---|---|
protected boolean |
recordEndsOnNewline
|
protected boolean |
skipTrailingCharsUntilNewline
|
| Constructor Summary | |
|---|---|
FixedWidthParserSettings()
Creates a basic configuration object for the Fixed-Width parser with no field length configuration. |
|
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. |
|
| Method Summary | |
|---|---|
protected void |
addConfiguration(Map<String,Object> out)
|
void |
addFormatForLookahead(String lookahead,
FixedWidthFields lengths)
Defines the format of records identified by a lookahead symbol. |
void |
addFormatForLookbehind(String lookbehind,
FixedWidthFields lengths)
Defines the format of records identified by a lookbehind symbol. |
protected FixedWidthFormat |
createDefaultFormat()
Returns the default FixedWidthFormat configured to handle Fixed-Width inputs |
int |
getMaxCharsPerColumn()
The maximum number of characters allowed for any given value being written/read. |
int |
getMaxColumns()
Returns the hard limit of how many columns a record can have (defaults to a maximum of 512). |
boolean |
getRecordEndsOnNewline()
Indicates whether or not a record is considered parsed when a newline is reached. |
boolean |
getSkipTrailingCharsUntilNewline()
Indicates whether or not any trailing characters beyond the record's length should be skipped until the newline is reached (defaults to false) |
boolean |
getUseDefaultPaddingForHeaders()
Indicates whether headers should be parsed using the default padding specified in FixedWidthFormat.getPadding()
instead of any custom padding associated with a given field (in FixedWidthFields.setPadding(char, int...))
Defaults to true |
protected CharAppender |
newCharAppender()
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 |
void |
setRecordEndsOnNewline(boolean recordEndsOnNewline)
Defines whether or not a record is considered parsed when a newline is reached. |
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 false) |
void |
setUseDefaultPaddingForHeaders(boolean useDefaultPaddingForHeaders)
Defines whether headers should be parsed using the default padding specified in FixedWidthFormat.getPadding()
instead of any custom padding associated with a given field (in FixedWidthFields.setPadding(char, int...)) |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected boolean skipTrailingCharsUntilNewline
protected boolean recordEndsOnNewline
| Constructor Detail |
|---|
public FixedWidthParserSettings(FixedWidthFields fieldLengths)
This must provided using an instance of FixedWidthFields.
fieldLengths - the instance of FixedWidthFields which provides the lengths of each field in the fixed-width records to be parsedFixedWidthFieldspublic FixedWidthParserSettings()
addFormatForLookahead(String, FixedWidthFields), addFormatForLookbehind(String, FixedWidthFields)
| Method Detail |
|---|
public boolean getSkipTrailingCharsUntilNewline()
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 setSkipTrailingCharsUntilNewline(boolean skipTrailingCharsUntilNewline)
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
skipTrailingCharsUntilNewline - a flag indicating if any trailing characters beyond the record's length should be skipped until the newline is reachedpublic boolean getRecordEndsOnNewline()
recordEndsOnNewline is set to true: the first value will be read as 12 and the second 3456recordEndsOnNewline is set to false: the first value will be read as 12\n3 and the second 456Defaults to false
public void setRecordEndsOnNewline(boolean recordEndsOnNewline)
recordEndsOnNewline is set to true: the first value will be read as 12 and the second 3456recordEndsOnNewline is set to false: the first value will be read as 12\n3 and the second 456
recordEndsOnNewline - a flag indicating whether or not a record is considered parsed when a newline is reachedprotected FixedWidthFormat createDefaultFormat()
createDefaultFormat in class CommonSettings<FixedWidthFormat>protected CharAppender newCharAppender()
This overrides the parent implementation to create a CharAppender capable of handling padding characters that represent unwritten positions.
newCharAppender in class CommonParserSettings<FixedWidthFormat>public int getMaxCharsPerColumn()
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.
getMaxCharsPerColumn in class CommonSettings<FixedWidthFormat>public int getMaxColumns()
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.
getMaxColumns in class CommonSettings<FixedWidthFormat>
public void addFormatForLookahead(String lookahead,
FixedWidthFields lengths)
lookahead - the lookahead value that when found in the input,
will notify the parser to switch to a new record format, with different field lengthslengths - the field lengths of the record format identified by the given lookahead symbol.
public void addFormatForLookbehind(String lookbehind,
FixedWidthFields lengths)
lookbehind - 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 lengthslengths - the field lengths of the record format identified by the given lookbehind symbol.public boolean getUseDefaultPaddingForHeaders()
FixedWidthFormat.getPadding()
instead of any custom padding associated with a given field (in FixedWidthFields.setPadding(char, int...))
Defaults to true
true if the default padding is to be used when reading headers, otherwise falsepublic void setUseDefaultPaddingForHeaders(boolean useDefaultPaddingForHeaders)
FixedWidthFormat.getPadding()
instead of any custom padding associated with a given field (in FixedWidthFields.setPadding(char, int...))
useDefaultPaddingForHeaders - flag indicating whether the default padding is to be used when parsing headersprotected void addConfiguration(Map<String,Object> out)
addConfiguration in class CommonParserSettings<FixedWidthFormat>
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||