Package org.beanio.internal.parser
Class RecordAggregation
- 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.RecordAggregation
-
- All Implemented Interfaces:
java.lang.Cloneable
,java.lang.Iterable<Component>
,Parser
,Property
,Selector
,Replicateable
- Direct Known Subclasses:
RecordCollection
,RecordMap
public abstract class RecordAggregation extends DelegatingParser implements Selector, Property
- Since:
- 2.0.1
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
lazy
protected ParserLocal<java.lang.Object>
value
-
Fields inherited from interface org.beanio.internal.parser.Property
AGGREGATION_ARRAY, AGGREGATION_COLLECTION, AGGREGATION_MAP, COLLECTION, COMPLEX, MAP, SIMPLE
-
-
Constructor Summary
Constructors Constructor Description RecordAggregation()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clearValue(ParsingContext context)
Clears the current property value.Selector
close(ParsingContext context)
Checks for any unsatisfied components before the stream is closed.protected java.lang.Object
createAggregationType()
java.lang.Object
createValue(ParsingContext context)
Creates the property value and returns it.boolean
defines(java.lang.Object value)
PropertyAccessor
getAccessor()
int
getCount(ParsingContext context)
Returns the number of times this component was matched within the current iteration of its parent component.int
getMaxOccurs()
Returns the maximum number of occurrences of this component (within the context of its parent).int
getMinOccurs()
Returns the minimum number of occurrences of this component (within the context of its parent).java.lang.Object
getNullValue()
int
getOrder()
Returns the order of this component (within the context of its parent).Property
getProperty()
Returns theProperty
mapped to this component, or null if there is no property mapping.Selector
getSelector()
Returns the child selector.java.lang.Class<?>
getType()
java.lang.Object
getValue(ParsingContext context)
Returns the unmarshalled property value.boolean
isIdentifier()
Returns whether this parser or any descendant of this parser is used to identify a record during unmarshalling.boolean
isLazy()
boolean
isMaxOccursReached(ParsingContext context)
Returns whether this component has reached its maximum occurrences.boolean
isRecordGroup()
Returns whether this component is a record group.protected boolean
isSupportedChild(Component child)
Returns whether a node is a supported child of this node.Selector
matchAny(UnmarshallingContext context)
Finds a parser that matches the input record.Selector
matchNext(MarshallingContext context)
Finds a parser for marshalling a bean object.Selector
matchNext(UnmarshallingContext context)
Finds a parser for unmarshalling a record based on the current state of the stream.void
registerLocals(java.util.Set<ParserLocal<? extends java.lang.Object>> locals)
Called by a stream to register variables stored in the parsing context.void
reset(ParsingContext context)
Resets the component count of this Selector's children.void
restoreState(ParsingContext context, java.lang.String namespace, java.util.Map<java.lang.String,java.lang.Object> state)
Restores a Map of previously stored state information.void
setAccessor(PropertyAccessor accessor)
void
setCount(ParsingContext context, int count)
Sets the number of times this component was matched within the current iteration of its parent component.void
setIdentifier(boolean identifier)
void
setLazy(boolean lazy)
void
setType(java.lang.Class<?> type)
Sets the collection type.void
setValue(ParsingContext context, java.lang.Object value)
Sets the property value for marshaling.void
skip(UnmarshallingContext context)
Skips a record or group of records.protected void
toParamString(java.lang.StringBuilder s)
Called byTreeNode.toString()
to append node parameters to the output.void
updateState(ParsingContext context, java.lang.String namespace, java.util.Map<java.lang.String,java.lang.Object> state)
Updates a Map with the current state of the Writer to allow for restoration at a later time.-
Methods inherited from class org.beanio.internal.parser.DelegatingParser
getParser, getSize, hasContent, isOptional, marshal, matches, unmarshal
-
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.Parser
getName, getSize, hasContent, isOptional, marshal, matches, unmarshal
-
-
-
-
Field Detail
-
value
protected ParserLocal<java.lang.Object> value
-
lazy
protected boolean lazy
-
-
Method Detail
-
setType
public void setType(java.lang.Class<?> type)
Sets the collection type.
-
createValue
public java.lang.Object createValue(ParsingContext context)
Description copied from interface:Property
Creates the property value and returns it.- Specified by:
createValue
in interfaceProperty
- Parameters:
context
- theParsingContext
- Returns:
- the property value
-
getNullValue
public java.lang.Object getNullValue()
-
createAggregationType
protected java.lang.Object createAggregationType()
-
getValue
public java.lang.Object getValue(ParsingContext context)
Description copied from interface:Parser
Returns the unmarshalled property value.- Specified by:
getValue
in interfaceParser
- Specified by:
getValue
in interfaceProperty
- Overrides:
getValue
in classDelegatingParser
- Parameters:
context
- theParsingContext
- Returns:
- the property value
-
clearValue
public void clearValue(ParsingContext context)
Description copied from interface:Parser
Clears the current property value.- Specified by:
clearValue
in interfaceParser
- Specified by:
clearValue
in interfaceProperty
- Overrides:
clearValue
in classDelegatingParser
- Parameters:
context
- theParsingContext
-
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
-
getProperty
public Property getProperty()
Description copied from interface:Selector
Returns theProperty
mapped to this component, or null if there is no property mapping.- Specified by:
getProperty
in interfaceSelector
- Returns:
- the
Property
mapped to this component
-
matchNext
public Selector matchNext(UnmarshallingContext context)
Description copied from interface:Selector
Finds a parser for unmarshalling a record based on the current state of the stream.- Specified by:
matchNext
in interfaceSelector
- Parameters:
context
- theUnmarshallingContext
- Returns:
- the matched
Selector
for unmarshalling the record
-
matchAny
public Selector matchAny(UnmarshallingContext context)
Description copied from interface:Selector
Finds a parser that matches the input record. This method is invoked whenSelector.matchNext(UnmarshallingContext)
returns null, in order to differentiate between unexpected and unidentified record types.- Specified by:
matchAny
in interfaceSelector
- Parameters:
context
- theUnmarshallingContext
- Returns:
- the matched
Selector
-
matchNext
public Selector matchNext(MarshallingContext context)
Description copied from interface:Selector
Finds a parser for marshalling a bean object. If matched by this Selector, the method should set the bean object on the property tree and return itself.- Specified by:
matchNext
in interfaceSelector
- Parameters:
context
- theMarshallingContext
- Returns:
- the matched
Selector
for marshalling the bean object
-
close
public Selector close(ParsingContext context)
Description copied from interface:Selector
Checks for any unsatisfied components before the stream is closed.- Specified by:
close
in interfaceSelector
- Parameters:
context
- theParsingContext
- Returns:
- the first unsatisfied node
-
reset
public void reset(ParsingContext context)
Description copied from interface:Selector
Resets the component count of this Selector's children.- Specified by:
reset
in interfaceSelector
- Parameters:
context
- theParsingContext
-
getCount
public int getCount(ParsingContext context)
Description copied from interface:Selector
Returns the number of times this component was matched within the current iteration of its parent component.- Specified by:
getCount
in interfaceSelector
- Parameters:
context
- theParsingContext
- Returns:
- the match count
-
setCount
public void setCount(ParsingContext context, int count)
Description copied from interface:Selector
Sets the number of times this component was matched within the current iteration of its parent component.- Specified by:
setCount
in interfaceSelector
- Parameters:
context
- theParsingContext
count
- the new match count
-
getOrder
public int getOrder()
Description copied from interface:Selector
Returns the order of this component (within the context of its parent).
-
isMaxOccursReached
public boolean isMaxOccursReached(ParsingContext context)
Description copied from interface:Selector
Returns whether this component has reached its maximum occurrences.- Specified by:
isMaxOccursReached
in interfaceSelector
- Parameters:
context
- theParsingContext
- Returns:
- true if maximum occurrences has been reached
-
updateState
public void updateState(ParsingContext context, java.lang.String namespace, java.util.Map<java.lang.String,java.lang.Object> state)
Description copied from interface:Selector
Updates a Map with the current state of the Writer to allow for restoration at a later time.- Specified by:
updateState
in interfaceSelector
- Parameters:
context
- theParsingContext
namespace
- a String to prefix all state keys withstate
- the Map to update with the latest state
-
restoreState
public void restoreState(ParsingContext context, java.lang.String namespace, java.util.Map<java.lang.String,java.lang.Object> state) throws java.lang.IllegalStateException
Description copied from interface:Selector
Restores a Map of previously stored state information.- Specified by:
restoreState
in interfaceSelector
- Parameters:
context
- theParsingContext
namespace
- a String to prefix all state keys withstate
- the Map containing the state to restore- Throws:
java.lang.IllegalStateException
- if the Map is missing any state information
-
getMinOccurs
public int getMinOccurs()
Description copied from interface:Selector
Returns the minimum number of occurrences of this component (within the context of its parent).- Specified by:
getMinOccurs
in interfaceSelector
- Returns:
- the minimum occurrences
-
getMaxOccurs
public int getMaxOccurs()
Description copied from interface:Selector
Returns the maximum number of occurrences of this component (within the context of its parent).- Specified by:
getMaxOccurs
in interfaceSelector
- Returns:
- the maximum occurrences
-
isLazy
public boolean isLazy()
-
setLazy
public void setLazy(boolean lazy)
-
isSupportedChild
protected boolean isSupportedChild(Component child)
Description copied from class:TreeNode
Returns whether a node is a supported child of this node. Called byTreeNode.add(TreeNode)
.- Overrides:
isSupportedChild
in classParserComponent
- Parameters:
child
- the node to test- Returns:
- true if the child is allowed
-
getAccessor
public PropertyAccessor getAccessor()
- Specified by:
getAccessor
in interfaceProperty
-
setAccessor
public void setAccessor(PropertyAccessor accessor)
- Specified by:
setAccessor
in interfaceProperty
-
setIdentifier
public void setIdentifier(boolean identifier)
- Specified by:
setIdentifier
in interfaceProperty
-
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
-
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
-
skip
public void skip(UnmarshallingContext context)
Description copied from interface:Selector
Skips a record or group of records.- Specified by:
skip
in interfaceSelector
- Parameters:
context
- theUnmarshallingContext
-
isRecordGroup
public boolean isRecordGroup()
Description copied from interface:Selector
Returns whether this component is a record group.- Specified by:
isRecordGroup
in interfaceSelector
- Returns:
- true if this component is a record group, false otherwise
-
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
-
-