|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectARoad0.gBase.NameTreeImpl
public class NameTreeImpl
This class is responsible for managing a fast-methods tree of ImmutableNames. They are not designed to be displayed by the Gui1.CommonPropertyEditor subclasses, but by trees in dedicated Gui1 internal frames. The nodes are ImmutableNames, without any constraint between a node name and its parent node name. The node name may include the parent name or not. However, the current use of this class is to enforce the parent name including. The links between nodes are parent-child relations.
This class reuses the names of the relevant methods in javax.swing.tree.DefaultTreeModel. There is always a non-null name as root. There is no sorting in the children list of a node. A node name cannot be two times in the nametree.
This class is used by the IS trees. It is possible to get new subtrees, that is an independant nametree with a copy of all the indirect children. The NameTree manages mainly nodes and areas. An area is defined as a group of nametree-connected or nametree-unconnected nodes in the nametree, with a specific area name. Areas are used to define virtual structures like a composite ACS which contains several pieces of software running on different servers, and defined in the nametree as classical nodes. The area name cannot be a node name, and areas are put by convention under the nametreee root. Areas may be included in areas, but the nametree does not manage this relation. The visible space (see NameISTree) of an area node always includes this area. Most of the methods are applicable both to nodes and areas, and the exceptions are documented.
A node may have an immutable type. A node may be a hub, which means that for this node, any direct child may have exchanges with any other direct child. For a non-hub node, exchanges between its children are not allowed. The visible space (see NameISTree) of a node having a hub parent always includes all the children of its parent.
The data structure is optimized for searchings from the root, with no more than 20 nodes in any level. This class does not fire property changes.
Field Summary | |
---|---|
static NameTreeImpl |
EMPTY_INSTANCE
A reusable empty instance for initialization, to avoid the use of 'new' for temporary values. |
protected static int |
INCREMENT_CAPACITY
|
protected static int |
INITIAL_CAPACITY
|
protected java.util.ArrayList[] |
l_NodeDescriptors_
array of lists where the index is the level. |
protected java.util.HashMap<ImmutableName,java.util.List<java.lang.String>> |
m_Areas_
hashmap of areas: key: area_name, which may be a node name value: String node type at the index 0, and then node names of items in the area |
protected java.util.HashMap<ImmutableName,java.lang.Integer> |
m_Levels_
hashmap of node levels: key: node_name value: node level in l_NodeDescriptors_ so, the key set gives all the node names. |
protected static int |
PRIME
|
static java.io.ObjectStreamField[] |
serialPersistentFields
standardized variable for the JDK 2 serialization |
protected static long |
serialVersionUID
arraylists array, one array per level for the root: root_name, node_type, is_hub, nb_of_children, null for each level, arraylist of Object[5] one Object[5] for each node: 0: node name (it is the key), 1: node type, 2: is_hub, 3: nb_of_children (at the lower level), 4: parent name (at the upper level) hashmap of nodes from levels: key: node_name value: node level index of a child: get through a search in the right level vector hashmap of areas: key: area_name value: area nodes list |
Constructor Summary | |
---|---|
NameTreeImpl()
The default constructor. |
|
NameTreeImpl(ImmutableName _root_name,
java.lang.String _node_type,
boolean _is_hub)
Constructor. |
Method Summary | |
---|---|
protected void |
addArea(ImmutableName _area,
java.lang.String _node_type)
Adds an empty area in the nametree, which is defined as a set of nodes in the nametree. |
protected void |
addChild(ImmutableName _parent,
ImmutableName _child,
java.lang.String _node_type,
boolean _is_hub)
Adds a child as a new node in the nametree. |
protected void |
addNodeToArea(ImmutableName _area,
ImmutableName _node)
Adds a node to an area in the nametree, only if the new node is a nametree node which is a direct child of an area external node. |
java.lang.Object |
clone()
|
boolean |
equals(java.lang.Object _obj)
This method compares the node and area lists, not the parent-child relations nor the area elements. |
protected void |
finalize()
This method calls finalizeForUser(). |
protected void |
finalizeForUser()
This method nullify all the nameTree inner properties. |
ImmutableName |
getChild(ImmutableName _parent,
int _index)
Gets one of the children in the nametree |
int |
getChildCount(ImmutableName _parent)
Gets the number of children for a node in the nametree, in reading its proper children count. |
int |
getDepthFirstIndexInNameTree(ImmutableName _child)
Gets the current index of a child in its nametree, as the child appears in the IS structure o the GUI, following a depth-first order. |
int |
getIndexInParent(ImmutableName _child)
Gets the current index of a child in its parent array in the nametree. |
java.util.List<ImmutableName> |
getL_AllChildren(ImmutableName _parent)
Gets all the direct and indirect children of a node or area in the nametree. |
java.util.Set<ImmutableName> |
getL_AreaNames()
Gets the set of all the nametree area names, if any. |
java.util.List<ImmutableName> |
getL_AreasOfNode(ImmutableName _name)
Gets the areas of the nametree the node belongs to. |
java.util.List<ImmutableName> |
getL_DirectChildren(ImmutableName _parent)
Gets all the direct children of a node or area in the nametree. |
java.util.List<ImmutableName> |
getL_NodesOfArea(ImmutableName _name)
Gets the nodes belonging to an area of the nametree. |
int |
getLevel(ImmutableName _node)
Gets the level of a node in the nametree. |
java.util.Map |
getM_AreaNodes()
Gets all the areas of this nametree, with their node names. |
private java.lang.Object[] |
getNodeArray(ImmutableName _node)
Gets the internal description of a node in the nametree. |
ImmutableName |
getParent(ImmutableName _child)
Gets the parent of a nametree node or area. |
ImmutableName |
getRoot()
Gets the root of the nametree |
long |
getSerialVersionUID()
|
ImmutableNameTree |
getSubTree(ImmutableName _root)
Gets an independant subtree from the nametree, with all the indirect children. |
javax.swing.tree.TreePath |
getTreePath(ImmutableName _startingNode,
ImmutableName _endingNode)
Gets the path of nodes between two nodes in the nametree, if one of the two nodes is an indirect child of the other one. |
java.lang.String |
getType(ImmutableName _name)
Gets the type of the node or the area. |
int |
hashCode()
|
boolean |
isArea(ImmutableName _name)
Tests a name as area of the nametree. |
boolean |
isEmpty()
|
boolean |
isHubNode(ImmutableName _node)
Tests if a node of the nametree is set as a 'hub' for its children. |
boolean |
isLeaf(ImmutableName _node)
Tests if a node is a leaf of the nametree, in reading its proper children count. |
boolean |
isNode(ImmutableName _name)
Tests a name as node of the nametree, including the root. |
int |
nbOfLevels()
The returned value is at least '1'. |
int |
nbOfNodesAndAreas()
|
java.util.Set<ImmutableName> |
nodes()
Gets the set of all the nametree nodes, including the root and excluding the areas. |
protected void |
removeArea(ImmutableName _area)
Removes an area in the nametree. |
protected void |
removeLeaf(ImmutableName _node)
Remove the internal data for a leaf in the nametree, with an update of the parent, the nametree internal data, the areas, but no removing of the node children. |
protected int |
removeNodeAndSubTree(ImmutableName _node)
Removes a node from the nametree (excepting the root), and removes all the subtree which may be associated to the node. |
protected void |
removeNodeToArea(ImmutableName _area,
ImmutableName _node)
Removes a node in an area in the nametree. |
Methods inherited from class java.lang.Object |
---|
getClass, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final long serialVersionUID
protected static final int INITIAL_CAPACITY
protected static final int INCREMENT_CAPACITY
protected static final int PRIME
protected java.util.ArrayList[] l_NodeDescriptors_
protected java.util.HashMap<ImmutableName,java.lang.Integer> m_Levels_
protected java.util.HashMap<ImmutableName,java.util.List<java.lang.String>> m_Areas_
public static final NameTreeImpl EMPTY_INSTANCE
public static final java.io.ObjectStreamField[] serialPersistentFields
Constructor Detail |
---|
public NameTreeImpl()
public NameTreeImpl(ImmutableName _root_name, java.lang.String _node_type, boolean _is_hub) throws CreateError
_root_name
- is the name of the nametree root. Not null._node_type
- is a type for the root node. May be null._is_hub
- is true if the root is a node hub, which means that
any direct child of this node may have exchanges with any other direct child,
if the rights allow them.
CreateError
- if _root_name is null or empty.Method Detail |
---|
public boolean isEmpty()
isEmpty
in interface ImmutableNameTree
public final ImmutableName getRoot()
getRoot
in interface ImmutableNameTree
public final ImmutableNameTree getSubTree(ImmutableName _root) throws BaseError
Changes on the returned nametree do not change this nametree. Caution: the subclass does not override this method, so the returned object is never an ImmutableNameISTree.
getSubTree
in interface ImmutableNameTree
_root
- node of the nametree which will be the returned subtree root.
Never the nametree root nor an area.
BaseError
- if the root is the nametree root, null, empty, is an area name,
does not belong to the nametree, or if non-consistent data is detected.public java.util.Map getM_AreaNodes()
getM_AreaNodes
in interface ImmutableNameTree
public java.util.Set<ImmutableName> nodes()
nodes
in interface ImmutableNameTree
public final java.util.Set<ImmutableName> getL_AreaNames()
getL_AreaNames
in interface ImmutableNameTree
public final int nbOfNodesAndAreas()
nbOfNodesAndAreas
in interface ImmutableNameTree
public final int nbOfLevels()
nbOfLevels
in interface ImmutableNameTree
public final boolean isNode(ImmutableName _name)
isNode
in interface ImmutableNameTree
_name
- to test
public boolean isArea(ImmutableName _name)
isArea
in interface ImmutableNameTree
_name
- to test
public final java.util.List<ImmutableName> getL_NodesOfArea(ImmutableName _name)
getL_NodesOfArea
in interface ImmutableNameTree
_name
- of an area in the nametree
public final java.util.List<ImmutableName> getL_AreasOfNode(ImmutableName _name)
getL_AreasOfNode
in interface ImmutableNameTree
_name
- of a node of the nametree
public final int getLevel(ImmutableName _node)
getLevel
in interface ImmutableNameTree
_node
- has to be a nametree node or area
public final ImmutableName getParent(ImmutableName _child)
getParent
in interface ImmutableNameTree
_child
- has to be a nametree node name, or an area name
public final ImmutableName getChild(ImmutableName _parent, int _index)
getChild
in interface ImmutableNameTree
_parent
- is a node or area in the nametree_index
- in the parent's child array
public final int getChildCount(ImmutableName _parent) throws BaseError
getChildCount
in interface ImmutableNameTree
_parent
- is a node or an area in the nametree
BaseError
- if the parent is null or does not belong to the nametreepublic final java.util.List<ImmutableName> getL_DirectChildren(ImmutableName _parent)
getL_DirectChildren
in interface ImmutableNameTree
_parent
- is a node or area or the root in the nametree
getL_AllChildren(ARoad0.gBaseInterface.ImmutableName)
public final java.util.List<ImmutableName> getL_AllChildren(ImmutableName _parent)
getL_AllChildren
in interface ImmutableNameTree
_parent
- is a node or area in the nametree
getL_DirectChildren(ARoad0.gBaseInterface.ImmutableName)
public final int getIndexInParent(ImmutableName _child)
getIndexInParent
in interface ImmutableNameTree
_child
- is the node or an area we are interrested in
public final int getDepthFirstIndexInNameTree(ImmutableName _child) throws BaseError
getDepthFirstIndexInNameTree
in interface ImmutableNameTree
_child
- is the node or an area of the nametree
BaseError
- if the arguments does not belong to the nametree,
or if the nametree data is not consistent.public java.lang.String getType(ImmutableName _name) throws BaseError
getType
in interface ImmutableNameTree
_name
- of the node or area
BaseError
- if _name is null or an empty name,
or does not belong to the nametree.public boolean isHubNode(ImmutableName _node) throws BaseError
isHubNode
in interface ImmutableNameTree
BaseError
- if _node is null or an empty name,
or does not belong to the nametree.protected final void addChild(ImmutableName _parent, ImmutableName _child, java.lang.String _node_type, boolean _is_hub) throws BaseError
_parent
- is the parent node of the child in the nametree. Never null._child
- is the unique name of the new child_node_type
- is a value of the type. May be null._is_hub
- is true if the child is a node hub, which means that for this node,
any direct child may have exchanges with any other direct child, if the rights allow them.
BaseError
- if _parent is not a node of this nametree,
if _child is null, an area name, is already a nametree node, or
contains a character that is not a letterprotected final int removeNodeAndSubTree(ImmutableName _node) throws BaseError
_node
- is a node of the nametree
BaseError
- if _node is null, or not in the nametree, or is the rootprotected final void addArea(ImmutableName _area, java.lang.String _node_type) throws BaseError
Areas are used to define virtual structures like a composite ACS which contains several pieces of software running on different servers, and defined in the nametree as nodes. By convention, an area is put under the root of the nametree.
The area name cannot be a node name, and areas are not explicitly in the nametree. Nevertheless, they are often put graphically under the nametreee root. Areas may be included in areas, but the nametree does not manage this relation. The extended visible space (see NameISTree) of an area node is always ALL_THE_IS_SPACE.
_area
- the area name._node_type
- a value of the type. May be null.
BaseError
- if _area is already an area name or a node name, or if
it contains a character that is not a letterprotected final void addNodeToArea(ImmutableName _area, ImmutableName _node) throws BaseError
_area
- is the area name_node
- of the nametree to add to the area
BaseError
- if _node is not a node name of this nametree,
if _area is not an area name, if _node
is not a direct child of an area external node.protected final void removeNodeToArea(ImmutableName _area, ImmutableName _node) throws BaseError
_area
- is an area name_node
- of the nametree to remove to the area
BaseError
- if _areaName is not an area nameprotected void removeArea(ImmutableName _area) throws BaseError
_area
- is an area name
BaseError
- if _area is not an area namepublic final javax.swing.tree.TreePath getTreePath(ImmutableName _startingNode, ImmutableName _endingNode) throws BaseError
getTreePath
in interface ImmutableNameTree
_startingNode
- is a nametree node. Never an area._endingNode
- is a nametree node which is at a lower or a greater level
than _startingNode. Never an area.
BaseError
- if one of the two arguments does not belong to the nametree,
or if the nametree data is not consistent.public final boolean isLeaf(ImmutableName _node) throws BaseError
isLeaf
in interface ImmutableNameTree
_node
- is a node or an area to test
BaseError
- if the node is null or does not belong to the nametreepublic java.lang.Object clone()
clone
in class java.lang.Object
public boolean equals(java.lang.Object _obj)
equals
in interface ImmutableNameTree
equals
in class java.lang.Object
_obj
- is the object to compare
public int hashCode()
hashCode
in interface ImmutableNameTree
hashCode
in class java.lang.Object
public long getSerialVersionUID()
getSerialVersionUID
in interface ImmutableNameTree
protected void finalizeForUser()
protected void finalize() throws java.lang.Throwable
finalize
in class java.lang.Object
java.lang.Throwable
protected void removeLeaf(ImmutableName _node) throws BaseError
_node
- is a node of the nametree, not an area.
BaseError
- if _node is the root, or does not belong to the nametree,
or is not a leaf, or if the base is not consistent.private java.lang.Object[] getNodeArray(ImmutableName _node) throws BaseError
_node
- is the node we are interrested in. Never an area.
0: node name (it is the key), 1: node type (may be null), 2: is_hub,
3: nb_of_children, 4: parent name
BaseError
- if the node does not belong to this nametree.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |