|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object fr.umlv.tatoo.runtime.ast.CompositeNode<N,P>
N
- type of child nodes.P
- type of parent node.public abstract class CompositeNode<N extends Node,P extends Node>
Represents a node with a variable number of nodes.
FlatNode
,
Serialized FormNested Class Summary |
---|
Nested classes/interfaces inherited from interface fr.umlv.tatoo.runtime.ast.Node |
---|
Node.NoParent, Node.NoValue |
Constructor Summary | |
---|---|
protected |
CompositeNode()
Only subclass can call this constructor |
Method Summary | ||
---|---|---|
protected V |
attributeAt(int index)
Returns the value of the attribute at the index position. |
|
protected V |
attributeAt(int index,
V value)
Changes the value of the attribute at the index position and returns the old value. |
|
protected int |
attributeCount()
Returns the number of attributes. |
|
List<V> |
attributeList()
A read-write list of all attribute values of the current node. |
|
Map<String,V> |
attributeMap()
A read-write map of couples attribute name/attribute value. |
|
protected String |
attributeNameAt(int index)
Returns the name of the attribute at the index position. |
|
protected Class<? extends V> |
attributeTypeAt(int index)
Returns the real type of the attribute at the index position. |
|
boolean |
equals(Object o)
|
|
protected abstract Class<N> |
getElementType()
Returns the real type of the child node. |
|
P |
getParent()
Returns the parent of the current node. |
|
int |
hashCode()
|
|
protected int |
indexOfAttributeName(String name)
Returns the index of an attribute by its name. |
|
List<N> |
nodeList()
Returns a read-write list of all sub nodes of the current node. |
|
protected
|
reparent(T oldNode,
T newNode)
This method changes the parent of the current node. |
|
void |
replaceAllNodes(Collection<? extends N> nodes)
Replaces all sub-nodes of the current node by new ones taken as parameter. |
|
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface fr.umlv.tatoo.runtime.ast.Node |
---|
accept, getName |
Constructor Detail |
---|
protected CompositeNode()
Method Detail |
---|
public List<N> nodeList()
List.add(int, Object)
or List.set(int, Object)
raises an IllegalStateException
if the node taken as argument
has already a parent.
Futhermore, this list checks at runtime if the type of
an inserted node is a subtype of the declared children type.
nodeList
in interface Node
Collections.checkedList(List, Class)
public boolean equals(Object o)
equals
in class Object
public int hashCode()
hashCode
in class Object
public String toString()
toString
in class Object
public P getParent()
getParent
in interface Node
protected <T extends N> T reparent(T oldNode, T newNode)
nodeList().set()
,
nodeList().add()
,
nodeList().remove()
instead.
T
- a subtype of NoldNode
- the old child node.newNode
- the new child node.
public void replaceAllNodes(Collection<? extends N> nodes)
nodeList().clear(); nodeList().addAll(nodes);Each node in
nodes
must have no parent.
Each newly added node will have the current node has parent.
Each removed node will have no parent.
nodes
- a collection of nodes that will be used as new subnodes,
IllegalArgumentException
- if the nodeList()
is a fixed size list
and if its number of nodes is not the same that the number of nodes
of the collection taken as parameter.
IllegalStateException
- if one node of nodes
has a parent.nodeList()
protected abstract Class<N> getElementType()
public List<V> attributeList()
attributeList
in interface Node
Node.attributeMap()
protected int attributeCount()
attributeList().size()
or
attributeMap().size()
instead.
protected V attributeAt(int index) throws IndexOutOfBoundsException
attributeList().get(index)
instead.
index
- the index of the attribute.
IndexOutOfBoundsException
- if the index is not
between 0 and the attribute list size.protected V attributeAt(int index, V value) throws IndexOutOfBoundsException
attributeList().set(index)
instead.
index
- the index of the attribute.value
- the new value of the attribute.
IndexOutOfBoundsException
- if the index is not
between 0 ant the attribute list size.protected String attributeNameAt(int index) throws IndexOutOfBoundsException
index
- index the index of the attribute.
IndexOutOfBoundsException
- if the index is not
between 0 ant the attribute list size.protected Class<? extends V> attributeTypeAt(int index) throws IndexOutOfBoundsException
index
- index the index of the attribute.
IndexOutOfBoundsException
- if the index is not
between 0 ant the attribute list size.protected int indexOfAttributeName(String name)
name
- name of the attribute.
IllegalArgumentException
- if the name of the attribute is not known.public Map<String,V> attributeMap()
attributeMap
in interface Node
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |