Package org.beanio.internal.parser
Interface Selector
-
- All Superinterfaces:
Parser
- All Known Implementing Classes:
Group
,Record
,RecordAggregation
,RecordArray
,RecordCollection
,RecordMap
,XmlSelectorWrapper
public interface Selector extends Parser
- Since:
- 2.0
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
COUNT_KEY
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Selector
close(ParsingContext context)
Checks for any unsatisfied components before the stream is closed.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).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.boolean
isMaxOccursReached(ParsingContext context)
Returns whether this component has reached its maximum occurrences.boolean
isRecordGroup()
Returns whether this component is a record group.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
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
setCount(ParsingContext context, int count)
Sets the number of times this component was matched within the current iteration of its parent component.void
skip(UnmarshallingContext context)
Skips a record or group of records.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 interface org.beanio.internal.parser.Parser
clearValue, getName, getSize, getValue, hasContent, isIdentifier, isOptional, marshal, matches, setValue, unmarshal
-
-
-
-
Field Detail
-
COUNT_KEY
static final java.lang.String COUNT_KEY
- See Also:
- Constant Field Values
-
-
Method Detail
-
matchNext
Selector matchNext(MarshallingContext context)
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.- Parameters:
context
- theMarshallingContext
- Returns:
- the matched
Selector
for marshalling the bean object
-
matchNext
Selector matchNext(UnmarshallingContext context)
Finds a parser for unmarshalling a record based on the current state of the stream.- Parameters:
context
- theUnmarshallingContext
- Returns:
- the matched
Selector
for unmarshalling the record
-
matchAny
Selector matchAny(UnmarshallingContext context)
Finds a parser that matches the input record. This method is invoked whenmatchNext(UnmarshallingContext)
returns null, in order to differentiate between unexpected and unidentified record types.- Parameters:
context
- theUnmarshallingContext
- Returns:
- the matched
Selector
-
skip
void skip(UnmarshallingContext context)
Skips a record or group of records.- Parameters:
context
- theUnmarshallingContext
-
close
Selector close(ParsingContext context)
Checks for any unsatisfied components before the stream is closed.- Parameters:
context
- theParsingContext
- Returns:
- the first unsatisfied node
-
reset
void reset(ParsingContext context)
Resets the component count of this Selector's children.- Parameters:
context
- theParsingContext
-
getCount
int getCount(ParsingContext context)
Returns the number of times this component was matched within the current iteration of its parent component.- Parameters:
context
- theParsingContext
- Returns:
- the match count
-
setCount
void setCount(ParsingContext context, int count)
Sets the number of times this component was matched within the current iteration of its parent component.- Parameters:
context
- theParsingContext
count
- the new match count
-
isMaxOccursReached
boolean isMaxOccursReached(ParsingContext context)
Returns whether this component has reached its maximum occurrences.- Parameters:
context
- theParsingContext
- Returns:
- true if maximum occurrences has been reached
-
getMinOccurs
int getMinOccurs()
Returns the minimum number of occurrences of this component (within the context of its parent).- Returns:
- the minimum occurrences
-
getMaxOccurs
int getMaxOccurs()
Returns the maximum number of occurrences of this component (within the context of its parent).- Returns:
- the maximum occurrences
-
getOrder
int getOrder()
Returns the order of this component (within the context of its parent).- Returns:
- the component order
-
getProperty
Property getProperty()
Returns theProperty
mapped to this component, or null if there is no property mapping.- Returns:
- the
Property
mapped to this component
-
isRecordGroup
boolean isRecordGroup()
Returns whether this component is a record group.- Returns:
- true if this component is a record group, false otherwise
-
updateState
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.- Parameters:
context
- theParsingContext
namespace
- a String to prefix all state keys withstate
- the Map to update with the latest state
-
restoreState
void restoreState(ParsingContext context, java.lang.String namespace, java.util.Map<java.lang.String,java.lang.Object> state) throws java.lang.IllegalStateException
Restores a Map of previously stored state information.- 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
-
-