public abstract class Node extends Object implements Comparable
Modifier and Type | Class and Description |
---|---|
static interface |
Node.Operations
This interface defines node operations that can be redefined
using the
addOperations method. |
Modifier and Type | Field and Description |
---|---|
protected Node[] |
_nodes |
(package private) Vector |
_observers |
(package private) static HashMap |
_operations |
(package private) Node.Operations |
_thisoperations |
static Integer |
ID
This field represent the static ID of the class Node.
|
Modifier | Constructor and Description |
---|---|
protected |
Node(int capacity) |
Modifier and Type | Method and Description |
---|---|
abstract void |
accept(Visitor visitor)
This method is part of the implementation of the visitor design pattern.
|
void |
addObserver(NodeObserver observer)
This method allows to add an observer for this node.
|
static void |
addOperations(Integer classID,
Node.Operations operations)
This method allows to redefine some operations for a particular class of nodes.
|
Node[] |
children()
This method returns the children of a the node.
|
void |
childrenAccept(Visitor v)
This method is part of the implementation of the visitor design pattern.
|
boolean |
childrenOfKind(Class[] nodeClasses,
ListOfNodes result)
This method fills the result list with all nodes of the graph
instance of one of the nodeClasses.
|
boolean |
childrenOfKind(Class nodeClass,
ListOfNodes result)
This method fills the result list with all nodes of the graph
instance of the nodeClass.
|
boolean |
childrenOfKind(String nodeClass,
ListOfNodes result)
This method fills the result list with all nodes of the graph
instance of the nodeClass.
|
int |
compare(Node other)
This method compares the node with the one given as an argument.
|
int |
compareTo(Object object)
This method return if the node equals another node.
|
void |
copyValueOf(Node n)
This method replace the graph entirely with the other graph the root is n.
|
void |
copyValueOf(Node n,
HashMap clones) |
protected void |
dofind(Class[] nodeClasses,
int attribut,
Object value,
ListOfNodes result,
boolean all) |
void |
dump(String tab)
This method dumps the graph this node of which is the root.
|
boolean |
equals(Object object)
This method return if the node equals another node.
|
boolean |
find(Class[] nodeClasses,
int attribut,
Object value,
ListOfNodes result,
boolean all) |
boolean |
find(Class[] nodeClasses,
String attribut,
Object value,
ListOfNodes result,
boolean all)
This method fills the result list with all nodes of the graph
instance of one of the nodeClasses, holding an attribute named attribut the value
of which is value parameter.
|
boolean |
find(Class nodeClass,
int attribut,
Object value,
ListOfNodes result,
boolean all) |
boolean |
find(Class nodeClass,
String attribut,
Object value,
ListOfNodes result,
boolean all)
This method fills the result list with all nodes of the graph
instance of the nodeClass, holding an attribute the value
of which is the value parameter.
|
Object |
getAttribute(int attrname) |
Object |
getAttribute(String attrname)
This method returns an object representing the value of the attribute if exists.
|
int |
getClassID()
This method return the dynamic class ID of the node.
|
Node |
getClone()
This method return a clone of the graph this node of which is the root.
|
abstract Node |
getClone(HashMap clones) |
Node.Operations |
getOperations()
This method returns the object implementing the operations associated to this node.
|
boolean |
hasAttribute(int attrname) |
boolean |
hasAttribute(String attrname)
This method returns true is the node holds the attribute the name of which is given as parameter.
|
void |
initNode()
This method is called to initialize the current node if needed.
|
static void |
installOperations(Object[] class_operations_array)
This method allows to redefine operations on several node classes.
|
void |
notifyChanges()
This method call the nodeChanged method on each observer
attached to this node.
|
void |
removeObserver(NodeObserver observer)
This method allows to remove an observer of this node.
|
void |
replace(int index,
Node node)
This method allow to replace a child of the node.
|
void |
setAttribute(int attrname,
Object attrvalue) |
void |
setAttribute(String attrname,
Object attrvalue)
This method set the value of the attribute if exists.
|
String |
toString()
This method return a string representing the node.
|
static HashMap _operations
Node.Operations _thisoperations
public static Integer ID
protected Node[] _nodes
Vector _observers
public int getClassID()
public static void addOperations(Integer classID, Node.Operations operations)
classID
- the id of the class the operations of which we want to redefine.operations
- the new operations definition.public Node.Operations getOperations()
public static void installOperations(Object[] class_operations_array)
class_operations_array
- an array containing alternatively a node class ID
and a Node.Operations class.addOperations(Integer, Node.Operations)
public Node[] children()
public void replace(int index, Node node)
index
- the index of the child to replace.node
- the new node.public void dump(String tab)
tab
- a prefix string used to display each node of the graph.public void childrenAccept(Visitor v)
v
- the visitor to apply on chidlren.public Node getClone()
public void copyValueOf(Node n)
n
- the root node of the new graph.public void notifyChanges()
public void addObserver(NodeObserver observer)
observer
- the observer to add.public void removeObserver(NodeObserver observer)
observer
- the observer to remove.public boolean hasAttribute(String attrname)
attrname
- the name of the attribute (or its hashCode) we are looking for.public boolean hasAttribute(int attrname)
public Object getAttribute(String attrname)
attrname
- the name of the attribute (or its hashCode) we are looking for.public Object getAttribute(int attrname)
public void setAttribute(String attrname, Object attrvalue)
attrname
- the name of the attribute (or its hashCode) we are looking for.attrvalue
- the new value of this attribute.public void setAttribute(int attrname, Object attrvalue)
public abstract void accept(Visitor visitor)
visitor
- the visitor to apply on this node.public boolean childrenOfKind(String nodeClass, ListOfNodes result)
nodeClass
- the name of the class the return nodes must be instance of.result
- the result list.public boolean childrenOfKind(Class nodeClass, ListOfNodes result)
nodeClass
- the class the return nodes must be instance of.result
- the result list.public boolean childrenOfKind(Class[] nodeClasses, ListOfNodes result)
nodeClasses
- the return nodes must be instance of one of these classes.result
- the result list.public boolean find(Class nodeClass, String attribut, Object value, ListOfNodes result, boolean all)
nodeClass
- the class the return nodes must be instance of.attribut
- the name of the attribute (or its hashcode).value
- the expected value of this attribute for the return nodes.result
- the result list.all
- if true, this method looks for all nodes satisfaying the constraints,
otherwise it return the first found node.public boolean find(Class nodeClass, int attribut, Object value, ListOfNodes result, boolean all)
public boolean find(Class[] nodeClasses, String attribut, Object value, ListOfNodes result, boolean all)
nodeClasses
- the return nodes must be instance of one of these classes.attribut
- the name of the attribute.value
- the expected value of this attribute for the return nodes.result
- the result list.all
- if true, this method looks for all nodes satisfaying the constraints,
otherwise it return the first found node.public boolean find(Class[] nodeClasses, int attribut, Object value, ListOfNodes result, boolean all)
protected void dofind(Class[] nodeClasses, int attribut, Object value, ListOfNodes result, boolean all)
public boolean equals(Object object)
public int compareTo(Object object)
compareTo
in interface Comparable
object
- the node to compare with.public int compare(Node other)
other
- the other node to compare the node with.public String toString()
public void initNode()