The Meta-Environment API

toolbus.process
Class RightBiasedAlternative

java.lang.Object
  extended by toolbus.process.ProcessExpression
      extended by toolbus.process.RightBiasedAlternative
All Implemented Interfaces:
StateElement

public class RightBiasedAlternative
extends ProcessExpression
implements StateElement

Author:
paulk, May 30, 2007 RightBiasedAlternative implements the the asymmetric choice operator operator +>. It is similar to + but prefers its right argument.

Field Summary
private  ProcessExpression[] expr
           
private  int LEFT
           
private  State mergeState
           
private  ProcessInstance processInstance
           
private  int RIGHT
           
private  boolean rightLast
           
private  State[] state
           
 
Fields inherited from class toolbus.process.ProcessExpression
posInfo, tbfactory
 
Constructor Summary
RightBiasedAlternative(ProcessExpression left, ProcessExpression right, TBTermFactory tbfactory, PositionInformation posInfo)
           
 
Method Summary
 void activate()
          Activate the StateElement, i.e.
protected  void compile(ProcessInstance processInstance, java.util.Stack<java.lang.String> calls, State follows)
           
protected  void computeFirst()
           
 boolean contains(StateElement a)
          Check whether a StateElement contains another StateElement.
protected  ProcessExpression copy()
           
 ProcessInstance[] debugExecute()
          Executes the state element in debug mode.
 boolean execute()
          Execute this StateElement
 AtomList getAtoms()
           
 State getFirst()
           
 ProcessInstance getProcess()
           
 java.util.List<aterm.ATerm> getTests()
          Returns a collection containing all tests that are associated with this state element.
 State gotoNextStateAndActivate()
           
 State gotoNextStateAndActivate(StateElement se)
          Get the successor of the StateElement for a given other StateElement elem.
 boolean isEnabled()
          Is this StateElelement enabled for execution, i.e., are its associated tests all true? If enabled, the StateElement is ready for execution.
protected  void replaceFormals(Environment env)
           
 void setTest(aterm.ATerm test, Environment env)
          Add a test to this state element.
 java.lang.String toString()
           
 
Methods inherited from class toolbus.process.ProcessExpression
addToFirst, addToFollow, getFollow, getPosInfo, setFirst, setFollow
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface toolbus.StateElement
getFollow, getPosInfo
 

Field Detail

LEFT

private final int LEFT
See Also:
Constant Field Values

RIGHT

private final int RIGHT
See Also:
Constant Field Values

processInstance

private ProcessInstance processInstance

expr

private final ProcessExpression[] expr

state

private final State[] state

mergeState

private final State mergeState

rightLast

private boolean rightLast
Constructor Detail

RightBiasedAlternative

public RightBiasedAlternative(ProcessExpression left,
                              ProcessExpression right,
                              TBTermFactory tbfactory,
                              PositionInformation posInfo)
Method Detail

computeFirst

protected void computeFirst()
Specified by:
computeFirst in class ProcessExpression

compile

protected void compile(ProcessInstance processInstance,
                       java.util.Stack<java.lang.String> calls,
                       State follows)
                throws ToolBusException
Specified by:
compile in class ProcessExpression
Throws:
ToolBusException

replaceFormals

protected void replaceFormals(Environment env)
                       throws ToolBusException
Specified by:
replaceFormals in class ProcessExpression
Throws:
ToolBusException

copy

protected ProcessExpression copy()
Specified by:
copy in class ProcessExpression

getAtoms

public AtomList getAtoms()
Specified by:
getAtoms in class ProcessExpression

getFirst

public State getFirst()
Overrides:
getFirst in class ProcessExpression

contains

public boolean contains(StateElement a)
Description copied from interface: StateElement
Check whether a StateElement contains another StateElement. In the simplest case of Atom this is just an identity test. In composite cases (e.g. Merge), it requires a recursive search.

Specified by:
contains in interface StateElement
Parameters:
a - the StateElement
Returns:
true (contained in) or false (not contained in)

getProcess

public ProcessInstance getProcess()
Specified by:
getProcess in interface StateElement
Returns:
the ProcessInstance to which the StateElement belongs

setTest

public void setTest(aterm.ATerm test,
                    Environment env)
             throws ToolBusException
Description copied from interface: StateElement
Add a test to this state element. Tests implement conditionals but not delays / timeouts.

Specified by:
setTest in interface StateElement
env - to be used for executing the test
Throws:
ToolBusException

getTests

public java.util.List<aterm.ATerm> getTests()
Description copied from interface: StateElement
Returns a collection containing all tests that are associated with this state element.

Specified by:
getTests in interface StateElement
Returns:
A collection containing all tests that are associated with this state element.

isEnabled

public boolean isEnabled()
Description copied from interface: StateElement
Is this StateElelement enabled for execution, i.e., are its associated tests all true? If enabled, the StateElement is ready for execution.

Specified by:
isEnabled in interface StateElement
Returns:
true (enabled) or false (not enabled).

gotoNextStateAndActivate

public State gotoNextStateAndActivate()
Specified by:
gotoNextStateAndActivate in interface StateElement
Returns:
the successor State of the StateElement

gotoNextStateAndActivate

public State gotoNextStateAndActivate(StateElement se)
Description copied from interface: StateElement
Get the successor of the StateElement for a given other StateElement elem. This typically used for a composite StateElement to get a specific successor. TODO: Probably this method should be combined with the previous one.

Specified by:
gotoNextStateAndActivate in interface StateElement
Returns:
the successor State of the StateElement

activate

public void activate()
Description copied from interface: StateElement
Activate the StateElement, i.e. make it ready for execution. This may involve initialization and the setting of timers.

Specified by:
activate in interface StateElement

execute

public boolean execute()
                throws ToolBusException
Description copied from interface: StateElement
Execute this StateElement

Specified by:
execute in interface StateElement
Returns:
true if execution was completed.
Throws:
ToolBusException

debugExecute

public ProcessInstance[] debugExecute()
                               throws ToolBusException
Description copied from interface: StateElement
Executes the state element in debug mode.

Specified by:
debugExecute in interface StateElement
Returns:
The collection of partners that cooperated with the execution of the state element. Null if the execution did not complete.
Throws:
ToolBusException

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

The Meta-Environment API