BeanIO 2.0.4

org.beanio.internal.parser
Class Bean

java.lang.Object
  extended by org.beanio.internal.util.TreeNode<Component>
      extended by org.beanio.internal.parser.Component
          extended by org.beanio.internal.parser.PropertyComponent
              extended by org.beanio.internal.parser.Bean
All Implemented Interfaces:
Cloneable, Iterable<Component>, Property, Replicateable

public class Bean
extends PropertyComponent
implements Property

A component used to aggregate Property's into a bean object, which may also be a property of a parent bean object itself.

A bean may only have children that implement Property.

Since:
2.0
Author:
Kevin Seim

Field Summary
 
Fields inherited from class org.beanio.internal.parser.PropertyComponent
createMissingBeans
 
Fields inherited from interface org.beanio.internal.parser.Property
AGGREGATION_ARRAY, AGGREGATION_COLLECTION, AGGREGATION_MAP, COLLECTION, COMPLEX, MAP, SIMPLE
 
Constructor Summary
Bean()
          Constructs a new Bean.
 
Method Summary
 void clearValue(ParsingContext context)
          Clears the property value.
 Object createValue(ParsingContext context)
          Creates the property value and returns it.
 boolean defines(Object bean)
           
 Constructor<?> getConstructor()
          Returns the Constructor used to instantiate this bean object, or null if the default no-arg constructor is used.
 Object getValue(ParsingContext context)
          Returns the value of this property.
 boolean isLazy()
           
protected  boolean isMap()
          Returns whether the bean object implements Map.
protected  boolean isSupportedChild(Component child)
          Returns whether a node is a supported child of this node.
protected  Object newInstance(ParsingContext context)
          Creates a new instance of this bean object.
 void registerLocals(Set<ParserLocal<?>> locals)
          Called by a stream to register variables stored in the parsing context.
 void setConstructor(Constructor<?> constructor)
          Sets the Constructor used to instantiate this bean object.
 void setLazy(boolean lazy)
           
 void setRequired(boolean required)
          Sets whether this property should always be instantiated when Property.createValue(ParsingContext) is invoked.
 void setValue(ParsingContext context, Object value)
          Sets the property value (before marshalling).
 int type()
          Returns the property type.
 
Methods inherited from class org.beanio.internal.parser.PropertyComponent
getAccessor, getType, isIdentifier, isRequired, setAccessor, setIdentifier, setType, toParamString
 
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
getAccessor, getName, getType, isIdentifier, setAccessor, setIdentifier, setType
 

Constructor Detail

Bean

public Bean()
Constructs a new Bean.

Method Detail

clearValue

public void clearValue(ParsingContext context)
Description copied from interface: Property
Clears the property value. A subsequent call to Property.getValue(ParsingContext) should return null, or Value.MISSING for lazy property values.

Specified by:
clearValue in interface Property
Parameters:
context - the ParsingContext

defines

public boolean defines(Object bean)
Specified by:
defines in interface Property

createValue

public Object createValue(ParsingContext context)
Description copied from interface: Property
Creates the property value and returns it.

Specified by:
createValue in interface Property
Parameters:
context - the ParsingContext
Returns:
the property value

getValue

public Object getValue(ParsingContext context)
Description copied from interface: Property
Returns the value of this property.

When 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.

Specified by:
getValue in interface Property
Parameters:
context - the ParsingContext
Returns:
the property value, or Value.MISSING if not present in the stream, or Value.INVALID if the field was invalid

setValue

public void setValue(ParsingContext context,
                     Object value)
Description copied from interface: Property
Sets the property value (before marshalling).

Specified by:
setValue in interface Property
Parameters:
context - the ParsingContext
value - the property value

newInstance

protected Object newInstance(ParsingContext context)
Creates a new instance of this bean object.

Parameters:
context - the ParsingContext
Returns:
the new bean Object

isSupportedChild

protected boolean isSupportedChild(Component child)
Description copied from class: TreeNode
Returns whether a node is a supported child of this node. Called by TreeNode.add(TreeNode).

Overrides:
isSupportedChild in class PropertyComponent
Parameters:
child - the node to test
Returns:
true if the child is allowed

setRequired

public void setRequired(boolean required)
Description copied from class: PropertyComponent
Sets whether this property should always be instantiated when Property.createValue(ParsingContext) is invoked.

Overrides:
setRequired in class PropertyComponent
Parameters:
required - true to always instantiate this property, false otherwise

type

public int type()
Description copied from interface: Property
Returns the property type.

Specified by:
type in interface Property
Returns:
Property.SIMPLE, Property.COMPLEX, Property.AGGREGATION_ARRAY, Property.COLLECTION, Property.AGGREGATION_COLLECTION, or Property.MAP

isMap

protected boolean isMap()
Returns whether the bean object implements Map.

Returns:
true if the bean object implements Map, false otherwise

getConstructor

public Constructor<?> getConstructor()
Returns the Constructor used to instantiate this bean object, or null if the default no-arg constructor is used.

Returns:
the Constructor

setConstructor

public void setConstructor(Constructor<?> constructor)
Sets the Constructor used to instantiate this bean object.

Parameters:
constructor - the Constructor

registerLocals

public void registerLocals(Set<ParserLocal<?>> locals)
Description copied from class: Component
Called by a stream to register variables stored in the parsing context. This method should be overridden by subclasses that need to register one or more parser context variables.

Overrides:
registerLocals in class Component
Parameters:
locals - set of local variables

isLazy

public boolean isLazy()

setLazy

public void setLazy(boolean lazy)

BeanIO 2.0.4

Copyright © 2010-2013 Kevin Seim