org.jscience.computing.ai.planning
Class TaskList

java.lang.Object
  extended by org.jscience.computing.ai.planning.CompileTimeObject
      extended by org.jscience.computing.ai.planning.TaskList

public class TaskList
extends CompileTimeObject

Each task list, both at compile time and at run time, is an instance of this class.


Field Summary
static TaskList empty
          This variable represents an empty task list.
 TaskList[] subtasks
          In case this task list is not-atomic, this array represents it.
 
Constructor Summary
TaskList(int size, boolean orderedIn)
          To initialize this task list as a non-atomic one.
TaskList(TaskAtom taskIn)
          To initialize this task list as an atomic one.
 
Method Summary
 TaskList bind(Term[] binding)
          To bind a task list to a given binding.
static TaskList createTaskList(java.util.Vector subtasksIn, boolean orderedIn)
          To create a non-atomic task list.
 java.util.LinkedList getFirst()
          To return a LinkedList of the task atoms we have the option to achieve right now.
 java.lang.String getInitCode(java.lang.String what)
          This function produces Java code used to create this task list either as an atomic task list or recursively, as a list of other task lists.
 TaskAtom getTask()
          To return the task atom associated with this task list.
 boolean isEmpty()
          Whether or not this task list is, or has become as result of task decomposition, an empty one.
 void print()
          This function is used to print this task list.
 void replace(TaskList tasksIn)
          This function replaces (i.e., decomposes) a given task atom with a task list.
 void setVarCount(int varCountIn)
          This function sets the number of variables for this task list.
 java.lang.String toCode()
          This function produces Java code to create this task list.
 java.lang.String toString()
          This function returns a printable String representation of this task list.
 void undo()
          This function undoes the decomposition of a task atom to a task list in case of a backtrack over the decision to decompose the task.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

empty

public static TaskList empty
This variable represents an empty task list. All over the code, whenever any object needs an empty task list, it will use this variable rather than create a new empty task list to save memory because functionally all the empty task lists are the same.


subtasks

public TaskList[] subtasks
In case this task list is not-atomic, this array represents it. Otherwise, this variable will be null.

Constructor Detail

TaskList

public TaskList(TaskAtom taskIn)
To initialize this task list as an atomic one.

Parameters:
taskIn - the task atom this task list will represent.

TaskList

public TaskList(int size,
                boolean orderedIn)
To initialize this task list as a non-atomic one.

Parameters:
size - the number of task lists in the task list this object represents.
orderedIn - whether or not this task list is ordered.
Method Detail

bind

public TaskList bind(Term[] binding)
To bind a task list to a given binding.

Parameters:
binding - the given binding
Returns:
the resulting task list.

createTaskList

public static TaskList createTaskList(java.util.Vector subtasksIn,
                                      boolean orderedIn)
To create a non-atomic task list. This is defined as a static function rather than a constructor because it returns TaskList.empty if the required task list is of length 0 rather than creating a new empty task list. Other than that, this function acts like a constructor.

Parameters:
subtasksIn - a Vector of subtasks the output task list will represent.
orderedIn - whether or not the output task list should be ordered.
Returns:
the resulting task list.

getFirst

public java.util.LinkedList getFirst()
To return a LinkedList of the task atoms we have the option to achieve right now. This list might have more than one member because of the existence of unordered task lists.

Returns:
a LinkedList of the task atoms we have the option to achieve right now.

getInitCode

public java.lang.String getInitCode(java.lang.String what)
This function produces Java code used to create this task list either as an atomic task list or recursively, as a list of other task lists.

Parameters:
what - the String name of the task list created by this piece of code.
Returns:
the Java code as a String.

getTask

public TaskAtom getTask()
To return the task atom associated with this task list.

Returns:
the task atom associated with this task list in case this is an atomic task list, null otherwise.

isEmpty

public boolean isEmpty()
Whether or not this task list is, or has become as result of task decomposition, an empty one.

Returns:
true if this task list is equivalent to an empty task list, false otherwise.

print

public void print()
This function is used to print this task list.


replace

public void replace(TaskList tasksIn)
This function replaces (i.e., decomposes) a given task atom with a task list.

Parameters:
tasksIn - the decomposition to replace the task atom.

setVarCount

public void setVarCount(int varCountIn)
This function sets the number of variables for this task list. This number is used to return bindings of the appropriate size.

Parameters:
varCountIn - the number of variables for this task list.

toCode

public java.lang.String toCode()
This function produces Java code to create this task list.

Specified by:
toCode in class CompileTimeObject
Returns:
DOCUMENT ME!

toString

public java.lang.String toString()
This function returns a printable String representation of this task list.

Overrides:
toString in class java.lang.Object
Returns:
the String representation.

undo

public void undo()
This function undoes the decomposition of a task atom to a task list in case of a backtrack over the decision to decompose the task.