tom.library.sl
Class Environment

java.lang.Object
  extended by tom.library.sl.Environment
All Implemented Interfaces:
Cloneable

public final class Environment
extends Object
implements Cloneable

Object that represents an environment of a strategy the position where the strategy is applied a pointer to subterm the root is stored in the first cell


Field Summary
protected  int current
           
static int FAILURE
           
static int IDENTITY
           
protected  Introspector introspector
           
protected  int[] omega
           
protected  int status
           
protected  Object[] subterm
           
static int SUCCESS
           
 
Constructor Summary
Environment()
           
Environment(Introspector introspector)
           
 
Method Summary
 Object clone()
           
 int depth()
          Get the depth of the position in the tree
 void down(int n)
          add a sub-position n
 boolean equals(Object o)
          Tests if two environments are equals
 void followPath(Path path)
           
 void followPathLocal(Path path)
           
 Object getAncestor()
          get the term that corresponds to the ancestor of current position
 List<Object> getCurrentStack()
          get the current stack
 Introspector getIntrospector()
           
 Position getPosition()
          get the current position
 Object getRoot()
          get the current root
 int getStatus()
           
 Object getSubject()
          get the term that corresponds to the current position
 int getSubOmega()
          get the current sub-position
 void goToPosition(Position p)
           
 int hashCode()
           
 void setIntrospector(Introspector i)
           
 void setRoot(Object root)
          set the current root
 void setStatus(int s)
           
 void setSubject(Object root)
          set the current term
 String toString()
          Returns a String object representing the position.
 void up()
          remove the last sub-position Up and down are made public to allow to write compiled strategies by hand This may be a BAD idea
 void upLocal()
          package private remove the last sub-position but does not update the subject
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

SUCCESS

public static final int SUCCESS
See Also:
Constant Field Values

FAILURE

public static final int FAILURE
See Also:
Constant Field Values

IDENTITY

public static final int IDENTITY
See Also:
Constant Field Values

current

protected int current

omega

protected int[] omega

subterm

protected Object[] subterm

introspector

protected Introspector introspector

status

protected int status
Constructor Detail

Environment

public Environment()

Environment

public Environment(Introspector introspector)
Method Detail

clone

public Object clone()
             throws CloneNotSupportedException
Overrides:
clone in class Object
Throws:
CloneNotSupportedException

equals

public boolean equals(Object o)
Tests if two environments are equals

Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

getStatus

public int getStatus()

setStatus

public void setStatus(int s)

getRoot

public Object getRoot()
get the current root

Returns:
the current root

setRoot

public void setRoot(Object root)
set the current root


getCurrentStack

public List<Object> getCurrentStack()
get the current stack


getAncestor

public Object getAncestor()
get the term that corresponds to the ancestor of current position

Returns:
the ancestor of the current term

getSubject

public Object getSubject()
get the term that corresponds to the current position

Returns:
the current term

setSubject

public void setSubject(Object root)
set the current term


getIntrospector

public Introspector getIntrospector()

setIntrospector

public void setIntrospector(Introspector i)

getSubOmega

public int getSubOmega()
get the current sub-position

Returns:
the current sub-position

getPosition

public Position getPosition()
get the current position

Returns:
the current position

depth

public int depth()
Get the depth of the position in the tree

Returns:
depth on the position

up

public void up()
remove the last sub-position Up and down are made public to allow to write compiled strategies by hand This may be a BAD idea


upLocal

public void upLocal()
package private remove the last sub-position but does not update the subject


down

public void down(int n)
add a sub-position n

Parameters:
n - sub-position number. 1 is the first possible sub-position

goToPosition

public void goToPosition(Position p)

followPath

public void followPath(Path path)

followPathLocal

public void followPathLocal(Path path)

toString

public String toString()
Returns a String object representing the position. The string representation consists of a list of elementary positions

Overrides:
toString in class Object
Returns:
a string representation of this position