BeanIO 2.0.4

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

A Selector is used to match a Group or Record for marshalling and unmarshalling.

Since:
2.0
Author:
Kevin Seim

Field Summary
static String COUNT_KEY
           
 
Method Summary
 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 the Property 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, String namespace, Map<String,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, String namespace, Map<String,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, isLazy, marshal, matches, setValue, unmarshal
 

Field Detail

COUNT_KEY

static final 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 - the MarshallingContext
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 - the UnmarshallingContext
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 when matchNext(UnmarshallingContext) returns null, in order to differentiate between unexpected and unidentified record types.

Parameters:
context - the UnmarshallingContext
Returns:
the matched Selector

skip

void skip(UnmarshallingContext context)
Skips a record or group of records.

Parameters:
context - the UnmarshallingContext

close

Selector close(ParsingContext context)
Checks for any unsatisfied components before the stream is closed.

Parameters:
context - the ParsingContext
Returns:
the first unsatisfied node

reset

void reset(ParsingContext context)
Resets the component count of this Selector's children.

Parameters:
context - the ParsingContext

getCount

int getCount(ParsingContext context)
Returns the number of times this component was matched within the current iteration of its parent component.

Parameters:
context - the ParsingContext
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 - the ParsingContext
count - the new match count

isMaxOccursReached

boolean isMaxOccursReached(ParsingContext context)
Returns whether this component has reached its maximum occurrences.

Parameters:
context - the ParsingContext
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 the Property 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,
                 String namespace,
                 Map<String,Object> state)
Updates a Map with the current state of the Writer to allow for restoration at a later time.

Parameters:
context - the ParsingContext
namespace - a String to prefix all state keys with
state - the Map to update with the latest state

restoreState

void restoreState(ParsingContext context,
                  String namespace,
                  Map<String,Object> state)
                  throws IllegalStateException
Restores a Map of previously stored state information.

Parameters:
context - the ParsingContext
namespace - a String to prefix all state keys with
state - the Map containing the state to restore
Throws:
IllegalStateException - if the Map is missing any state information

BeanIO 2.0.4

Copyright © 2010-2013 Kevin Seim