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.StringCOUNT_KEY
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Selectorclose(ParsingContext context)Checks for any unsatisfied components before the stream is closed.intgetCount(ParsingContext context)Returns the number of times this component was matched within the current iteration of its parent component.intgetMaxOccurs()Returns the maximum number of occurrences of this component (within the context of its parent).intgetMinOccurs()Returns the minimum number of occurrences of this component (within the context of its parent).intgetOrder()Returns the order of this component (within the context of its parent).PropertygetProperty()Returns thePropertymapped to this component, or null if there is no property mapping.booleanisMaxOccursReached(ParsingContext context)Returns whether this component has reached its maximum occurrences.booleanisRecordGroup()Returns whether this component is a record group.SelectormatchAny(UnmarshallingContext context)Finds a parser that matches the input record.SelectormatchNext(MarshallingContext context)Finds a parser for marshalling a bean object.SelectormatchNext(UnmarshallingContext context)Finds a parser for unmarshalling a record based on the current state of the stream.voidreset(ParsingContext context)Resets the component count of this Selector's children.voidrestoreState(ParsingContext context, java.lang.String namespace, java.util.Map<java.lang.String,java.lang.Object> state)Restores a Map of previously stored state information.voidsetCount(ParsingContext context, int count)Sets the number of times this component was matched within the current iteration of its parent component.voidskip(UnmarshallingContext context)Skips a record or group of records.voidupdateState(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
Selectorfor 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
Selectorfor 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- theParsingContextcount- 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 thePropertymapped to this component, or null if there is no property mapping.- Returns:
- the
Propertymapped 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- theParsingContextnamespace- 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- theParsingContextnamespace- 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
-
-