Package org.beanio.builder
Class FieldBuilder
- java.lang.Object
-
- org.beanio.builder.PropertyBuilderSupport<FieldBuilder>
-
- org.beanio.builder.FieldBuilder
-
public class FieldBuilder extends PropertyBuilderSupport<FieldBuilder>
Builds a new field configuration.- Since:
- 2.1.0
-
-
Field Summary
Fields Modifier and Type Field Description protected FieldConfig
config
-
Constructor Summary
Constructors Constructor Description FieldBuilder(java.lang.String name)
Constructs a new FieldBuilder.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description FieldBuilder
align(Align align)
Sets the alignment or justification of this field if padded.FieldBuilder
at(int at)
Sets the position of the field.FieldConfig
build()
Builds this field.FieldBuilder
defaultValue(java.lang.String value)
Sets the default value of this field.FieldBuilder
format(java.lang.String pattern)
Sets the pattern used to format this field by the type handler.protected FieldConfig
getConfig()
Returns the configuration settings.FieldBuilder
ignore()
Indicates this field is not bound to a property of the class assigned to its parent record or segment.FieldBuilder
keepPadding()
Indicates this field should not be unpadded during unmarshalling.FieldBuilder
length(int length)
Sets the padded length of this field.FieldBuilder
lenientPadding()
Indicates the padding length should not be enforced for this field.FieldBuilder
literal(java.lang.String literal)
Sets the literal text the field text must match.FieldBuilder
maxLength(int n)
Sets the maximum expected length of the field text.protected FieldBuilder
me()
Returns this.FieldBuilder
minLength(int n)
Sets the minimum expected length of the field text.FieldBuilder
nillable()
Indicates this field is nillable for XML formatted streams.FieldBuilder
occursRef(java.lang.String ref)
Indicates the number of occurrences of this field is governed by another field.FieldBuilder
padding(char c)
Sets the character used to pad this field.FieldBuilder
regex(java.lang.String pattern)
Sets the regular expression the field text must match.FieldBuilder
required()
Indicates this field is required and must contain at least one character.FieldBuilder
rid()
Indicates this field is used to identify the record.FieldBuilder
trim()
Indicates the field text should be trimmed before validation and type conversion.FieldBuilder
typeHandler(java.lang.Class<? extends TypeHandler> handler)
Sets the type handler used for parsing and formatting field text.FieldBuilder
typeHandler(java.lang.String name)
Sets the type handler used for parsing and formatting field text.FieldBuilder
typeHandler(TypeHandler handler)
Sets the type handler used for parsing and formatting field text.FieldBuilder
until(int until)
Sets the maximum position of this field if it repeats an indeterminate number of times-
Methods inherited from class org.beanio.builder.PropertyBuilderSupport
collection, getter, lazy, maxOccurs, minOccurs, occurs, occurs, setter, type, xmlName, xmlNamespace, xmlPrefix, xmlType
-
-
-
-
Field Detail
-
config
protected FieldConfig config
-
-
Method Detail
-
me
protected FieldBuilder me()
Description copied from class:PropertyBuilderSupport
Returns this.- Specified by:
me
in classPropertyBuilderSupport<FieldBuilder>
- Returns:
- this
-
getConfig
protected FieldConfig getConfig()
Description copied from class:PropertyBuilderSupport
Returns the configuration settings.- Specified by:
getConfig
in classPropertyBuilderSupport<FieldBuilder>
- Returns:
- the configuration
-
rid
public FieldBuilder rid()
Indicates this field is used to identify the record.- Returns:
- this
-
at
public FieldBuilder at(int at)
Sets the position of the field.- Parameters:
at
- the position- Returns:
- this
-
until
public FieldBuilder until(int until)
Sets the maximum position of this field if it repeats an indeterminate number of times- Parameters:
until
- the maximum position- Returns:
- this
FieldBuilder
-
trim
public FieldBuilder trim()
Indicates the field text should be trimmed before validation and type conversion.- Returns:
- this
FieldBuilder
-
required
public FieldBuilder required()
Indicates this field is required and must contain at least one character.- Returns:
- this
FieldBuilder
-
occursRef
public FieldBuilder occursRef(java.lang.String ref)
Indicates the number of occurrences of this field is governed by another field.- Parameters:
ref
- the name of the field that governs the occurrences of this field- Returns:
- this
FieldBuilder
-
minLength
public FieldBuilder minLength(int n)
Sets the minimum expected length of the field text.- Returns:
- this
FieldBuilder
-
maxLength
public FieldBuilder maxLength(int n)
Sets the maximum expected length of the field text.- Returns:
- this
FieldBuilder
-
regex
public FieldBuilder regex(java.lang.String pattern)
Sets the regular expression the field text must match.- Returns:
- this
FieldBuilder
-
literal
public FieldBuilder literal(java.lang.String literal)
Sets the literal text the field text must match.- Returns:
- this
FieldBuilder
-
defaultValue
public FieldBuilder defaultValue(java.lang.String value)
Sets the default value of this field.- Returns:
- this
FieldBuilder
-
format
public FieldBuilder format(java.lang.String pattern)
Sets the pattern used to format this field by the type handler.- Parameters:
pattern
- the pattern- Returns:
- this
FieldBuilder
-
ignore
public FieldBuilder ignore()
Indicates this field is not bound to a property of the class assigned to its parent record or segment.- Returns:
- this
FieldBuilder
-
length
public FieldBuilder length(int length)
Sets the padded length of this field.- Parameters:
length
- the length- Returns:
- this
FieldBuilder
-
padding
public FieldBuilder padding(char c)
Sets the character used to pad this field. Defaults to a space.- Parameters:
c
- the padding character- Returns:
- this
FieldBuilder
-
keepPadding
public FieldBuilder keepPadding()
Indicates this field should not be unpadded during unmarshalling.- Returns:
- this
FieldBuilder
-
lenientPadding
public FieldBuilder lenientPadding()
Indicates the padding length should not be enforced for this field. Only applies to fixed length formatted streams.- Returns:
- this
FieldBuilder
-
align
public FieldBuilder align(Align align)
Sets the alignment or justification of this field if padded.- Parameters:
align
- the alignment- Returns:
- this
FieldBuilder
-
nillable
public FieldBuilder nillable()
Indicates this field is nillable for XML formatted streams.- Returns:
- this
FieldBuilder
-
typeHandler
public FieldBuilder typeHandler(java.lang.String name)
Sets the type handler used for parsing and formatting field text.- Parameters:
name
- the type handler name- Returns:
- this
FieldBuilder
-
typeHandler
public FieldBuilder typeHandler(java.lang.Class<? extends TypeHandler> handler)
Sets the type handler used for parsing and formatting field text.- Parameters:
handler
- the type handler class- Returns:
- this
FieldBuilder
-
typeHandler
public FieldBuilder typeHandler(TypeHandler handler)
Sets the type handler used for parsing and formatting field text.- Parameters:
handler
- theTypeHandler
- Returns:
- this
FieldBuilder
-
build
public FieldConfig build()
Builds this field.- Returns:
- the field configuration
-
-