net.sourceforge.aqueduct.state
Class RegexState

java.lang.Object
  extended by net.sourceforge.aqueduct.state.AbstractState<StringSequenceInputSource>
      extended by net.sourceforge.aqueduct.state.RegexState
All Implemented Interfaces:
State<StringSequenceInputSource>, StringSequenceState

public class RegexState
extends AbstractState<StringSequenceInputSource>
implements StringSequenceState

State implementation that uses regular expression matching to select the next transition.

Author:
keith

Nested Class Summary
static class RegexState.Builder
          Convenience class that simplifies the code required to create a RegexState instance.
 
Constructor Summary
RegexState(java.lang.String id, boolean stopState, java.util.Map<java.util.regex.Pattern,java.lang.String> regexTransitions, java.lang.String defaultTransition)
           
 
Method Summary
 java.lang.String findTransitionName(java.lang.String value)
          Iterates over the regular expressions in this object's regexTransitions map, testing the provided String against each expression.
 java.lang.String nextTransition(StringSequenceInputSource inputSource)
          Returns the transition name that corresponds to the next String in the provided StringSequenceInputSource.
 
Methods inherited from class net.sourceforge.aqueduct.state.AbstractState
getId, isStopState, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface net.sourceforge.aqueduct.State
getId, isStopState
 

Constructor Detail

RegexState

public RegexState(java.lang.String id,
                  boolean stopState,
                  java.util.Map<java.util.regex.Pattern,java.lang.String> regexTransitions,
                  java.lang.String defaultTransition)
Method Detail

nextTransition

public java.lang.String nextTransition(StringSequenceInputSource inputSource)
Returns the transition name that corresponds to the next String in the provided StringSequenceInputSource.

Specified by:
nextTransition in interface State<StringSequenceInputSource>
Returns:

findTransitionName

public java.lang.String findTransitionName(java.lang.String value)
Iterates over the regular expressions in this object's regexTransitions map, testing the provided String against each expression. When the first matching expression is found, the associated transition name is returned. If no matching transition is found, this object's default transition is returned.

Parameters:
value -
Returns:


Copyright © 2008. All Rights Reserved.