Package org.beanio.internal.config
Class FieldConfig
- java.lang.Object
-
- All Implemented Interfaces:
java.lang.Cloneable
,java.lang.Iterable<ComponentConfig>
,Replicateable
public class FieldConfig extends SimplePropertyConfig
A field is used to define the smallest physical part of a stream. Fields are combined to form segments and records.Unless
bound
is set to false, a field is bound to a property of its closest parent bean object.Position must be set for all fields in record, or for none of them. If not set, position is determined based on the order in which the fields are added to the record.
- Since:
- 2.0
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
LEFT
Left justification settingstatic java.lang.String
RIGHT
Right justification setting-
Fields inherited from class org.beanio.internal.config.PropertyConfig
JSON_TYPE_ARRAY, JSON_TYPE_BOOLEAN, JSON_TYPE_NONE, JSON_TYPE_NUMBER, JSON_TYPE_OBJECT, JSON_TYPE_STRING
-
-
Constructor Summary
Constructors Constructor Description FieldConfig()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description char
getComponentType()
Returns the component type.java.lang.String
getDefault()
Returns the textual representation of the default value for this field when the field is not present or empty during unmarshalling.java.lang.String
getJustify()
Returns the justification of this field.java.lang.Integer
getLength()
Returns the length of this field in characters.java.lang.String
getLiteral()
Returns the static text for this field, ornull
if the field text is not static.java.lang.Integer
getMaxLength()
Returns the maximum length of this field in characters.java.lang.Integer
getMinLength()
Returns the minimum length of this field in characters, ornull
if a minimum length should not be enforced.java.lang.Character
getPadding()
Returns the character used to pad this field.java.lang.String
getRegex()
Returns the regular expression pattern for validating the field text during unmarshalling.boolean
isKeepPadding()
Returns whether a fixed length field should keep its padding when unmarshalled.boolean
isLenientPadding()
Sets whether padding length is enforced for fixed length formatted streams.boolean
isRef()
Returns true if this field is referenced by another component.boolean
isRequired()
Returnstrue
if this field is required when unmarshalled.boolean
isTrim()
Returns whether field text should be trimmed before validation and type conversion.void
setDefault(java.lang.String text)
Sets the textual representation of the default value of this field when the field is not present or empty during unmarshalling.void
setJustify(java.lang.String justify)
Sets the justification of this field.void
setKeepPadding(boolean keepPadding)
Sets whether a fixed length field should keep its padding when unmarshalled.void
setLength(java.lang.Integer length)
Sets the length of this field in characters.void
setLenientPadding(boolean lenientPadding)
Sets whether the padding length is enforced for fixed length formatted streams.void
setLiteral(java.lang.String literal)
Sets the static text for this field.void
setMaxLength(java.lang.Integer maxLength)
Sets the maximum length of this field in characters.void
setMinLength(java.lang.Integer minLength)
Sets the minimum length of this field in characters, ornull
if a minimum length should not be enforced.void
setPadding(java.lang.Character padding)
Sets the character used to pad this field.void
setRef(boolean ref)
Sets whether this field is referenced by another component.void
setRegex(java.lang.String pattern)
Sets the regular expression pattern for validating the field text during unmarshalling.void
setRequired(boolean required)
Set totrue
if this field is required when unmarshalled.void
setTrim(boolean trim)
Sets whether field text should be trimmed before validation and type conversion.-
Methods inherited from class org.beanio.internal.config.SimplePropertyConfig
getFormat, getTypeHandler, getTypeHandlerInstance, setFormat, setTypeHandler, setTypeHandlerInstance
-
Methods inherited from class org.beanio.internal.config.PropertyConfig
getCollection, getGetter, getJsonArrayIndex, getJsonName, getJsonType, getKey, getLabel, getMaxOccurs, getMaxOccursRef, getMaxSize, getMinOccurs, getMinOccursRef, getMinSize, getOccursRef, getPosition, getSetter, getType, getUntil, getXmlType, isBound, isCollection, isIdentifier, isJsonArray, isLazy, isNillable, isRepeating, isSupportedChild, setBound, setCollection, setGetter, setIdentifier, setJsonArray, setJsonArrayIndex, setJsonName, setJsonType, setLabel, setLazy, setMaxOccurs, setMaxOccursRef, setMaxSize, setMinOccurs, setMinOccursRef, setMinSize, setNillable, setOccursRef, setPosition, setSetter, setType, setUntil, setXmlType
-
Methods inherited from class org.beanio.internal.config.ComponentConfig
getOrdinal, getXmlName, getXmlNamespace, getXmlPrefix, isXmlNamespaceAware, setOrdinal, setXmlName, setXmlNamespace, setXmlNamespaceAware, setXmlPrefix
-
Methods inherited from class org.beanio.internal.util.TreeNode
add, clone, find, getChildren, getFirst, getName, isDescendant, iterator, print, print, setName, size, sort, toParamString, toString, updateReferences
-
-
-
-
Field Detail
-
LEFT
public static final java.lang.String LEFT
Left justification setting- See Also:
- Constant Field Values
-
RIGHT
public static final java.lang.String RIGHT
Right justification setting- See Also:
- Constant Field Values
-
-
Method Detail
-
getComponentType
public char getComponentType()
Description copied from class:ComponentConfig
Returns the component type.- Specified by:
getComponentType
in classComponentConfig
- Returns:
- one of
ComponentConfig.GROUP
,ComponentConfig.RECORD
,ComponentConfig.SEGMENT
,ComponentConfig.FIELD
,ComponentConfig.CONSTANT
orComponentConfig.WRAPPER
-
getDefault
public java.lang.String getDefault()
Returns the textual representation of the default value for this field when the field is not present or empty during unmarshalling. May benull
.- Returns:
- the default value (as text)
-
setDefault
public void setDefault(java.lang.String text)
Sets the textual representation of the default value of this field when the field is not present or empty during unmarshalling. May benull
.- Parameters:
text
- the default value (as text)
-
getMinLength
public java.lang.Integer getMinLength()
Returns the minimum length of this field in characters, ornull
if a minimum length should not be enforced.- Returns:
- the minimum length, or
null
if not enforced
-
setMinLength
public void setMinLength(java.lang.Integer minLength)
Sets the minimum length of this field in characters, ornull
if a minimum length should not be enforced.- Parameters:
minLength
- the minimum length, ornull
if not enforced
-
getMaxLength
public java.lang.Integer getMaxLength()
Returns the maximum length of this field in characters. Returnsnull
if a maximum length will not be enforced.- Returns:
- the maximum length, or
null
if not enforced
-
setMaxLength
public void setMaxLength(java.lang.Integer maxLength)
Sets the maximum length of this field in characters. Set tonull
if a maximum length should not be enforced.- Parameters:
maxLength
- the maximum length, ornull
if not enforced
-
isTrim
public boolean isTrim()
Returns whether field text should be trimmed before validation and type conversion.- Returns:
true
if field text should be trimmed
-
setTrim
public void setTrim(boolean trim)
Sets whether field text should be trimmed before validation and type conversion.- Parameters:
trim
-true
if field text should be trimmed
-
getLiteral
public java.lang.String getLiteral()
Returns the static text for this field, ornull
if the field text is not static. If set, unmarshalled field text must match the literal text, and likewise, the literal text is always marshalled for this field.- Returns:
- the literal text of the field
-
setLiteral
public void setLiteral(java.lang.String literal)
Sets the static text for this field. If set, unmarshalled field text must match the literal text, and likewise, the literal text is always marshalled for this field.- Parameters:
literal
- the literal text of the field
-
getRegex
public java.lang.String getRegex()
Returns the regular expression pattern for validating the field text during unmarshalling. Field text is only validated using the regular expression after trimming (if enabled) and when its not the empty string.- Returns:
- the regular expression pattern
-
setRegex
public void setRegex(java.lang.String pattern)
Sets the regular expression pattern for validating the field text during unmarshalling. Field text is only validated using the regular expression after trimming (if enabled) and when its not the empty string.- Parameters:
pattern
- the regular expression pattern
-
isRequired
public boolean isRequired()
Returnstrue
if this field is required when unmarshalled. Required fields must have at least one character (after trimming, if enabled). If this field is not required and no text is parsed from the input stream, no further validations are performed.- Returns:
true
if this field is required
-
setRequired
public void setRequired(boolean required)
Set totrue
if this field is required when unmarshalled. Required fields must have at least one character (after trimming, if enabled). If this field is not required and no text is parsed from the input stream, no further validations are performed.- Parameters:
required
-true
if this field is required
-
getLength
public java.lang.Integer getLength()
Returns the length of this field in characters. Applies to fixed length and padded fields. May return -1 (aka 'unbounded'), for the last field in a fixed length record to indicate it is not padded and of variable length.- Returns:
- the length of this field
-
setLength
public void setLength(java.lang.Integer length)
Sets the length of this field in characters. Applies to fixed length and padded fields.- Parameters:
length
- the length of this field
-
getPadding
public java.lang.Character getPadding()
Returns the character used to pad this field. Defaults to a space when padding is enabled.- Returns:
- the character used to pad this field
-
setPadding
public void setPadding(java.lang.Character padding)
Sets the character used to pad this field. Defaults to a space when padding is enabled.- Parameters:
padding
- the character used to pad this field
-
getJustify
public java.lang.String getJustify()
Returns the justification of this field. Defaults toleft
. Applies to fixed length and padded fields.
-
setJustify
public void setJustify(java.lang.String justify)
Sets the justification of this field. Applies to fixed length and padded fields.
-
isKeepPadding
public boolean isKeepPadding()
Returns whether a fixed length field should keep its padding when unmarshalled. Defaults to false.- Returns:
- true to keep padding, false otherwise
-
setKeepPadding
public void setKeepPadding(boolean keepPadding)
Sets whether a fixed length field should keep its padding when unmarshalled.- Parameters:
keepPadding
- true to keep field padding, false otherwise
-
isLenientPadding
public boolean isLenientPadding()
Sets whether padding length is enforced for fixed length formatted streams.- Returns:
- true if not enforced, false otherwise
- Since:
- 2.1.0
-
setLenientPadding
public void setLenientPadding(boolean lenientPadding)
Sets whether the padding length is enforced for fixed length formatted streams.- Parameters:
lenientPadding
- true if not enforced, false otherwise- Since:
- 2.1.0
-
isRef
public boolean isRef()
Returns true if this field is referenced by another component.- Returns:
- true if referenced
-
setRef
public void setRef(boolean ref)
Sets whether this field is referenced by another component.- Parameters:
ref
- true if referenced
-
-