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 boolean
lazy
protected Field
occurs
-
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 PropertyAccessor
getAccessor()
int
getIterationIndex(ParsingContext context)
Returns the index of the current iteration relative to its parent.int
getMaxOccurs()
int
getMinOccurs()
Field
getOccurs()
boolean
isDynamicIteration()
Returns whether the iteration size is variable based on another field in the record.boolean
isIdentifier()
Returns whether this parser or any descendant of this parser is used to identify a record during unmarshalling.boolean
isLazy()
boolean
isOptional()
Returns whether this node must exist during unmarshalling.abstract boolean
isProperty()
Returns whether this aggregation is a property of its parent bean object.protected abstract int
length(java.lang.Object value)
Returns the length of aggregation.boolean
marshal(MarshallingContext context)
Marshals a record.protected abstract boolean
marshal(MarshallingContext context, Parser delegate, int minOccurs, int maxOccurs)
void
registerLocals(java.util.Set<ParserLocal<? extends java.lang.Object>> locals)
Called by a stream to register variables stored in the parsing context.void
setAccessor(PropertyAccessor accessor)
void
setIdentifier(boolean identifier)
protected void
setIterationIndex(ParsingContext context, int index)
void
setLazy(boolean lazy)
void
setMaxOccurs(int maxOccurs)
void
setMinOccurs(int minOccurs)
void
setOccurs(Field occurs)
void
setValue(ParsingContext context, java.lang.Object value)
Sets the property value for marshaling.protected void
toParamString(java.lang.StringBuilder s)
Called byTreeNode.toString()
to append node parameters to the output.boolean
unmarshal(UnmarshallingContext context)
Unmarshals a record.protected abstract boolean
unmarshal(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:Parser
Marshals a record.- Specified by:
marshal
in interfaceParser
- Overrides:
marshal
in 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:Parser
Unmarshals a record.- Specified by:
unmarshal
in interfaceParser
- Overrides:
unmarshal
in classDelegatingParser
- Parameters:
context
- theUnmarshallingContext
- Returns:
true
if this component was present in the unmarshalled record, orfalse
otherwise
-
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:Parser
Sets the property value for marshaling.- Specified by:
setValue
in interfaceParser
- Specified by:
setValue
in interfaceProperty
- Overrides:
setValue
in classDelegatingParser
- Parameters:
context
- theParsingContext
value
- the property value
-
isOptional
public boolean isOptional()
Description copied from interface:Parser
Returns whether this node must exist during unmarshalling.- Specified by:
isOptional
in interfaceParser
- Overrides:
isOptional
in classDelegatingParser
- Returns:
- true if this node is optional during unmarshalling, false otherwise
-
isIdentifier
public boolean isIdentifier()
Description copied from interface:Parser
Returns whether this parser or any descendant of this parser is used to identify a record during unmarshalling.- Specified by:
isIdentifier
in interfaceParser
- Specified by:
isIdentifier
in interfaceProperty
- Overrides:
isIdentifier
in classDelegatingParser
- Returns:
- true if this parser or any descendant is used to identify a record
-
setIdentifier
public void setIdentifier(boolean identifier)
- Specified by:
setIdentifier
in interfaceProperty
- Throws:
java.lang.UnsupportedOperationException
-
getAccessor
public PropertyAccessor getAccessor()
- Specified by:
getAccessor
in interfaceProperty
-
setAccessor
public void setAccessor(PropertyAccessor accessor)
- Specified by:
setAccessor
in interfaceProperty
-
getIterationIndex
public final int getIterationIndex(ParsingContext context)
Description copied from interface:Iteration
Returns the index of the current iteration relative to its parent.- Specified by:
getIterationIndex
in 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:Iteration
Returns whether the iteration size is variable based on another field in the record.- Specified by:
isDynamicIteration
in interfaceIteration
- Returns:
- true if variable, false otherwise
-
registerLocals
public void registerLocals(java.util.Set<ParserLocal<? extends java.lang.Object>> 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 classComponent
- Parameters:
locals
- set of local variables
-
toParamString
protected void toParamString(java.lang.StringBuilder s)
Description copied from class:TreeNode
Called byTreeNode.toString()
to append node parameters to the output.- Overrides:
toParamString
in classTreeNode<Component>
- Parameters:
s
- the output to append
-
-