org.springframework.batch.core.job.flow.support
Class StateTransition

java.lang.Object
  extended by org.springframework.batch.core.job.flow.support.StateTransition
All Implemented Interfaces:
Comparable<StateTransition>

public class StateTransition
extends Object
implements Comparable<StateTransition>

Value object representing a potential transition from one State to another. The originating State name and the next State to execute are linked by a pattern for the exit code of an execution of the originating State.

Since:
2.0
Author:
Dave Syer

Method Summary
 int compareTo(StateTransition other)
          Sorts by decreasing specificity of pattern, based on just counting wildcards (with * taking precedence over ?).
static StateTransition createEndStateTransition(State state)
          Create a new end state StateTransition specification.
static StateTransition createEndStateTransition(State state, String pattern)
          Create a new end state StateTransition specification.
static StateTransition createStateTransition(State state, String next)
          Create a new state StateTransition specification with a wildcard pattern that matches all outcomes.
static StateTransition createStateTransition(State state, String pattern, String next)
          Create a new StateTransition specification from one State to another (by name).
 String getNext()
          Public getter for the next State name.
 State getState()
          Public getter for the State.
 boolean isEnd()
          Check for a special next State signalling the end of a job.
 boolean matches(String status)
          Check if the provided status matches the pattern, signalling that the next State should be executed.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

createEndStateTransition

public static StateTransition createEndStateTransition(State state)
Create a new end state StateTransition specification. This transition explicitly goes unconditionally to an end state (i.e. no more executions).

Parameters:
state - the State used to generate the outcome for this transition

createEndStateTransition

public static StateTransition createEndStateTransition(State state,
                                                       String pattern)
Create a new end state StateTransition specification. This transition explicitly goes to an end state (i.e. no more processing) if the outcome matches the pattern.

Parameters:
state - the State used to generate the outcome for this transition
pattern - the pattern to match in the exit status of the State

createStateTransition

public static StateTransition createStateTransition(State state,
                                                    String next)
Create a new state StateTransition specification with a wildcard pattern that matches all outcomes.

Parameters:
state - the State used to generate the outcome for this transition
next - the name of the next State to execute

createStateTransition

public static StateTransition createStateTransition(State state,
                                                    String pattern,
                                                    String next)
Create a new StateTransition specification from one State to another (by name).

Parameters:
state - the State used to generate the outcome for this transition
pattern - the pattern to match in the exit status of the State
next - the name of the next State to execute

getState

public State getState()
Public getter for the State.

Returns:
the State

getNext

public String getNext()
Public getter for the next State name.

Returns:
the next

matches

public boolean matches(String status)
Check if the provided status matches the pattern, signalling that the next State should be executed.

Parameters:
status - the status to compare
Returns:
true if the pattern matches this status

isEnd

public boolean isEnd()
Check for a special next State signalling the end of a job.

Returns:
true if this transition goes nowhere (there is no next)

compareTo

public int compareTo(StateTransition other)
Sorts by decreasing specificity of pattern, based on just counting wildcards (with * taking precedence over ?). If wildcard counts are equal then falls back to alphabetic comparison. Hence * > foo* > ??? > fo? > foo.

Specified by:
compareTo in interface Comparable<StateTransition>
See Also:
Comparable.compareTo(Object)

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2009 SpringSource. All Rights Reserved.