|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.declarativa.interprolog.TermModel
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
Field Summary | |
TermModel[] |
children
public for convenience, but should not be set outside this class; children == null means children == new TermModel[0] |
static int |
listMaxLength
|
Object |
node
public for convenience, but should not be set outside this class |
TermModel |
root
The TermModel containing this; relevant to define variable scope. |
Constructor Summary | |
TermModel()
|
|
TermModel(Object n)
|
|
TermModel(Object n,
TermModel[] c)
|
|
TermModel(Object n,
Vector v)
|
Method Summary | |
void |
addChildren(TermModel[] more)
Add children to this term node; a new children array is created and old children are copied to it |
void |
addTermModelListener(TermModelListener l)
Start notifying listener l of changes to this term. |
void |
addTreeModelListener(TreeModelListener l)
|
void |
assignToVar(VariableNode v,
Object value)
Replaces all occurrences of v in this subterm by value, using setNodeValue |
Object |
clone()
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 |
void |
deleteChildren(int[] less)
Delete children with specified indexes; a new children array is created and old children are copied to it |
void |
deleteChildren(TermModel[] less)
Removes the children in array; it finds children to remove by using the equivalent of Prolog's == |
boolean |
equals(Object x)
True if both terms are structurally similar with equal nodes |
static ObjectExamplePair |
example()
|
static TreePath |
findPathForNode(String label,
TermModel tree,
boolean exactMatch)
|
void |
fireTermChanged()
|
TermModel[] |
flatList()
Flattens this list into a new TermModel array, but not completely: the result may still contain lists |
static TermModel[] |
flatList(TermModel list)
Flattens a list into a TermModel array, but not completely: the result may still contain lists |
Object |
getChild(int index)
|
Object |
getChild(Object parent,
int index)
|
int |
getChildCount()
|
int |
getChildCount(Object parent)
|
TermModel[] |
getChildren()
|
String |
getFunctorArity()
Return a node/arity String |
int |
getIndexOfChild(Object parent,
Object child)
|
Object |
getRoot()
|
String |
getTemplate()
Return a Node(_,..._) String |
int |
intValue()
Returns node object as an int, assuming it is a Number |
boolean |
isAtom()
|
boolean |
isInteger()
|
boolean |
isLeaf()
|
boolean |
isLeaf(Object node)
|
boolean |
isList()
|
boolean |
isListEnd()
|
boolean |
isNumber()
|
boolean |
isRoot()
This node is its own root |
boolean |
isVar()
|
String |
listToString(PrologOperatorsContext ops)
|
Vector |
makeIntegerVector()
Assuming this is a list of numbers, returns a Vector containing one Integer for each number in the list |
static TermModel |
makeList(TermModel[] terms)
|
static TermModel |
makeList(Vector terms)
|
boolean |
nodeIsVar()
|
static Hashtable |
props2Hashtable(TermModel[] terms)
|
void |
removeTermModelListener(TermModelListener l)
|
void |
removeTreeModelListener(TreeModelListener l)
|
void |
setChild(int index,
TermModel child)
Set the child, notifying TermModelListeners |
void |
setChildren(TermModel[] c)
Set the children array, notifying TermModelListeners |
void |
setNodeValue(Object v)
Set the node, notifying TermModelListeners |
void |
setRoot()
Set the root variables of nodes in this subterm to refer this term node as their root |
void |
setRoot(TermModel r)
Set the root variables of nodes in this subterm to refer r as their root |
String |
toString()
|
String |
toString(PrologOperatorsContext ops)
|
void |
valueForPathChanged(TreePath path,
Object newValue)
|
Methods inherited from class java.lang.Object |
getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public Object node
public TermModel[] children
public transient TermModel root
public static final int listMaxLength
Constructor Detail |
public TermModel()
public TermModel(Object n)
public TermModel(Object n, TermModel[] c)
public TermModel(Object n, Vector v)
Method Detail |
public static ObjectExamplePair example()
public Object clone()
clone
in class Object
public boolean equals(Object x)
equals
in class Object
public void setNodeValue(Object v)
public void setChild(int index, TermModel child)
public void setChildren(TermModel[] c)
public TermModel[] getChildren()
public void addChildren(TermModel[] more)
public void deleteChildren(int[] less)
public void deleteChildren(TermModel[] less)
public void assignToVar(VariableNode v, Object value)
public void setRoot()
public void setRoot(TermModel r)
public boolean isRoot()
public String getTemplate()
public String getFunctorArity()
public Object getRoot()
getRoot
in interface TreeModel
TreeModel
public Object getChild(Object parent, int index)
getChild
in interface TreeModel
TreeModel
public int getChildCount(Object parent)
getChildCount
in interface TreeModel
TreeModel
public boolean isLeaf(Object node)
isLeaf
in interface TreeModel
TreeModel
public void valueForPathChanged(TreePath path, Object newValue)
valueForPathChanged
in interface TreeModel
TreeModel
public int getIndexOfChild(Object parent, Object child)
getIndexOfChild
in interface TreeModel
TreeModel
public void addTreeModelListener(TreeModelListener l)
addTreeModelListener
in interface TreeModel
TreeModel
public void removeTreeModelListener(TreeModelListener l)
removeTreeModelListener
in interface TreeModel
TreeModel
public Object getChild(int index)
public int getChildCount()
public boolean isLeaf()
public void addTermModelListener(TermModelListener l)
public void removeTermModelListener(TermModelListener l)
public void fireTermChanged()
public static TreePath findPathForNode(String label, TermModel tree, boolean exactMatch)
public static TermModel makeList(TermModel[] terms)
public static TermModel makeList(Vector terms)
public Vector makeIntegerVector()
public int intValue()
public String toString()
toString
in class Object
public String toString(PrologOperatorsContext ops)
public String listToString(PrologOperatorsContext ops)
public boolean isListEnd()
public boolean isList()
public boolean isAtom()
public boolean isNumber()
public boolean isInteger()
public boolean isVar()
public boolean nodeIsVar()
public TermModel[] flatList()
public static TermModel[] flatList(TermModel list)
public static Hashtable props2Hashtable(TermModel[] terms)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |