Package org.beanio.internal.parser
Class Bean
- java.lang.Object
-
- org.beanio.internal.util.TreeNode<Component>
-
- org.beanio.internal.parser.Component
-
- org.beanio.internal.parser.PropertyComponent
-
- org.beanio.internal.parser.Bean
-
- All Implemented Interfaces:
java.lang.Cloneable,java.lang.Iterable<Component>,Property,Replicateable
public class Bean extends PropertyComponent implements Property
A component used to aggregateProperty'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
-
-
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
Constructors Constructor Description Bean()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclearValue(ParsingContext context)Clears the property value.java.lang.ObjectcreateValue(ParsingContext context)Creates the property value and returns it.booleandefines(java.lang.Object bean)java.lang.reflect.Constructor<?>getConstructor()Returns theConstructorused to instantiate this bean object, or null if the default no-arg constructor is used.java.lang.ObjectgetValue(ParsingContext context)Returns the value of this property.booleanisLazy()protected booleanisMap()Returns whether the bean object implementsMap.protected booleanisSupportedChild(Component child)Returns whether a node is a supported child of this node.protected java.lang.ObjectnewInstance(ParsingContext context)Creates a new instance of this bean object.voidregisterLocals(java.util.Set<ParserLocal<?>> locals)Called by a stream to register variables stored in the parsing context.voidsetConstructor(java.lang.reflect.Constructor<?> constructor)Sets theConstructorused to instantiate this bean object.voidsetLazy(boolean lazy)voidsetRequired(boolean required)Sets whether this property should always be instantiated whenProperty.createValue(ParsingContext)is invoked.voidsetValue(ParsingContext context, java.lang.Object value)Sets the property value (before marshalling).inttype()Returns the property type.-
Methods inherited from class org.beanio.internal.parser.PropertyComponent
getAccessor, getType, isIdentifier, isMatchNull, isRequired, setAccessor, setIdentifier, setMatchNull, setType, toParamString
-
Methods inherited from class org.beanio.internal.util.TreeNode
add, clone, find, getChildren, getFirst, getName, isDescendant, iterator, print, 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
-
-
-
-
Method Detail
-
clearValue
public void clearValue(ParsingContext context)
Description copied from interface:PropertyClears the property value. A subsequent call toProperty.getValue(ParsingContext)should return null, orValue.MISSINGfor lazy property values.- Specified by:
clearValuein interfaceProperty- Parameters:
context- theParsingContext
-
createValue
public java.lang.Object createValue(ParsingContext context)
Description copied from interface:PropertyCreates the property value and returns it.- Specified by:
createValuein interfaceProperty- Parameters:
context- theParsingContext- Returns:
- the property value
-
getValue
public java.lang.Object getValue(ParsingContext context)
Description copied from interface:PropertyReturns the value of this property.When unmarshalling, this method should return
Value.MISSINGif 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.MISSINGfor any optional segment bound to a bean object, or null if required. Null field properties should always returnValue.MISSING.- Specified by:
getValuein interfaceProperty- Parameters:
context- theParsingContext- Returns:
- the property value,
or
Value.MISSINGif not present in the stream, orValue.INVALIDif the field was invalid
-
setValue
public void setValue(ParsingContext context, java.lang.Object value)
Description copied from interface:PropertySets the property value (before marshalling).- Specified by:
setValuein interfaceProperty- Parameters:
context- theParsingContextvalue- the property value
-
newInstance
protected java.lang.Object newInstance(ParsingContext context)
Creates a new instance of this bean object.- Parameters:
context- theParsingContext- Returns:
- the new bean
Object
-
isSupportedChild
protected boolean isSupportedChild(Component child)
Description copied from class:TreeNodeReturns whether a node is a supported child of this node. Called byTreeNode.add(TreeNode).- Overrides:
isSupportedChildin classPropertyComponent- Parameters:
child- the node to test- Returns:
- true if the child is allowed
-
setRequired
public void setRequired(boolean required)
Description copied from class:PropertyComponentSets whether this property should always be instantiated whenProperty.createValue(ParsingContext)is invoked.- Overrides:
setRequiredin classPropertyComponent- Parameters:
required- true to always instantiate this property, false otherwise
-
type
public int type()
Description copied from interface:PropertyReturns the property type.- Specified by:
typein interfaceProperty- Returns:
Property.SIMPLE,Property.COMPLEX,Property.AGGREGATION_ARRAY,Property.COLLECTION,Property.AGGREGATION_COLLECTION, orProperty.MAP
-
isMap
protected boolean isMap()
Returns whether the bean object implementsMap.- Returns:
- true if the bean object implements
Map, false otherwise
-
getConstructor
public java.lang.reflect.Constructor<?> getConstructor()
Returns theConstructorused to instantiate this bean object, or null if the default no-arg constructor is used.- Returns:
- the
Constructor
-
setConstructor
public void setConstructor(java.lang.reflect.Constructor<?> constructor)
Sets theConstructorused to instantiate this bean object.- Parameters:
constructor- theConstructor
-
registerLocals
public void registerLocals(java.util.Set<ParserLocal<?>> locals)
Description copied from class:ComponentCalled 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:
registerLocalsin classComponent- Parameters:
locals- set of local variables
-
isLazy
public boolean isLazy()
-
setLazy
public void setLazy(boolean lazy)
-
-