BeanIO 1.2.3

org.beanio.config
Class FieldConfig

java.lang.Object
  extended by org.beanio.config.PropertyConfig
      extended by org.beanio.config.FieldConfig

public class FieldConfig
extends PropertyConfig

Stores configuration settings for a field. Fields are used to define the layout of a record.

Since:
1.0
Author:
Kevin Seim

Field Summary
static String LEFT
          Left justification setting
static String RIGHT
          Right justification setting
 
Constructor Summary
FieldConfig()
          Constructs a new FieldConfig.
 
Method Summary
 String getDefault()
          Returns the default textual representation of the value of this field when the field is not present in the input stream.
 String getFormat()
          Returns the format pattern used by date and number type handlers.
 String getJustify()
          Returns the justification of this field.
 int getLength()
          Returns the length of this field in characters.
 String getLiteral()
          Returns the static text for this field, or null if the field text is not static.
 Integer getMaxLength()
          Returns the maximum length of this field in characters.
 Integer getMinLength()
          Returns the minimum length of this field in characters, or null if a minimum length should not be enforced.
 Character getPadding()
          Returns the character used to pad this field.
 int getPosition()
          Returns the position of this field.
 String getRegex()
          Returns the regular expression pattern for validating this field's text when read from an input stream.
 String getTypeHandler()
          Returns the name of the custom type handler used for type conversion by this field, or null if the default type handler is sufficient.
 boolean isField()
          Returns whether this property configuration defines a field.
 boolean isRecordIdentifier()
          Returns true if this field is used to identify the type of record.
 boolean isRequired()
          Returns true if this field is required when parsing an input stream.
 boolean isTrim()
          Returns true if field text will be trimmed before validation and type conversion.
 void setDefault(String text)
          Sets the default textual representation of the value of this field when the field is not present in the input stream.
 void setFormat(String format)
          Sets the format pattern used by date and number type handlers.
 void setJustify(String justify)
          Sets the justification of this field.
 void setLength(int length)
          Sets the length of this field in characters.
 void setLiteral(String literal)
          Sets the static text for this field.
 void setMaxLength(Integer maxLength)
          Sets the maximum length of this field in characters.
 void setMinLength(Integer minLength)
          Sets the minimum length of this field in characters, or null if a minimum length should not be enforced.
 void setPadding(Character padding)
          Sets the character used to pad this field.
 void setPosition(int position)
          Sets the position of this field.
 void setRecordIdentifier(boolean b)
          Set to true if this field is used to identify the type of record.
 void setRegex(String pattern)
          Sets the regular expression pattern for validating this field's text when read from an input stream.
 void setRequired(boolean required)
          Set to true if this field is required when parsing an input stream.
 void setTrim(boolean trim)
          Set to true if field text should be trimmed before validation and type conversion.
 void setTypeHandler(String handler)
          Sets the name of the custom type handler to use for type conversion by this field.
 
Methods inherited from class org.beanio.config.PropertyConfig
getCollection, getGetter, getMaxOccurs, getMinOccurs, getName, getSetter, getType, getXmlName, getXmlNamespace, getXmlPrefix, getXmlType, getXmlWrapper, isBean, isIgnored, isNillable, setCollection, setGetter, setIgnored, setMaxOccurs, setMinOccurs, setName, setNillable, setSetter, setType, setXmlName, setXmlNamespace, setXmlPrefix, setXmlType, setXmlWrapper
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LEFT

public static final String LEFT
Left justification setting

See Also:
Constant Field Values

RIGHT

public static final String RIGHT
Right justification setting

See Also:
Constant Field Values
Constructor Detail

FieldConfig

public FieldConfig()
Constructs a new FieldConfig.

Method Detail

isField

public boolean isField()
Description copied from class: PropertyConfig
Returns whether this property configuration defines a field.

Overrides:
isField in class PropertyConfig
Returns:
true if this property is a field

getDefault

public String getDefault()
Returns the default textual representation of the value of this field when the field is not present in the input stream. May be null.

Returns:
the default value (as text)

setDefault

public void setDefault(String text)
Sets the default textual representation of the value of this field when the field is not present in the input stream. May be null.

Parameters:
text - the default value (as text)

getPosition

public int getPosition()
Returns the position of this field. For delimited record formats, the position is the index (beginning at 0) of this field in the record. For fixed length record formats, the position is the index of the first character in the field.

Returns:
the field position

setPosition

public void setPosition(int position)
Sets the position of this field. For delimited record formats, the position is the index (beginning at 0) of this field in the record. For fixed length record formats, the position is the index of the first character in the field.

Parameters:
position - the field position

getMinLength

public Integer getMinLength()
Returns the minimum length of this field in characters, or null if a minimum length should not be enforced.

Returns:
the minimum length, or null if not enforced

setMinLength

public void setMinLength(Integer minLength)
Sets the minimum length of this field in characters, or null if a minimum length should not be enforced.

Parameters:
minLength - the minimum length, or null if not enforced

getMaxLength

public Integer getMaxLength()
Returns the maximum length of this field in characters. Returns null if a maximum length will not be enforced.

Returns:
the maximum length, or null if not enforced

setMaxLength

public void setMaxLength(Integer maxLength)
Sets the maximum length of this field in characters. Set to null if a maximum length should not be enforced.

Parameters:
maxLength - the maximum length, or null if not enforced

isTrim

public boolean isTrim()
Returns true if field text will be trimmed before validation and type conversion.

Returns:
true if field text will be trimmed

setTrim

public void setTrim(boolean trim)
Set to true if field text should be trimmed before validation and type conversion.

Parameters:
trim - true if field text will be trimmed

isRecordIdentifier

public boolean isRecordIdentifier()
Returns true if this field is used to identify the type of record.

Returns:
true if this field is used to identify the record

setRecordIdentifier

public void setRecordIdentifier(boolean b)
Set to true if this field is used to identify the type of record.

Parameters:
b - true if this field is used to identify the record

getLiteral

public String getLiteral()
Returns the static text for this field, or null if the field text is not static. If defined, the field text must match the literal value when reading an input stream, and likewise, the literal value will be written to an output stream.

Returns:
the literal text of the field

setLiteral

public void setLiteral(String literal)
Sets the static text for this field. Set to null if the field text is not static. If defined, the field text must match the literal value when reading an input stream, and likewise, the literal value will be written to an output stream.

Parameters:
literal - the literal text of the field

getRegex

public String getRegex()
Returns the regular expression pattern for validating this field's text when read from an input stream. Field text is only validated if its not the empty string after trimming (if enabled).

Returns:
the regular expression pattern

setRegex

public void setRegex(String pattern)
Sets the regular expression pattern for validating this field's text when read from an input stream. Field text is only validated if its not the empty string after trimming (if enabled).

Parameters:
pattern - the regular expression pattern

isRequired

public boolean isRequired()
Returns true if this field is required when parsing an input stream. 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 to true if this field is required when parsing an input stream. 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

getTypeHandler

public String getTypeHandler()
Returns the name of the custom type handler used for type conversion by this field, or null if the default type handler is sufficient.

Returns:
the name of the custom type handler

setTypeHandler

public void setTypeHandler(String handler)
Sets the name of the custom type handler to use for type conversion by this field. Set to null if the default type handler is sufficient.

Parameters:
handler - the name of the custom type handler

getFormat

public String getFormat()
Returns the format pattern used by date and number type handlers.

Returns:
the date or number format pattern

setFormat

public void setFormat(String format)
Sets the format pattern used by date and number type handlers.

Parameters:
format - the date or number format pattern

getLength

public int getLength()
Returns the length of this field in characters. Applies to fixed length and padded fields.

Returns:
the length of this field

setLength

public void setLength(int 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 Character getPadding()
Returns the character used to pad this field.

Returns:
the character used to pad this field

setPadding

public void setPadding(Character padding)
Sets the character used to pad this field.

Parameters:
padding - the character used to pad this field

getJustify

public String getJustify()
Returns the justification of this field. Defaults to left. Applies to fixed length and padded fields.

Returns:
LEFT or RIGHT

setJustify

public void setJustify(String justify)
Sets the justification of this field. Applies to fixed length and padded fields.

Parameters:
justify - LEFT or RIGHT

BeanIO 1.2.3

Copyright © 2010-2012 Kevin Seim