Package com.univocity.parsers.fixed
Class FixedWidthFormat
- java.lang.Object
-
- com.univocity.parsers.common.Format
-
- com.univocity.parsers.fixed.FixedWidthFormat
-
- All Implemented Interfaces:
java.lang.Cloneable
public class FixedWidthFormat extends Format
The Fixed-Width format configuration. In addition to the default configuration inFormat
, the fixed-width format defines:- padding (defaults to ' '): the character used for filling unwritten spaces in a fixed-width record.
e.g. if a field has a length of 5 characters, but the value is 'ZZ', the field should contain [ZZ ] (i.e. ZZ followed by 3 unwritten spaces).
If the padding is set to '_', then the field will be written as [ZZ___]
- See Also:
Format
-
-
Field Summary
Fields Modifier and Type Field Description private char
lookupWildcard
private char
padding
-
Constructor Summary
Constructors Constructor Description FixedWidthFormat()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description FixedWidthFormat
clone()
protected java.util.TreeMap<java.lang.String,java.lang.Object>
getConfiguration()
char
getLookupWildcard()
Returns the lookup wildcard character to accept any character in look-ahead or look-behind patterns defined usingFixedWidthParserSettings.addFormatForLookahead(String, FixedWidthFields)
orFixedWidthParserSettings.addFormatForLookbehind(String, FixedWidthFields)
.char
getPadding()
Returns the padding character used to represent unwritten spaces.boolean
isPadding(char padding)
Identifies whether or not a given character represents a padding charactervoid
setLookupWildcard(char lookupWildcard)
Defines the lookup wildcard character to accept any character in look-ahead or look-behind patterns defined usingFixedWidthParserSettings.addFormatForLookahead(String, FixedWidthFields)
orFixedWidthParserSettings.addFormatForLookbehind(String, FixedWidthFields)
.void
setPadding(char padding)
Defines the padding character used to represent unwritten spaces.-
Methods inherited from class com.univocity.parsers.common.Format
getComment, getLineSeparator, getLineSeparatorString, getNormalizedNewline, getSystemLineSeparator, isComment, isNewLine, setComment, setLineSeparator, setLineSeparator, setNormalizedNewline, toString
-
-
-
-
Method Detail
-
getPadding
public char getPadding()
Returns the padding character used to represent unwritten spaces. Defaults to ' '- Returns:
- the padding character
-
setPadding
public void setPadding(char padding)
Defines the padding character used to represent unwritten spaces. Defaults to ' '- Parameters:
padding
- the padding character
-
isPadding
public boolean isPadding(char padding)
Identifies whether or not a given character represents a padding character- Parameters:
padding
- the character to be verified- Returns:
- true if the given character is the padding character, false otherwise
-
getConfiguration
protected java.util.TreeMap<java.lang.String,java.lang.Object> getConfiguration()
- Specified by:
getConfiguration
in classFormat
-
clone
public final FixedWidthFormat clone()
-
getLookupWildcard
public char getLookupWildcard()
Returns the lookup wildcard character to accept any character in look-ahead or look-behind patterns defined usingFixedWidthParserSettings.addFormatForLookahead(String, FixedWidthFields)
orFixedWidthParserSettings.addFormatForLookbehind(String, FixedWidthFields)
. Defaults to'?'
- Returns:
- the wildcard character to be used in lookahead/behind patterns.
-
setLookupWildcard
public void setLookupWildcard(char lookupWildcard)
Defines the lookup wildcard character to accept any character in look-ahead or look-behind patterns defined usingFixedWidthParserSettings.addFormatForLookahead(String, FixedWidthFields)
orFixedWidthParserSettings.addFormatForLookbehind(String, FixedWidthFields)
. Defaults to'?'
- Parameters:
lookupWildcard
- the wildcard character to be used in lookahead/behind patterns.
-
-