com::declarativa::interprolog::TermModel Class Reference


Public Member Functions

Object clone ()
boolean equals (Object x)
void setNodeValue (Object v)
void setChild (int index, TermModel child)
void setChildren (TermModel[] c)
TermModel[] getChildren ()
void addChildren (TermModel[] more)
void deleteChildren (int[] less)
void deleteChildren (TermModel[] less)
void assignToVar (VariableNode v, Object value)
void setRoot ()
void setRoot (TermModel r)
boolean isRoot ()
String getTemplate ()
String getFunctorArity ()
Object getRoot ()
Object getChild (Object parent, int index)
int getChildCount (Object parent)
boolean isLeaf (Object node)
void valueForPathChanged (TreePath path, Object newValue)
int getIndexOfChild (Object parent, Object child)
void addTreeModelListener (TreeModelListener l)
void removeTreeModelListener (TreeModelListener l)
Object getChild (int index)
int getChildCount ()
boolean isLeaf ()
void addTermModelListener (TermModelListener l)
void removeTermModelListener (TermModelListener l)
void fireTermChanged ()
 TermModel ()
 TermModel (Object n)
 TermModel (Object n, TermModel[] c)
 TermModel (Object n, Vector v)
Vector makeIntegerVector ()
int intValue ()
String toString ()
String toString (PrologOperatorsContext ops)
String listToString (PrologOperatorsContext ops)
boolean isListEnd ()
boolean isList ()
boolean isAtom ()
boolean isNumber ()
boolean isInteger ()
boolean isVar ()
boolean nodeIsVar ()
TermModel[] flatList ()

Static Public Member Functions

static ObjectExamplePair example ()
static TreePath findPathForNode (String label, TermModel tree, boolean exactMatch)
static TermModel makeList (TermModel[] terms)
static TermModel makeList (Vector terms)
static TermModel[] flatList (TermModel list)
static Hashtable props2Hashtable (TermModel[] terms)

Data Fields

Object node
TermModel[] children
transient TermModel root

Static Public Attributes

static final int listMaxLength = 100

Protected Member Functions

void propagateRoot ()

Static Protected Member Functions

static TermModel makeList (int t, TermModel[] terms)
static TermModel makeList (int t, Vector terms)

Static Package Functions

static boolean inArray (int x, int[] a)
static boolean inArray (Object x, Object[] a)
static boolean foundPathForNode (String label, TermModel tree, boolean exactMatch, Vector bag)
static void flatList (TermModel x, Vector bag)

Static Package Attributes

static PrologOperatorsContext defaultOperatorContext = new PrologOperatorsContext()

Detailed Description

Represents a Prolog term, as a tree of TermModel objects, each containing a term node and a children list. Implements TreeModel, therefore easily supporting display in a JTree. It includes the funcionality of Prolog's Edinburgh syntax write within toString(); if you wish to reflect operator declarations dynamically you should provide a different PrologOperatorsContext object

Definition at line 20 of file TermModel.java.


Member Function Documentation

void com::declarativa::interprolog::TermModel::addChildren TermModel[]  more  )  [inline]
 

Add children to this term node; a new children array is created and old children are copied to it

Definition at line 101 of file TermModel.java.

References children, getChildCount(), and setChildren().

void com::declarativa::interprolog::TermModel::addTermModelListener TermModelListener  l  )  [inline]
 

Start notifying listener l of changes to this term. The term is considered changed iff either a node or children is set to a different object; a nonreported change is the setting of a same object as node/children, not the setting of an "equals" object

Definition at line 252 of file TermModel.java.

References isRoot().

void com::declarativa::interprolog::TermModel::addTreeModelListener TreeModelListener  l  )  [inline]
 

See also:
javax.swing.tree.TreeModel

Definition at line 228 of file TermModel.java.

void com::declarativa::interprolog::TermModel::assignToVar VariableNode  v,
Object  value
[inline]
 

Replaces all occurrences of v in this subterm by value, using setNodeValue

Definition at line 150 of file TermModel.java.

References node, and setNodeValue().

Object com::declarativa::interprolog::TermModel::clone  )  [inline]
 

Clones by serialization, to keep variable bindings; these should form a closed graph within this term, otherwise the new term instance would contain dangling references

Definition at line 43 of file TermModel.java.

void com::declarativa::interprolog::TermModel::deleteChildren TermModel[]  less  )  [inline]
 

Removes the children in array; it finds children to remove by using the equivalent of Prolog's ==

Definition at line 125 of file TermModel.java.

References children, getChildCount(), inArray(), and setChildren().

void com::declarativa::interprolog::TermModel::deleteChildren int[]  less  )  [inline]
 

Delete children with specified indexes; a new children array is created and old children are copied to it

Definition at line 112 of file TermModel.java.

References children, getChildCount(), inArray(), and setChildren().

boolean com::declarativa::interprolog::TermModel::equals Object  x  )  [inline]
 

True if both terms are structurally similar with equal nodes

Definition at line 59 of file TermModel.java.

References getChild(), getChildCount(), and node.

Referenced by isList().

static TermModel [] com::declarativa::interprolog::TermModel::flatList TermModel  list  )  [inline, static]
 

Flattens a list into a TermModel array, but not completely: the result may still contain lists

Definition at line 449 of file TermModel.java.

TermModel [] com::declarativa::interprolog::TermModel::flatList  )  [inline]
 

Flattens this list into a new TermModel array, but not completely: the result may still contain lists

Definition at line 443 of file TermModel.java.

Object com::declarativa::interprolog::TermModel::getChild Object  parent,
int  index
[inline]
 

See also:
javax.swing.tree.TreeModel

Definition at line 202 of file TermModel.java.

Referenced by equals(), foundPathForNode(), and getChild().

int com::declarativa::interprolog::TermModel::getChildCount Object  parent  )  [inline]
 

See also:
javax.swing.tree.TreeModel

Definition at line 206 of file TermModel.java.

Referenced by equals(), foundPathForNode(), com::declarativa::interprolog::gui::PredicateTableModel::PredicateTableModel(), and props2Hashtable().

String com::declarativa::interprolog::TermModel::getFunctorArity  )  [inline]
 

Return a node/arity String

Definition at line 191 of file TermModel.java.

References getChildCount(), and node.

int com::declarativa::interprolog::TermModel::getIndexOfChild Object  parent,
Object  child
[inline]
 

See also:
javax.swing.tree.TreeModel

Definition at line 220 of file TermModel.java.

Object com::declarativa::interprolog::TermModel::getRoot  )  [inline]
 

See also:
javax.swing.tree.TreeModel

Definition at line 198 of file TermModel.java.

String com::declarativa::interprolog::TermModel::getTemplate  )  [inline]
 

Return a Node(_,..._) String

Definition at line 179 of file TermModel.java.

References getChildCount(), and node.

int com::declarativa::interprolog::TermModel::intValue  )  [inline]
 

Returns node object as an int, assuming it is a Number

Definition at line 356 of file TermModel.java.

boolean com::declarativa::interprolog::TermModel::isLeaf Object  node  )  [inline]
 

See also:
javax.swing.tree.TreeModel

Definition at line 212 of file TermModel.java.

References getChildCount().

Referenced by props2Hashtable().

boolean com::declarativa::interprolog::TermModel::isRoot  )  [inline]
 

This node is its own root

Definition at line 171 of file TermModel.java.

References root.

Referenced by addTermModelListener(), and fireTermChanged().

Vector com::declarativa::interprolog::TermModel::makeIntegerVector  )  [inline]
 

Assuming this is a list of numbers, returns a Vector containing one Integer for each number in the list

Definition at line 347 of file TermModel.java.

void com::declarativa::interprolog::TermModel::removeTreeModelListener TreeModelListener  l  )  [inline]
 

See also:
javax.swing.tree.TreeModel

Definition at line 233 of file TermModel.java.

void com::declarativa::interprolog::TermModel::setChild int  index,
TermModel  child
[inline]
 

Set the child, notifying TermModelListeners

Definition at line 83 of file TermModel.java.

References children, and fireTermChanged().

void com::declarativa::interprolog::TermModel::setChildren TermModel[]  c  )  [inline]
 

Set the children array, notifying TermModelListeners

Definition at line 90 of file TermModel.java.

References children, and fireTermChanged().

Referenced by addChildren(), and deleteChildren().

void com::declarativa::interprolog::TermModel::setNodeValue Object  v  )  [inline]
 

Set the node, notifying TermModelListeners

Definition at line 70 of file TermModel.java.

References fireTermChanged(), and node.

Referenced by assignToVar().

void com::declarativa::interprolog::TermModel::setRoot TermModel  r  )  [inline]
 

Set the root variables of nodes in this subterm to refer r as their root

Definition at line 164 of file TermModel.java.

References propagateRoot(), and root.

void com::declarativa::interprolog::TermModel::setRoot  )  [inline]
 

Set the root variables of nodes in this subterm to refer this term node as their root

Definition at line 159 of file TermModel.java.

Referenced by propagateRoot().

void com::declarativa::interprolog::TermModel::valueForPathChanged TreePath  path,
Object  newValue
[inline]
 

See also:
javax.swing.tree.TreeModel

Definition at line 216 of file TermModel.java.


Field Documentation

TermModel [] com::declarativa::interprolog::TermModel::children
 

public for convenience, but should not be set outside this class; children == null means children == new TermModel[0]

Definition at line 25 of file TermModel.java.

Referenced by addChildren(), deleteChildren(), getChildren(), com::declarativa::interprolog::gui::PredicateTableModel::getValueAt(), listToString(), propagateRoot(), props2Hashtable(), setChild(), and setChildren().

Object com::declarativa::interprolog::TermModel::node
 

public for convenience, but should not be set outside this class

Definition at line 22 of file TermModel.java.

Referenced by assignToVar(), equals(), foundPathForNode(), getFunctorArity(), getTemplate(), com::declarativa::interprolog::gui::TermTreeCellRenderer::getTreeCellRendererComponent(), com::declarativa::interprolog::gui::PredicateTableModel::PredicateTableModel(), props2Hashtable(), setNodeValue(), and com::declarativa::interprolog::gui::TermTreeModel::topList().

transient TermModel com::declarativa::interprolog::TermModel::root
 

The TermModel containing this; relevant to define variable scope. For this to contain the root, the root TermModel must have been messaged once with setRoot()

Definition at line 30 of file TermModel.java.

Referenced by fireTermChanged(), isRoot(), propagateRoot(), and setRoot().


The documentation for this class was generated from the following file:
Generated on Wed Jul 26 13:30:53 2006 for XSB by  doxygen 1.4.5