lij.model
Class TreeNode

java.lang.Object
  extended by lij.model.TreeNode

public class TreeNode
extends java.lang.Object

This class is used to construct clause trees. Each node in the tree contains a Token (the "contents" of the node), as well as two children nodes (left and right).

Author:
Nikolaos Chatzinikolaou

Field Summary
private  Result.State evaluationResult
           
private  TreeNode left
           
private  TreeNode right
           
private  TreeNodeToken token
           
 
Constructor Summary
TreeNode(TreeNodeToken _token)
          Constructor.
 
Method Summary
 java.lang.Object clone()
           
private  void evaluate(Interpreter interpreter, AgentInstance agentInstance)
          Performs the evaluation of this node (and its children, recursively)
 Result.State getEvaluationResult(Interpreter interpreter, AgentInstance agentInstance)
          Returns the evaluation result of this node.
 TreeNode getLeft()
          Accessor.
 TreeNode getRight()
          Accessor.
 TreeNodeToken getToken()
          Accessor.
 void resetEvaluationResult()
          Resets the state of the evaluation result of this node and all of its children to MAYBE.
 void setLeft(TreeNode _left)
          Accessor.
 void setRight(TreeNode _right)
          Accessor.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

token

private TreeNodeToken token

left

private TreeNode left

right

private TreeNode right

evaluationResult

private Result.State evaluationResult
Constructor Detail

TreeNode

public TreeNode(TreeNodeToken _token)
Constructor.

Parameters:
_token - The token object contained in this node.
Method Detail

getToken

public TreeNodeToken getToken()
Accessor.

Returns:
The node's token object.

setLeft

public void setLeft(TreeNode _left)
Accessor.

Parameters:
_left - The node at the left branch of the tree.

getLeft

public TreeNode getLeft()
Accessor.

Returns:
The node at the left branch of the tree.

setRight

public void setRight(TreeNode _right)
Accessor.

Parameters:
_right - The node at the right branch of the tree.

getRight

public TreeNode getRight()
Accessor.

Returns:
The node at the right branch of the tree.

resetEvaluationResult

public void resetEvaluationResult()
Resets the state of the evaluation result of this node and all of its children to MAYBE.


getEvaluationResult

public Result.State getEvaluationResult(Interpreter interpreter,
                                        AgentInstance agentInstance)
                                 throws InterpreterException
Returns the evaluation result of this node. If the state of this result is not yet determined (i.e. it is MAYBE), the node (and its children) will first get (re-)evaluated.

Parameters:
interpreter - A reference to the current Interpreter instance.
agentInstance - A reference to the current agent instance.
Returns:
The evaluation result of this node.
Throws:
InterpreterException

evaluate

private void evaluate(Interpreter interpreter,
                      AgentInstance agentInstance)
               throws InterpreterException
Performs the evaluation of this node (and its children, recursively)

Parameters:
interpreter - A reference to the current Interpreter instance.
agentInstance - A reference to the current agent instance.
Throws:
InterpreterException

clone

public java.lang.Object clone()
Overrides:
clone in class java.lang.Object

toString

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