Package org.beanio.internal.parser
Class Aggregation
- java.lang.Object
-
- org.beanio.internal.util.TreeNode<Component>
-
- org.beanio.internal.parser.Component
-
- org.beanio.internal.parser.ParserComponent
-
- org.beanio.internal.parser.DelegatingParser
-
- org.beanio.internal.parser.Aggregation
-
- All Implemented Interfaces:
java.lang.Cloneable,java.lang.Iterable<Component>,Iteration,Parser,Property,Replicateable
- Direct Known Subclasses:
CollectionParser,MapParser
public abstract class Aggregation extends DelegatingParser implements Property, Iteration
Base class for parser components capable of aggregating descendant properties.- Since:
- 2.0.1
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanlazyprotected Fieldoccurs-
Fields inherited from interface org.beanio.internal.parser.Property
AGGREGATION_ARRAY, AGGREGATION_COLLECTION, AGGREGATION_MAP, COLLECTION, COMPLEX, MAP, SIMPLE
-
-
Constructor Summary
Constructors Constructor Description Aggregation()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description PropertyAccessorgetAccessor()intgetIterationIndex(ParsingContext context)Returns the index of the current iteration relative to its parent.intgetMaxOccurs()intgetMinOccurs()FieldgetOccurs()booleanisDynamicIteration()Returns whether the iteration size is variable based on another field in the record.booleanisIdentifier()Returns whether this parser or any descendant of this parser is used to identify a record during unmarshalling.booleanisLazy()booleanisOptional()Returns whether this node must exist during unmarshalling.abstract booleanisProperty()Returns whether this aggregation is a property of its parent bean object.protected abstract intlength(java.lang.Object value)Returns the length of aggregation.booleanmarshal(MarshallingContext context)Marshals a record.protected abstract booleanmarshal(MarshallingContext context, Parser delegate, int minOccurs, int maxOccurs)voidregisterLocals(java.util.Set<ParserLocal<? extends java.lang.Object>> locals)Called by a stream to register variables stored in the parsing context.voidsetAccessor(PropertyAccessor accessor)voidsetIdentifier(boolean identifier)protected voidsetIterationIndex(ParsingContext context, int index)voidsetLazy(boolean lazy)voidsetMaxOccurs(int maxOccurs)voidsetMinOccurs(int minOccurs)voidsetOccurs(Field occurs)voidsetValue(ParsingContext context, java.lang.Object value)Sets the property value for marshaling.protected voidtoParamString(java.lang.StringBuilder s)Called byTreeNode.toString()to append node parameters to the output.booleanunmarshal(UnmarshallingContext context)Unmarshals a record.protected abstract booleanunmarshal(UnmarshallingContext context, Parser delegate, int minOccurs, int maxOccurs)-
Methods inherited from class org.beanio.internal.parser.DelegatingParser
clearValue, getParser, getSize, getValue, hasContent, matches
-
Methods inherited from class org.beanio.internal.parser.ParserComponent
isSupportedChild
-
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.Iteration
getIterationSize
-
Methods inherited from interface org.beanio.internal.parser.Property
clearValue, createValue, defines, getName, getType, getValue, setType, type
-
-
-
-
Field Detail
-
lazy
protected boolean lazy
-
occurs
protected Field occurs
-
-
Method Detail
-
isProperty
public abstract boolean isProperty()
Returns whether this aggregation is a property of its parent bean object.- Returns:
- true if this a property, false otherwise
-
length
protected abstract int length(java.lang.Object value)
Returns the length of aggregation.- Parameters:
value- the aggregation value- Returns:
- the length
-
marshal
public final boolean marshal(MarshallingContext context) throws java.io.IOException
Description copied from interface:ParserMarshals a record.- Specified by:
marshalin interfaceParser- Overrides:
marshalin classDelegatingParser- Parameters:
context- theMarshallingContext- Returns:
- whether a value was marshalled
- Throws:
java.io.IOException- if an I/O error occurs
-
marshal
protected abstract boolean marshal(MarshallingContext context, Parser delegate, int minOccurs, int maxOccurs) throws java.io.IOException
- Throws:
java.io.IOException
-
unmarshal
public final boolean unmarshal(UnmarshallingContext context)
Description copied from interface:ParserUnmarshals a record.- Specified by:
unmarshalin interfaceParser- Overrides:
unmarshalin classDelegatingParser- Parameters:
context- theUnmarshallingContext- Returns:
trueif this component was present in the unmarshalled record, orfalseotherwise
-
unmarshal
protected abstract boolean unmarshal(UnmarshallingContext context, Parser delegate, int minOccurs, int maxOccurs)
-
setValue
public void setValue(ParsingContext context, java.lang.Object value)
Description copied from interface:ParserSets the property value for marshaling.- Specified by:
setValuein interfaceParser- Specified by:
setValuein interfaceProperty- Overrides:
setValuein classDelegatingParser- Parameters:
context- theParsingContextvalue- the property value
-
isOptional
public boolean isOptional()
Description copied from interface:ParserReturns whether this node must exist during unmarshalling.- Specified by:
isOptionalin interfaceParser- Overrides:
isOptionalin classDelegatingParser- Returns:
- true if this node is optional during unmarshalling, false otherwise
-
isIdentifier
public boolean isIdentifier()
Description copied from interface:ParserReturns whether this parser or any descendant of this parser is used to identify a record during unmarshalling.- Specified by:
isIdentifierin interfaceParser- Specified by:
isIdentifierin interfaceProperty- Overrides:
isIdentifierin classDelegatingParser- Returns:
- true if this parser or any descendant is used to identify a record
-
setIdentifier
public void setIdentifier(boolean identifier)
- Specified by:
setIdentifierin interfaceProperty- Throws:
java.lang.UnsupportedOperationException
-
getAccessor
public PropertyAccessor getAccessor()
- Specified by:
getAccessorin interfaceProperty
-
setAccessor
public void setAccessor(PropertyAccessor accessor)
- Specified by:
setAccessorin interfaceProperty
-
getIterationIndex
public final int getIterationIndex(ParsingContext context)
Description copied from interface:IterationReturns the index of the current iteration relative to its parent.- Specified by:
getIterationIndexin interfaceIteration- Returns:
- the index of the current iteration
-
setIterationIndex
protected final void setIterationIndex(ParsingContext context, int index)
-
getMinOccurs
public int getMinOccurs()
-
setMinOccurs
public void setMinOccurs(int minOccurs)
-
getMaxOccurs
public int getMaxOccurs()
-
setMaxOccurs
public void setMaxOccurs(int maxOccurs)
-
getOccurs
public Field getOccurs()
-
setOccurs
public void setOccurs(Field occurs)
-
isLazy
public boolean isLazy()
-
setLazy
public void setLazy(boolean lazy)
-
isDynamicIteration
public boolean isDynamicIteration()
Description copied from interface:IterationReturns whether the iteration size is variable based on another field in the record.- Specified by:
isDynamicIterationin interfaceIteration- Returns:
- true if variable, false otherwise
-
registerLocals
public void registerLocals(java.util.Set<ParserLocal<? extends java.lang.Object>> 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
-
toParamString
protected void toParamString(java.lang.StringBuilder s)
Description copied from class:TreeNodeCalled byTreeNode.toString()to append node parameters to the output.- Overrides:
toParamStringin classTreeNode<Component>- Parameters:
s- the output to append
-
-