|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object fr.umlv.tatoo.runtime.ast.FlatNode<N,P,V>
N
- type of the child nodes.P
- type of the parent node.V
- type of the attribute values.public abstract class FlatNode<N extends Node,P extends Node,V>
Represents a node with a fixed number of children nodes.
CompositeNode
,
Serialized FormNested Class Summary |
---|
Nested classes/interfaces inherited from interface fr.umlv.tatoo.runtime.ast.Node |
---|
Node.NoParent, Node.NoValue |
Constructor Summary | |
---|---|
protected |
FlatNode()
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. |
|
protected N |
nodeAt(int index)
Returns the child node at the index position. |
|
protected N |
nodeAt(int index,
N node)
Change the child node at the index position and returns the old one. |
|
protected int |
nodeCount()
Returns the number of child nodes. |
|
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 FlatNode()
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 the size of the list is fixed so
List.add(int, Object)
) and
List.remove(int)
) are not supported.
nodeList
in interface Node
replaceAllNodes(Collection)
protected int nodeCount()
nodeList().size()
instead.
protected N nodeAt(int index)
nodeList().get(index)
instead.
index
- the index of the child node.
IndexOutOfBoundsException
- if the index is not
between 0 and the node list size.protected N nodeAt(int index, N node)
nodeList().set(index)
instead.
index
- the index of the child node.node
- the new child node at index index.
IndexOutOfBoundsException
- if the index is not
between 0 and the node list size.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 |