Package org.beanio.internal.parser
Class MapParser
- java.lang.Object
-
- All Implemented Interfaces:
java.lang.Cloneable
,java.lang.Iterable<Component>
,Iteration
,Parser
,Property
,Replicateable
public class MapParser extends Aggregation
- Since:
- 2.0.1
-
-
Field Summary
-
Fields inherited from class org.beanio.internal.parser.Aggregation
lazy, 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 MapParser()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clearValue(ParsingContext context)
Clears the current property value.protected java.util.Map<java.lang.Object,java.lang.Object>
createMap()
java.lang.Object
createValue(ParsingContext context)
Creates the property value and returns it.boolean
defines(java.lang.Object value)
int
getIterationSize()
Returns the size of the components that make up a single iteration.Property
getKey()
protected java.util.Map<java.lang.Object,java.lang.Object>
getMap(ParsingContext context)
Returns the map value being parsed.java.lang.Class<? extends java.util.Map<java.lang.Object,java.lang.Object>>
getType()
java.lang.Object
getValue(ParsingContext context)
Returns the unmarshalled property value.boolean
hasContent(ParsingContext context)
Returns whether this parser or any of its descendant have content for marshalling.boolean
isProperty()
Returns whether this iteration is a property of a bean object.protected int
length(java.lang.Object value)
Returns the length of aggregation.protected boolean
marshal(MarshallingContext context, Parser delegate, int minOccurs, int maxOccurs)
boolean
matches(UnmarshallingContext context)
Returns whether this parser and its children match a record being unmarshalled.void
registerLocals(java.util.Set<ParserLocal<? extends java.lang.Object>> locals)
Called by a stream to register variables stored in the parsing context.void
setKey(Property key)
void
setType(java.lang.Class<?> mapType)
Sets the concreteMap
type.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.int
type()
Returns the property type.protected boolean
unmarshal(UnmarshallingContext context, Parser delegate, int minOccurs, int maxOccurs)
-
Methods inherited from class org.beanio.internal.parser.Aggregation
getAccessor, getIterationIndex, getMaxOccurs, getMinOccurs, getOccurs, isDynamicIteration, isIdentifier, isLazy, isOptional, marshal, setAccessor, setIdentifier, setIterationIndex, setLazy, setMaxOccurs, setMinOccurs, setOccurs, unmarshal
-
Methods inherited from class org.beanio.internal.parser.DelegatingParser
getParser, getSize
-
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
-
-
-
-
Method Detail
-
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
-
defines
public boolean defines(java.lang.Object value)
-
matches
public boolean matches(UnmarshallingContext context)
Description copied from interface:Parser
Returns whether this parser and its children match a record being unmarshalled.- Specified by:
matches
in interfaceParser
- Overrides:
matches
in classDelegatingParser
- Parameters:
context
- theUnmarshallingContext
- Returns:
- true if matched, false otherwise
-
marshal
protected boolean marshal(MarshallingContext context, Parser delegate, int minOccurs, int maxOccurs) throws java.io.IOException
- Specified by:
marshal
in classAggregation
- Throws:
java.io.IOException
-
unmarshal
protected boolean unmarshal(UnmarshallingContext context, Parser delegate, int minOccurs, int maxOccurs)
- Specified by:
unmarshal
in classAggregation
-
isProperty
public boolean isProperty()
Returns whether this iteration is a property of a bean object.- Specified by:
isProperty
in classAggregation
- Returns:
- true if this iteration is a property, false otherwise
-
getType
public java.lang.Class<? extends java.util.Map<java.lang.Object,java.lang.Object>> getType()
-
setType
public void setType(java.lang.Class<?> mapType)
Sets the concreteMap
type.
-
createValue
public java.lang.Object createValue(ParsingContext context)
Description copied from interface:Property
Creates the property value and returns it.- Parameters:
context
- theParsingContext
- Returns:
- the property value
-
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
-
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 classAggregation
- Parameters:
context
- theParsingContext
value
- the property value
-
createMap
protected java.util.Map<java.lang.Object,java.lang.Object> createMap()
-
getMap
protected java.util.Map<java.lang.Object,java.lang.Object> getMap(ParsingContext context)
Returns the map value being parsed.- Returns:
- the
Map
-
length
protected int length(java.lang.Object value)
Description copied from class:Aggregation
Returns the length of aggregation.- Specified by:
length
in classAggregation
- Parameters:
value
- the aggregation value- Returns:
- the length
-
getIterationSize
public int getIterationSize()
Description copied from interface:Iteration
Returns the size of the components that make up a single iteration.- Returns:
- the iteration size
-
type
public int type()
Description copied from interface:Property
Returns the property type.
-
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 classAggregation
- Parameters:
locals
- set of local variables
-
hasContent
public boolean hasContent(ParsingContext context)
Description copied from interface:Parser
Returns whether this parser or any of its descendant have content for marshalling.- Specified by:
hasContent
in interfaceParser
- Overrides:
hasContent
in classDelegatingParser
- Parameters:
context
- theParsingContext
- Returns:
- true if there is content for marshalling, false otherwise
-
getKey
public Property getKey()
-
setKey
public void setKey(Property key)
-
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 classAggregation
- Parameters:
s
- the output to append
-
-