tom.library.sl
Class AbstractStrategy

java.lang.Object
  extended by tom.library.sl.AbstractStrategy
All Implemented Interfaces:
Strategy, Visitable
Direct Known Subclasses:
All, AllSeq, Choice, ChoiceId, DeRef, Fail, Identity, IfThenElse, Mu, MuVar, Not, Omega, OmegaU, One, OneId, Pselect, Sequence, SequenceId, StrategyFwd

public abstract class AbstractStrategy
extends java.lang.Object
implements Strategy

A visitor that it iself visitable with a VisitorVisitor needs to implement the MuStrategy interface. The visitor's arguments should play the role of children.


Field Summary
protected  Environment environment
           
protected  Strategy[] visitors
           
 
Constructor Summary
AbstractStrategy()
           
 
Method Summary
 Strategy accept(StrategyFwd v)
           
 Visitable getChildAt(int i)
           
 int getChildCount()
           
 Visitable[] getChildren()
          Returns the list of (non builtin) Visitable children
 Environment getEnvironment()
          Get a reference to the current environment.
 Visitable getRoot()
           
 Visitable getSubject()
           
 void init()
           
static void init(Strategy s, Environment env)
           
protected  void initSubterm()
           
protected  void initSubterm(Strategy v1)
           
protected  void initSubterm(Strategy[] v)
           
protected  void initSubterm(Strategy v1, Strategy v2)
           
protected  void initSubterm(Strategy v1, Strategy v2, Strategy v3)
           
 Visitable setChildAt(int i, Visitable child)
           
 Visitable setChildren(Visitable[] children)
          Replaces all children of any visitable at once, and returns this visitable.
 void setEnvironment(Environment env)
          Set up a new environment
 void setRoot(Visitable any)
           
 void setSubject(Visitable any)
           
 Visitable visit(Environment envt)
          execute the strategy in the given environment (on its current subject).
 Visitable visit(Visitable any)
          Visits the subject any by providing the environment
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface tom.library.sl.Strategy
visit, visitLight
 

Field Detail

visitors

protected Strategy[] visitors

environment

protected Environment environment
Constructor Detail

AbstractStrategy

public AbstractStrategy()
Method Detail

initSubterm

protected void initSubterm()

initSubterm

protected void initSubterm(Strategy v1)

initSubterm

protected void initSubterm(Strategy v1,
                           Strategy v2)

initSubterm

protected void initSubterm(Strategy v1,
                           Strategy v2,
                           Strategy v3)

initSubterm

protected void initSubterm(Strategy[] v)

getChildCount

public int getChildCount()
Specified by:
getChildCount in interface Visitable

getChildAt

public Visitable getChildAt(int i)
Specified by:
getChildAt in interface Visitable

getChildren

public Visitable[] getChildren()
Description copied from interface: Visitable
Returns the list of (non builtin) Visitable children

Specified by:
getChildren in interface Visitable

setChildAt

public Visitable setChildAt(int i,
                            Visitable child)
Specified by:
setChildAt in interface Visitable

setChildren

public Visitable setChildren(Visitable[] children)
Description copied from interface: Visitable
Replaces all children of any visitable at once, and returns this visitable.

Specified by:
setChildren in interface Visitable

accept

public Strategy accept(StrategyFwd v)
                throws VisitFailure
Specified by:
accept in interface Strategy
Throws:
VisitFailure

visit

public Visitable visit(Environment envt)
                throws VisitFailure
Description copied from interface: Strategy
execute the strategy in the given environment (on its current subject). This method can only be used inside user strategies to execute another strategy but with the current environment of the user strategy.

Specified by:
visit in interface Strategy
Parameters:
envt - the environment where execute the strategy.
Throws:
VisitFailure

visit

public Visitable visit(Visitable any)
                throws VisitFailure
Description copied from interface: Strategy
Visits the subject any by providing the environment

Specified by:
visit in interface Strategy
Parameters:
any - the subject to visit.
Throws:
VisitFailure - in case of failure.

getEnvironment

public Environment getEnvironment()
Description copied from interface: Strategy
Get a reference to the current environment.

Specified by:
getEnvironment in interface Strategy
Returns:
the current environment

setEnvironment

public void setEnvironment(Environment env)
Description copied from interface: Strategy
Set up a new environment

Specified by:
setEnvironment in interface Strategy

getRoot

public Visitable getRoot()

setRoot

public void setRoot(Visitable any)

getSubject

public Visitable getSubject()

setSubject

public void setSubject(Visitable any)

init

public void init()

init

public static void init(Strategy s,
                        Environment env)