mapss.dif.graph.hierarchy
Class SuperNodeMap

java.lang.Object
  extended by mapss.dif.graph.hierarchy.SuperNodeMap

public class SuperNodeMap
extends java.lang.Object

List of super nodes in a hierarchy. It simulates a doubly linked map so users can both give the super node and get the hierarchy and vice versa.

Hierarchy names should not be duplicated therefore it provides methods to check if a hierarchy name is previously defined in the list.

Entries are stored in the order they are added, getNodes() and iterator() methods maintain this order.

Version:
$Id: SuperNodeMap.java 409 2007-05-13 19:47:16Z plishker $
Author:
Fuat Keceli

Constructor Summary
protected SuperNodeMap()
          Construct a super node map.
 
Method Summary
protected  void _put(mocgraph.Node node, Hierarchy hierarchy)
          Adds a super node - hierarchy pair to the map.
protected  void _remove(mocgraph.Node node)
          Removes a super node - hierarchy pair from the map.
 boolean contains(Hierarchy hierarchy)
          Returns true is a given hierarchy is defined as a sub-hierarchy.
 boolean contains(mocgraph.Node node)
          Returns true is a given node is defined as a super node.
 mocgraph.Node get(Hierarchy hierarchy)
          Returns the super node that contains the given sub-hierarchy.
 Hierarchy get(mocgraph.Node superNode)
          Returns the sub-hierarchy that is contained in a super node.
 Hierarchy get(java.lang.String name)
          Returns the sub-hierarchy that has the given name.
 java.util.List getNodes()
          Returns a collection of nodes that are defined as super nodes.
 boolean isDefined(java.lang.String name)
          Returns true if the given name is the name of another hierarchy.
 boolean isSubHierarchy(Hierarchy hierarchy)
          Returns true if the hierarchy is a sub-hierarchy of this hierarchy.
 boolean isSuperNode(mocgraph.Node node)
          Returns true if the node is a super node of this hierarchy.
 java.util.ListIterator iterator()
          Returns an iterator over the super nodes.
 java.lang.String newName()
          Returns a string that is guaranteed to be unused in this port list as a port name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SuperNodeMap

protected SuperNodeMap()
Construct a super node map.

Method Detail

contains

public boolean contains(Hierarchy hierarchy)
Returns true is a given hierarchy is defined as a sub-hierarchy.

Returns:
True is a given hierarchy is defined as a sub-hierarchy. False otherwise.

contains

public boolean contains(mocgraph.Node node)
Returns true is a given node is defined as a super node.

Returns:
True is a given node is defined as a super node. False otherwise.

get

public mocgraph.Node get(Hierarchy hierarchy)
Returns the super node that contains the given sub-hierarchy.

Parameters:
hierarchy - A sub-hierarchy.
Returns:
A graph node. Null if given hierarchy is not a child of this hierarchy.

get

public Hierarchy get(mocgraph.Node superNode)
Returns the sub-hierarchy that is contained in a super node.

Parameters:
superNode - A super node in the graph.
Returns:
A hierarchy object. Null if the node is not a super node.

get

public Hierarchy get(java.lang.String name)
Returns the sub-hierarchy that has the given name.

Parameters:
name - Name that is being searched.
Returns:
A hierarchy object. Null if not found.

getNodes

public java.util.List getNodes()
Returns a collection of nodes that are defined as super nodes. Order of the nodes returned is the order they are added as super nodes.

Returns:
A collection of nodes. Returned collection can safely be modified.

isDefined

public boolean isDefined(java.lang.String name)
Returns true if the given name is the name of another hierarchy.

Returns:
True if the given name is the name of another hierarchy. False otherwise.

isSubHierarchy

public boolean isSubHierarchy(Hierarchy hierarchy)
Returns true if the hierarchy is a sub-hierarchy of this hierarchy.

Returns:
True if the hierarchy is a sub-hierarchy of this hierarchy. False otherwise.

isSuperNode

public boolean isSuperNode(mocgraph.Node node)
Returns true if the node is a super node of this hierarchy.

Returns:
True if the node is a super node of this hierarchy. False otherwise.

iterator

public java.util.ListIterator iterator()
Returns an iterator over the super nodes. The order is the order they are added.

Returns:
An iterator over the super nodes.

newName

public java.lang.String newName()
Returns a string that is guaranteed to be unused in this port list as a port name.

Returns:
An port name.

_put

protected void _put(mocgraph.Node node,
                    Hierarchy hierarchy)
Adds a super node - hierarchy pair to the map. No error checking is performed therefore originating code should maintain the consistency.

Parameters:
node - Node to be added.
hierarchy - Hierarchy to be added

_remove

protected void _remove(mocgraph.Node node)
Removes a super node - hierarchy pair from the map. No error checking is performed therefore originating code should maintain the consistency.

Parameters:
node - Node to be removed.