Skip navigation links


oracle.idm.util
Class Transitions

java.lang.Object
  extended by oracle.idm.util.Transitions

All Implemented Interfaces:
java.lang.Cloneable, XmlPrintable

public class Transitions
extends java.lang.Object
implements java.lang.Cloneable, XmlPrintable

Transitions model state machine transitions. Null state is allowed and required as a pre-initial state; a state machine is in a null state before it has transitioned to one of its initial states.

A simple state machine with the following states:

 STARTED -> [ FINISHED | ABORTED ]
 

Is modelled with the following state transitions:

 null -> STARTED
 STARTED -> FINISHED
 STARTED -> ABORTED
 

And constructed as follows:

 new Transitions(new String[][] {
     { null, STARTED },
     { STARTED, FINISHED },
     { STARTED, ABORTED },
 });
 

Field Summary
static Transitions EMPTY_TRANSITIONS
          Empty unmodifiable state transitions.
protected  java.util.Map map
           
protected  boolean modifiable
           

 

Constructor Summary
Transitions()
          Creates empty modifiable state transitions.
Transitions(boolean modifiable)
          Creates empty state transitions.
Transitions(java.lang.String[][] transitions)
          Creates modifiable state transitions from String[][].
Transitions(java.lang.String[][] transitions, boolean modifiable)
          Creates state transitions from String[][].
Transitions(Transitions transitions)
          Creates modifiable state transitions from given transitions.
Transitions(Transitions transitions, boolean modifiable)
          Creates state transitions from given transitions.

 

Method Summary
 void add(java.lang.String[][] transitions)
          Adds all given state transitions.
 void add(java.lang.String from, java.lang.String to)
          Adds the given state transition.
 void add(Transitions transitions)
          Adds all given state transitions.
 java.lang.Object clone()
          This method clones Transitions.
 boolean contains(java.lang.String state)
          Checks if state transitions contain the given state.
 boolean contains(java.lang.String from, java.lang.String to)
          Checks if state transitions contain the given state transition.
 boolean equals(java.lang.Object object)
          This method compares transitions with the the specified object for equality.
 java.util.Set getFinal()
          Getter for final states.
 java.util.Set getInitial()
          Getter for initial states.
 java.util.Set getIntermediate()
          Getter for intermediate states.
 java.util.Set getNext(java.lang.String current)
          Getter for next states.
 java.util.Set getPrevious(java.lang.String current)
          Getter for previous states.
 java.util.Set getReachable()
          Getter for reachable states.
 java.util.Set getStates()
          Getter for all states.
 java.util.Set getUnreachable()
          Getter for unreachable states.
 int hashCode()
          This method returns the hash code value for this transitions object.
 boolean isEmpty()
          Returns true is there are no state transitions.
 boolean isFinal(java.lang.String state)
          Checks if the state is a final state.
 boolean isInitial(java.lang.String state)
          Checks if the state is an initial state.
 boolean isIntermediate(java.lang.String state)
          Checks if the state is an intermediate state.
 boolean isModifiable()
          Checks if state transitions are modifiable.
 boolean isNext(java.lang.String current, java.lang.String next)
          Checks if the next state can be reached from the current state.
 boolean isPrevious(java.lang.String current, java.lang.String previous)
          Checks if the current state can be reached from the previous state.
 boolean isReachable(java.lang.String state)
          Checks if the state is a reachable state.
 boolean isState(java.lang.String state)
          Checks if the state is a valid non-null state.
 boolean isUnreachable(java.lang.String state)
          Checks if the state is an unreachable state.
 void remove(java.lang.String state)
          Removes all state transitions containing the given state.
 void remove(java.lang.String[][] transitions)
          Removes all given state transitions.
 void remove(java.lang.String from, java.lang.String to)
          Removes the given state transition.
 void remove(Transitions transitions)
          Removes all given state transitions.
 int size()
          Calculates the number of state transitions.
 java.lang.String[][] toArray()
          Returns String[][] representation of state transitions.
 java.util.Map toMap()
          Returns Map representation of state transitions.
static Transitions unmodifiableTransitions(java.lang.String[][] transitions)
          Creates unmodifiable state transitions from String[][].
static Transitions unmodifiableTransitions(Transitions transitions)
          Creates unmodifiable state transitions from given transitions.
 void xprint(XmlPrintWriter out)
          Prints transitions to the PrintWriter as an XML element.

 

Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait

 

Field Detail

modifiable

protected final boolean modifiable

map

protected java.util.Map map

EMPTY_TRANSITIONS

public static final Transitions EMPTY_TRANSITIONS
Empty unmodifiable state transitions.

Constructor Detail

Transitions

public Transitions()
Creates empty modifiable state transitions.

Transitions

public Transitions(boolean modifiable)
Creates empty state transitions.

Transitions

public Transitions(java.lang.String[][] transitions)
Creates modifiable state transitions from String[][].

Transitions

public Transitions(java.lang.String[][] transitions,
                   boolean modifiable)
Creates state transitions from String[][].

Transitions

public Transitions(Transitions transitions)
Creates modifiable state transitions from given transitions.

Transitions

public Transitions(Transitions transitions,
                   boolean modifiable)
Creates state transitions from given transitions.

Method Detail

unmodifiableTransitions

public static Transitions unmodifiableTransitions(java.lang.String[][] transitions)
Creates unmodifiable state transitions from String[][].

unmodifiableTransitions

public static Transitions unmodifiableTransitions(Transitions transitions)
Creates unmodifiable state transitions from given transitions. If the given state transitions are already unmodifiable, it returns the given transitions.

clone

public java.lang.Object clone()
This method clones Transitions. The cloned transitions are modifiable.
Overrides:
clone in class java.lang.Object

equals

public boolean equals(java.lang.Object object)
This method compares transitions with the the specified object for equality. Returns true if the given object is also an instance of transitions and the two transitions contain the same state transitions. The modifiable property of transitions is ignored.
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
This method returns the hash code value for this transitions object.
Overrides:
hashCode in class java.lang.Object

isModifiable

public boolean isModifiable()
Checks if state transitions are modifiable.
Returns:
true if state transitions are modifiable

toArray

public java.lang.String[][] toArray()
Returns String[][] representation of state transitions.

toMap

public java.util.Map toMap()
Returns Map representation of state transitions.

add

public void add(java.lang.String from,
                java.lang.String to)
Adds the given state transition.

add

public void add(java.lang.String[][] transitions)
Adds all given state transitions.

add

public void add(Transitions transitions)
Adds all given state transitions.

remove

public void remove(java.lang.String state)
Removes all state transitions containing the given state.

remove

public void remove(java.lang.String from,
                   java.lang.String to)
Removes the given state transition.

remove

public void remove(java.lang.String[][] transitions)
Removes all given state transitions.

remove

public void remove(Transitions transitions)
Removes all given state transitions.

size

public int size()
Calculates the number of state transitions.
Returns:
the number of transitions

isEmpty

public boolean isEmpty()
Returns true is there are no state transitions.

contains

public boolean contains(java.lang.String state)
Checks if state transitions contain the given state.
Returns:
true if transitions contain the given state

contains

public boolean contains(java.lang.String from,
                        java.lang.String to)
Checks if state transitions contain the given state transition.
Returns:
true if transitions contain the given state transition

isState

public boolean isState(java.lang.String state)
Checks if the state is a valid non-null state.
Returns:
true if the state is a valid non-null state

getStates

public java.util.Set getStates()
Getter for all states.
Returns:
Set containing all states.

isNext

public boolean isNext(java.lang.String current,
                      java.lang.String next)
Checks if the next state can be reached from the current state.
Returns:
true if the next state can be reached from the current state

getNext

public java.util.Set getNext(java.lang.String current)
Getter for next states. Next states are states that can be reached from the current state.
Returns:
Set containing next states

isPrevious

public boolean isPrevious(java.lang.String current,
                          java.lang.String previous)
Checks if the current state can be reached from the previous state.
Returns:
true if the current state can be reached from the previous state

getPrevious

public java.util.Set getPrevious(java.lang.String current)
Getter for previous states. Previous states are states that the current state can be reached from.
Returns:
Set containing previous states

isReachable

public boolean isReachable(java.lang.String state)
Checks if the state is a reachable state. Reachable states can be reached from at least one other state.
Returns:
true if the state can be reached from at least one other state.

getReachable

public java.util.Set getReachable()
Getter for reachable states. Reachable states can be reached from at least one other state.
Returns:
Set of reachable states

isUnreachable

public boolean isUnreachable(java.lang.String state)
Checks if the state is an unreachable state. Unreachable states cannot be reached from any other state.
Returns:
true if the state cannot reached from any other state.

getUnreachable

public java.util.Set getUnreachable()
Getter for unreachable states. Unreachable states cannot be reached from any other state.
Returns:
Set of unreachable states

isInitial

public boolean isInitial(java.lang.String state)
Checks if the state is an initial state. Initial states can be reached from the pre-initial null state.
Returns:
true if the state can be reached form the pre-initial null state

getInitial

public java.util.Set getInitial()
Getter for initial states. Initial states can be reached from the pre-initial null state.
Returns:
Set of initial states

isIntermediate

public boolean isIntermediate(java.lang.String state)
Checks if the state is an intermediate state. Intermediate states can be reached from at least one other state and can be trnasitioned to at least one other state.
Returns:
true if the state can be reached form at least one other state and can be trnasitioned to at least one other state.

getIntermediate

public java.util.Set getIntermediate()
Getter for intermediate states. Intermediate states can be reached from at least one other state and can be trnasitioned to at least one other state.
Returns:
Set of intermediate states

isFinal

public boolean isFinal(java.lang.String state)
Checks if the state is a final state. Final states cannot be transitioned to any other state.
Returns:
true if the state cannot be transitioned to any other state.

getFinal

public java.util.Set getFinal()
Getter for final states. Final states cannot be transitioned to any other state.
Returns:
Set of final states

xprint

public void xprint(XmlPrintWriter out)
Prints transitions to the PrintWriter as an XML element.
Specified by:
xprint in interface XmlPrintable
Parameters:
out - PrintWriter for printing stateInfo propeties.

Skip navigation links