| 
 | BeanIO 2.0.4 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.beanio.internal.util.TreeNode<Component>
org.beanio.internal.parser.Component
org.beanio.internal.parser.ParserComponent
org.beanio.internal.parser.Field
public class Field
A parser for marshalling and unmarshalling a single field in a record. A field is usually, but optionally, bound to a simple property value.
A field component does not have any children.
| Field Summary | 
|---|
| Fields inherited from interface org.beanio.internal.parser.Property | 
|---|
| AGGREGATION_ARRAY, AGGREGATION_COLLECTION, AGGREGATION_MAP, COLLECTION, COMPLEX, MAP, SIMPLE | 
| Constructor Summary | |
|---|---|
| Field()Constructs a new Field. | |
| Method Summary | |
|---|---|
|  void | clearValue(ParsingContext context)Clears the property value. | 
|  Object | createValue(ParsingContext context)Creates the property value and returns it. | 
|  boolean | defines(Object value) | 
| protected  String | formatValue(Object value)Formats a field/property value. | 
|  PropertyAccessor | getAccessor() | 
|  Object | getDefaultValue()Returns the default value for a field parsed by this field definition when the field text is null or the empty string (after trimming). | 
|  FieldFormat | getFormat() | 
|  TypeHandler | getHandler() | 
|  String | getLiteral() | 
|  int | getMaxLength() | 
|  int | getMinLength() | 
|  Class<?> | getPropertyType() | 
|  String | getRegex()Returns the regular expression pattern the field text parsed by this field definition must match. | 
| protected  Pattern | getRegexPattern()Returns the regular expression the field text parsed by this field definition must match. | 
|  int | getSize()Returns the size of a single occurrence of this element, which is used to offset field positions for repeating segments and fields. | 
|  Class<?> | getType() | 
|  Object | getValue(ParsingContext context)Returns the value of this property. | 
|  boolean | hasContent(ParsingContext context)Returns whether this parser or any of its descendant have content for marshalling. | 
|  boolean | hasNext(UnmarshallingContext context) | 
|  boolean | isBound() | 
|  boolean | isIdentifier()Returns whether this property or any of its descendants are used to identify a bean object. | 
|  boolean | isLazy()Returns whether this node must exist during unmarshalling. | 
| protected  boolean | isMatch(String text)Returns true if the provided field text is a match for this field definition based on the configured literal value or regular expression. | 
|  boolean | isRequired() | 
| protected  boolean | isSupportedChild(Component child)Returns whether a node is a supported child of this node. | 
|  boolean | isTrim() | 
|  boolean | marshal(MarshallingContext context)Marshals a record. | 
|  boolean | matches(UnmarshallingContext context)Tests if the field text in the record matches this field. | 
| protected  Object | parseValue(UnmarshallingContext context,
           String fieldText)Parses and validates a field property value from the given field text. | 
|  void | registerLocals(Set<ParserLocal<? extends Object>> locals)Called by a stream to register variables stored in the parsing context. | 
|  void | setAccessor(PropertyAccessor accessor) | 
|  void | setBound(boolean property) | 
|  void | setDefaultValue(Object defaultValue)Sets the default value for a field parsed by this field definition when the field text is null or the empty string (after trimming). | 
|  void | setFormat(FieldFormat format) | 
|  void | setHandler(TypeHandler handler) | 
|  void | setIdentifier(boolean recordIdentifier) | 
|  void | setLiteral(String literal) | 
|  void | setMaxLength(int maxLength) | 
|  void | setMinLength(int minLength) | 
|  void | setPropertyType(Class<?> type) | 
|  void | setRegex(Pattern regex) | 
|  void | setRegex(String pattern)Sets the regular expression pattern the field text parsed by this field definition must match. | 
|  void | setRequired(boolean required) | 
|  void | setTrim(boolean trim) | 
|  void | setType(Class<?> type) | 
|  void | setValue(ParsingContext context,
         Object value)Sets the property value (before marshalling). | 
| protected  void | toParamString(StringBuilder s)Called by TreeNode.toString()to append node parameters to the output. | 
|  int | type()Returns the property type. | 
|  boolean | unmarshal(UnmarshallingContext context)Unmarshals a record. | 
| Methods inherited from class org.beanio.internal.util.TreeNode | 
|---|
| add, clone, find, getChildren, getFirst, getName, iterator, print, setName, size, sort, toString, updateReferences | 
| Methods inherited from class java.lang.Object | 
|---|
| equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait | 
| Methods inherited from interface org.beanio.internal.parser.Property | 
|---|
| getName | 
| Methods inherited from interface org.beanio.internal.parser.Parser | 
|---|
| getName | 
| Constructor Detail | 
|---|
public Field()
| Method Detail | 
|---|
public boolean hasContent(ParsingContext context)
Parser
hasContent in interface Parsercontext - the ParsingContext
public int type()
Property
type in interface PropertyProperty.SIMPLE, Property.COMPLEX, Property.AGGREGATION_ARRAY, Property.COLLECTION, 
   Property.AGGREGATION_COLLECTION, or Property.MAPpublic boolean isLazy()
Parser
isLazy in interface Parserpublic boolean defines(Object value)
defines in interface Propertypublic boolean matches(UnmarshallingContext context)
matches in interface Parsercontext - the UnmarshallingContext containing the record to match
protected boolean isMatch(String text)
text - the field text to test
public boolean marshal(MarshallingContext context)
Parser
marshal in interface Parsercontext - the MarshallingContext
public boolean hasNext(UnmarshallingContext context)
public boolean unmarshal(UnmarshallingContext context)
Parser
unmarshal in interface Parsercontext - the UnmarshallingContext
protected Object parseValue(UnmarshallingContext context,
                            String fieldText)
context - the UnmarshallingContext to report field errors tofieldText - the field text to parse
Value.INVALID if the field was invalid,
   or Value.MISSING if the field was not present in the recordprotected String formatValue(Object value)
value - the property value to format
public void clearValue(ParsingContext context)
PropertyProperty.getValue(ParsingContext) should
 return null, or Value.MISSING for lazy property values.
clearValue in interface ParserclearValue in interface Propertycontext - the ParsingContextpublic Object createValue(ParsingContext context)
Property
createValue in interface Propertycontext - the ParsingContext
public Object getValue(ParsingContext context)
PropertyWhen unmarshalling, this method should return Value.MISSING if the field
 was not present in the stream.  Or if present, but has no value, null should be returned.  
 
 
When marshalling, this method should return Value.MISSING for any optional
 segment bound to a bean object, or null if required.  Null field properties should 
 always return Value.MISSING.
getValue in interface ParsergetValue in interface Propertycontext - the ParsingContext
Value.MISSING if not present in the stream,
   or Value.INVALID if the field was invalid
public void setValue(ParsingContext context,
                     Object value)
Property
setValue in interface ParsersetValue in interface Propertycontext - the ParsingContextvalue - the property valueprotected boolean isSupportedChild(Component child)
TreeNodeTreeNode.add(TreeNode).
isSupportedChild in class ParserComponentchild - the node to test
public String getRegex()
public void setRegex(String pattern)
              throws PatternSyntaxException
pattern - the regular expression pattern
PatternSyntaxException - if the pattern is invalidprotected Pattern getRegexPattern()
public void registerLocals(Set<ParserLocal<? extends Object>> locals)
Component
registerLocals in class Componentlocals - set of local variablespublic void setPropertyType(Class<?> type)
public Class<?> getPropertyType()
public boolean isIdentifier()
Property
isIdentifier in interface ParserisIdentifier in interface Propertypublic void setIdentifier(boolean recordIdentifier)
setIdentifier in interface Propertypublic FieldFormat getFormat()
public void setFormat(FieldFormat format)
public String getLiteral()
public void setLiteral(String literal)
public Class<?> getType()
getType in interface Propertypublic boolean isTrim()
public void setTrim(boolean trim)
public boolean isRequired()
public void setRequired(boolean required)
public int getMinLength()
public void setMinLength(int minLength)
public int getMaxLength()
public void setMaxLength(int maxLength)
public void setRegex(Pattern regex)
public void setType(Class<?> type)
setType in interface Propertypublic PropertyAccessor getAccessor()
getAccessor in interface Propertypublic void setAccessor(PropertyAccessor accessor)
setAccessor in interface Propertypublic Object getDefaultValue()
public void setDefaultValue(Object defaultValue)
defaultValue - the default valuepublic TypeHandler getHandler()
public void setHandler(TypeHandler handler)
protected void toParamString(StringBuilder s)
TreeNodeTreeNode.toString() to append node parameters to the output.
toParamString in class TreeNode<Component>s - the output to appendpublic int getSize()
ParserThe concept of size is dependent on the stream format. The size of an element in a fixed length stream format is determined by the length of the element in characters, while other stream formats calculate size based on the number of fields. Some stream formats, such as XML, may ignore size settings.
getSize in interface Parserpublic boolean isBound()
public void setBound(boolean property)
| 
 | BeanIO 2.0.4 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||