lij.runtime
Class ClauseInstance

java.lang.Object
  extended by lij.runtime.ClauseInstance

public class ClauseInstance
extends java.lang.Object

A ClauseInstance instance is a runtime instance of a Clause definition. It contains the clause definition that is being executed, as well as a SymbolTable instance for storing any variables pertaining to that clause instance. It's main purpose is to decouple the execution code from the model.Clause class

Author:
Nikolaos Chatzinikolaou

Field Summary
private  Clause clause
           
private  java.io.Serializable id
           
private  Interpreter interpreter
           
private  SymbolTable symbolTable
           
 
Constructor Summary
ClauseInstance(java.io.Serializable _id, Clause _clause, Interpreter _interpreter)
          Constructor.
 
Method Summary
 java.io.Serializable getID()
          Accessor.
 java.lang.String getKind()
          Returns the kind of the current role of this AgentInstance.
 TreeNode getRoot()
          Convenience method for accessing the root node of the Clause encapsulated in this ClauseInstance.
 SymbolTable getSymbolTable()
          Accessor.
 Term getType()
          Accessor.
 java.io.Serializable getValueForArgument(Argument argument)
          Convenience method for retrieving the value associated with a variable or constant.
 void storeVariable(ArgumentVariable variable, java.io.Serializable value)
          Convenience method for storing a variable and its associated value into the SymbolTable of this ClauseInstance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

id

private java.io.Serializable id

clause

private Clause clause

symbolTable

private SymbolTable symbolTable

interpreter

private Interpreter interpreter
Constructor Detail

ClauseInstance

public ClauseInstance(java.io.Serializable _id,
                      Clause _clause,
                      Interpreter _interpreter)
Constructor.

Parameters:
_id - The ID of the agent executing this ClauseInstance.
_clause - The Clause encapsulated in this ClauseInstance.
_interpreter - A reference to the currently running Interpreter instance.
Method Detail

getID

public java.io.Serializable getID()
Accessor.

Returns:
The ID of the agent executing this ClauseInstance.

getType

public Term getType()
Accessor.

Returns:
The Clause encapsulated in this ClauseInstance.

getKind

public java.lang.String getKind()
Returns the kind of the current role of this AgentInstance.

Returns:
The current role of the agent.

getRoot

public TreeNode getRoot()
Convenience method for accessing the root node of the Clause encapsulated in this ClauseInstance.

Returns:
The root node of the Clause encapsulated in this ClauseInstance.

getSymbolTable

public SymbolTable getSymbolTable()
Accessor.

Returns:
The SymbolTable of this ClauseInstance.

storeVariable

public void storeVariable(ArgumentVariable variable,
                          java.io.Serializable value)
Convenience method for storing a variable and its associated value into the SymbolTable of this ClauseInstance.

Parameters:
variable - The variable to store.
value - The value associated with the variable.

getValueForArgument

public java.io.Serializable getValueForArgument(Argument argument)
                                         throws InterpreterException
Convenience method for retrieving the value associated with a variable or constant.

Parameters:
argument - The Argument whose value will be returned. This can be an ArgumentVariable (in which case the value will be retrieved from the SymbolTable), or an ArgumentConstant (in which case the value returned will be the constant value represented by the ArgumentConstant).
Returns:
The value represented by the specified Argument.
Throws:
InterpreterException