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 voidclearValue(ParsingContext context)Clears the current property value.protected java.util.Map<java.lang.Object,java.lang.Object>createMap()java.lang.ObjectcreateValue(ParsingContext context)Creates the property value and returns it.booleandefines(java.lang.Object value)intgetIterationSize()Returns the size of the components that make up a single iteration.PropertygetKey()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.ObjectgetValue(ParsingContext context)Returns the unmarshalled property value.booleanhasContent(ParsingContext context)Returns whether this parser or any of its descendant have content for marshalling.booleanisProperty()Returns whether this iteration is a property of a bean object.protected intlength(java.lang.Object value)Returns the length of aggregation.protected booleanmarshal(MarshallingContext context, Parser delegate, int minOccurs, int maxOccurs)booleanmatches(UnmarshallingContext context)Returns whether this parser and its children match a record being unmarshalled.voidregisterLocals(java.util.Set<ParserLocal<? extends java.lang.Object>> locals)Called by a stream to register variables stored in the parsing context.voidsetKey(Property key)voidsetType(java.lang.Class<?> mapType)Sets the concreteMaptype.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.inttype()Returns the property type.protected booleanunmarshal(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:ParserClears the current property value.- Specified by:
clearValuein interfaceParser- Specified by:
clearValuein interfaceProperty- Overrides:
clearValuein classDelegatingParser- Parameters:
context- theParsingContext
-
defines
public boolean defines(java.lang.Object value)
-
matches
public boolean matches(UnmarshallingContext context)
Description copied from interface:ParserReturns whether this parser and its children match a record being unmarshalled.- Specified by:
matchesin interfaceParser- Overrides:
matchesin 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:
marshalin classAggregation- Throws:
java.io.IOException
-
unmarshal
protected boolean unmarshal(UnmarshallingContext context, Parser delegate, int minOccurs, int maxOccurs)
- Specified by:
unmarshalin classAggregation
-
isProperty
public boolean isProperty()
Returns whether this iteration is a property of a bean object.- Specified by:
isPropertyin 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 concreteMaptype.
-
createValue
public java.lang.Object createValue(ParsingContext context)
Description copied from interface:PropertyCreates 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:ParserReturns the unmarshalled property value.- Specified by:
getValuein interfaceParser- Specified by:
getValuein interfaceProperty- Overrides:
getValuein classDelegatingParser- Parameters:
context- theParsingContext- Returns:
- the property value
-
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 classAggregation- Parameters:
context- theParsingContextvalue- 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:AggregationReturns the length of aggregation.- Specified by:
lengthin classAggregation- Parameters:
value- the aggregation value- Returns:
- the length
-
getIterationSize
public int getIterationSize()
Description copied from interface:IterationReturns the size of the components that make up a single iteration.- Returns:
- the iteration size
-
type
public int type()
Description copied from interface:PropertyReturns the property type.
-
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 classAggregation- Parameters:
locals- set of local variables
-
hasContent
public boolean hasContent(ParsingContext context)
Description copied from interface:ParserReturns whether this parser or any of its descendant have content for marshalling.- Specified by:
hasContentin interfaceParser- Overrides:
hasContentin 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:TreeNodeCalled byTreeNode.toString()to append node parameters to the output.- Overrides:
toParamStringin classAggregation- Parameters:
s- the output to append
-
-