org.eclipse.emf.henshin.statespace.impl
Class StateSpaceIndexImpl

java.lang.Object
  extended by org.eclipse.emf.henshin.statespace.impl.StateSpaceIndexImpl
All Implemented Interfaces:
StateSpaceIndex
Direct Known Subclasses:
BasicStateSpaceManager

public class StateSpaceIndexImpl
extends Object
implements StateSpaceIndex

Default implementation of StateSpaceIndex.


Constructor Summary
StateSpaceIndexImpl(StateSpace stateSpace)
          Default constructor.
 
Method Summary
protected  void addToCache(State state, Model model)
           
 void addToIndex(State state)
          Add a state to the index.
 void clearCache()
          Clear all caches of the state space index.
protected  Model deriveModel(State state, boolean fromInitial)
           
 Model getCachedModel(State state)
          Get the cached model that corresponds to a state.
 Model getModel(State state)
          Get the model that corresponds to a state.
 State getState(Model model)
          Get the state that corresponds to the argument model.
protected  State getState(Model model, int hash)
          Get the state for a given model and its hash code.
 StateSpace getStateSpace()
          Get the indexed state space.
 void removeFromIndex(State state)
          Remove a state from the index.
 void resetIndex()
          Reset this state space index.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StateSpaceIndexImpl

public StateSpaceIndexImpl(StateSpace stateSpace)
Default constructor. This fills the state index.

Method Detail

getModel

public Model getModel(State state)
               throws StateSpaceException
Description copied from interface: StateSpaceIndex
Get the model that corresponds to a state. The model is either cached or will be derived on-the-fly.

Specified by:
getModel in interface StateSpaceIndex
Parameters:
state - State in the state space.
Returns:
The corresponding model.
Throws:
StateSpaceException - If the state space contains errors.

getCachedModel

public Model getCachedModel(State state)
Description copied from interface: StateSpaceIndex
Get the cached model that corresponds to a state.

Specified by:
getCachedModel in interface StateSpaceIndex
Parameters:
state - State in the state space.
Returns:
The corresponding model or NullPointerException if the model is not cached.

addToCache

protected void addToCache(State state,
                          Model model)
                   throws StateSpaceException
Throws:
StateSpaceException

deriveModel

protected Model deriveModel(State state,
                            boolean fromInitial)
                     throws StateSpaceException
Throws:
StateSpaceException

getState

public final State getState(Model model)
                     throws StateSpaceException
Description copied from interface: StateSpaceIndex
Get the state that corresponds to the argument model.

Specified by:
getState in interface StateSpaceIndex
Parameters:
model - State model.
Returns:
The corresponding state or null if none was found.
Throws:
StateSpaceException - If the state space contains errors.

getState

protected State getState(Model model,
                         int hash)
                  throws StateSpaceException
Get the state for a given model and its hash code.

Parameters:
model - State model.
hash - Its hash code.
Returns:
The corresponding state if it exists.
Throws:
StateSpaceException

addToIndex

public void addToIndex(State state)
Add a state to the index.

Parameters:
state - State to be added.

removeFromIndex

public void removeFromIndex(State state)
Remove a state from the index.

Parameters:
state - State to be removed.

resetIndex

public void resetIndex()
Reset this state space index.


getStateSpace

public StateSpace getStateSpace()
Description copied from interface: StateSpaceIndex
Get the indexed state space.

Specified by:
getStateSpace in interface StateSpaceIndex
Returns:
The state space.

clearCache

public void clearCache()
Description copied from interface: StateSpaceIndex
Clear all caches of the state space index.

Specified by:
clearCache in interface StateSpaceIndex