public abstract class ProgramNode
extends java.lang.Object
implements javax.swing.tree.MutableTreeNode, java.lang.Cloneable
| Modifier and Type | Field and Description |
|---|---|
protected ProgramNode[] |
children
The children of this node.
|
protected ProgramNode |
parent
The parent of this node.
|
static int |
TYPE_BOOLEAN |
static int |
TYPE_DOUBLE |
static int |
TYPE_INT |
static int |
TYPE_UNDEFINED
The node result/operand types.
|
protected static java.util.ArrayList |
values
Container for the variable values passed to the program.
|
| Constructor and Description |
|---|
ProgramNode() |
| Modifier and Type | Method and Description |
|---|---|
static void |
addValue(java.lang.Object value)
Adds a value to the variable container.
|
java.util.Enumeration |
children()
Returns an Enumeration of the children.
|
static void |
clearValues()
Removes all values from the container.
|
ProgramNode |
clone()
A deep clone of this node and all the nodes below, if the node is in a valid tree structure.
|
static ProgramNode |
create(Element element)
Creates the ProgramNode designated by an XML element by calling the XML constructor.
|
boolean |
equals(java.lang.Object otherNode)
Checks for equality of this node to another by using the nodes' string representation.
|
abstract java.lang.Object |
eval()
Evaluates the node.
|
boolean |
getAllowsChildren()
Returns if the node allows children.
|
javax.swing.tree.MutableTreeNode |
getChildAt(int childIndex)
Returns the child at the given index.
|
int |
getChildCount()
Returns the number of children of this node.
|
int |
getIndex(javax.swing.tree.TreeNode node)
Returns the index of the given node in children.
|
int |
getLevel()
Returns the node's level in a tree.
|
int |
getOperandType(int index)
Returns the operand type of the program node.
|
ProgramNode |
getParent()
Returns the parent of this node.
|
abstract int |
getResultType()
Returns the result type of the program node.
|
abstract java.lang.String |
getSignature()
Returns the string signature of the node.
|
int |
hashCode()
Returns a hash code for the node by using the hash code for its string representation.
|
void |
insert(javax.swing.tree.MutableTreeNode node,
int index)
Sets the given node at index in children.
|
boolean |
isLeaf()
Returns if the node is a leaf node.
|
void |
mutate()
Mutates attributes of a program node, if necessary.
|
void |
randomize()
Randomizes attributes of a program node, if necessary.
|
void |
remove(int index)
Sets the node at the given child index to null.
|
void |
remove(javax.swing.tree.MutableTreeNode node)
Removes the given child node.
|
void |
removeFromParent()
Removes this node from parent.
|
void |
setParent(javax.swing.tree.MutableTreeNode parent)
Sets the parent of this node.
|
void |
setUserObject(java.lang.Object o)
Empty implementation.
|
abstract java.lang.String |
toString()
Returns the string representation of the node.
|
Element |
toXml(Element parent)
Saves the node to XML.
|
public static final int TYPE_UNDEFINED
public static final int TYPE_INT
public static final int TYPE_DOUBLE
public static final int TYPE_BOOLEAN
protected static java.util.ArrayList values
protected ProgramNode parent
protected ProgramNode[] children
public ProgramNode clone()
clone in class java.lang.Objectpublic boolean equals(java.lang.Object otherNode)
equals in class java.lang.ObjectotherNode - another nodepublic int hashCode()
hashCode in class java.lang.Objectpublic ProgramNode getParent()
getParent in interface javax.swing.tree.TreeNodepublic void setParent(javax.swing.tree.MutableTreeNode parent)
setParent in interface javax.swing.tree.MutableTreeNodeparent - the parent nodepublic javax.swing.tree.MutableTreeNode getChildAt(int childIndex)
getChildAt in interface javax.swing.tree.TreeNodechildIndex - the index of the childpublic int getChildCount()
getChildCount in interface javax.swing.tree.TreeNodepublic int getIndex(javax.swing.tree.TreeNode node)
getIndex in interface javax.swing.tree.TreeNodepublic void insert(javax.swing.tree.MutableTreeNode node,
int index)
insert in interface javax.swing.tree.MutableTreeNodenode - a ProgramNodeindex - the indexpublic void remove(int index)
remove in interface javax.swing.tree.MutableTreeNodeindex - the indexpublic void remove(javax.swing.tree.MutableTreeNode node)
remove in interface javax.swing.tree.MutableTreeNodenode - a child nodepublic void removeFromParent()
removeFromParent in interface javax.swing.tree.MutableTreeNodepublic boolean getAllowsChildren()
getAllowsChildren in interface javax.swing.tree.TreeNodepublic boolean isLeaf()
isLeaf in interface javax.swing.tree.TreeNodepublic java.util.Enumeration children()
children in interface javax.swing.tree.TreeNodepublic void setUserObject(java.lang.Object o)
setUserObject in interface javax.swing.tree.MutableTreeNodeo - a user objectpublic int getLevel()
public abstract java.lang.Object eval()
public abstract java.lang.String getSignature()
public abstract java.lang.String toString()
toString in class java.lang.Objectpublic abstract int getResultType()
public int getOperandType(int index)
index - a child indexpublic void randomize()
public void mutate()
public static void addValue(java.lang.Object value)
value - a variable value of arbitrary typepublic static void clearValues()
public static ProgramNode create(Element element)
element - an XML JDOM elementpublic Element toXml(Element parent)
parent - the JDOM parent element