org.eigenbase.jmi
Class JmiModelGraph

java.lang.Object
  extended by org.jgrapht.graph.AbstractGraph<V,E>
      extended by org.jgrapht.graph.GraphDelegator<V,E>
          extended by org.jgrapht.graph.UnmodifiableGraph<V,E>
              extended by org.jgrapht.graph.UnmodifiableDirectedGraph<JmiClassVertex,org.jgrapht.graph.DefaultEdge>
                  extended by org.eigenbase.jmi.JmiModelGraph
All Implemented Interfaces:
Serializable, org.jgrapht.DirectedGraph<JmiClassVertex,org.jgrapht.graph.DefaultEdge>, org.jgrapht.Graph<JmiClassVertex,org.jgrapht.graph.DefaultEdge>

public class JmiModelGraph
extends org.jgrapht.graph.UnmodifiableDirectedGraph<JmiClassVertex,org.jgrapht.graph.DefaultEdge>

JmiModelGraph is a directed graph representation of a JMI model. Vertices are instances of JmiClassVertex. Edges are instances of either JmiInheritanceEdge or JmiAssocEdge. Graph instances are immutable and can be accessed concurrently by multiple threads.

Version:
$Id: //open/dev/farrago/src/org/eigenbase/jmi/JmiModelGraph.java#20 $
Author:
John V. Sichi
See Also:
Serialized Form

Field Summary
private  org.jgrapht.DirectedGraph<JmiClassVertex,org.jgrapht.graph.DefaultEdge> assocGraph
          Subgraph with just inheritance edges.
private  ClassLoader classLoader
          Class loader to instantiate MDR classes.
private  org.jgrapht.DirectedGraph<JmiClassVertex,org.jgrapht.graph.DefaultEdge> combinedGraph
          The underlying graph structure; we hide it here so that it can only be modified internally.
private  org.jgrapht.DirectedGraph<JmiClassVertex,JmiInheritanceEdge> inheritanceGraph
          Subgraph with just inheritance edges.
private  Map<Object,Object> map
          Map from Ref and Mof instances to corresponding graph vertices and edges.
private  RefPackage refRootPackage
           
private  boolean strict
           
private  org.jgrapht.DirectedGraph<JmiClassVertex,org.jgrapht.graph.DefaultEdge> unmodifiableAssocGraph
          Unmodifiable view of assocGraph.
private  org.jgrapht.DirectedGraph<JmiClassVertex,JmiInheritanceEdge> unmodifiableInheritanceGraph
          Unmodifiable view of inheritanceGraph.
 
Constructor Summary
  JmiModelGraph(RefPackage refRootPackage)
          Creates a new graph based on the contents of a RefPackage and all of its subpackages.
  JmiModelGraph(RefPackage refRootPackage, ClassLoader classLoader, boolean strict)
          Creates a new graph based on the contents of a RefPackage and all of its subpackages, with control over strictness.
private JmiModelGraph(RefPackage refRootPackage, ClassLoader classLoader, org.jgrapht.DirectedGraph<JmiClassVertex,org.jgrapht.graph.DefaultEdge> combinedGraph, boolean strict)
           
 
Method Summary
private  void addMofAssoc(Association mofAssoc)
           
private  JmiClassVertex addMofClass(MofClass mofClass)
           
private  void addMofPackage(MofPackage mofPackage)
           
private  void addRefAssoc(RefAssociation refAssoc)
           
private  void addRefClass(RefClass refClass)
           
private  void addRefPackage(RefPackage refPackage)
           
 org.jgrapht.DirectedGraph<JmiClassVertex,org.jgrapht.graph.DefaultEdge> getAssocGraph()
           
 JmiAssocEdge getEdgeForAssocName(String name)
          Gets the edge representing a MOF association by name.
 JmiAssocEdge getEdgeForMofAssoc(Association mofAssoc)
          Gets the edge representing a MOF association.
 JmiAssocEdge getEdgeForRefAssoc(RefAssociation refAssoc)
          Gets the edge representing a JMI reflective association.
 org.jgrapht.DirectedGraph<JmiClassVertex,JmiInheritanceEdge> getInheritanceGraph()
           
 Association getMofAssocForEdge(JmiAssocEdge edge)
          Gets the MOF representation for an association.
 MofClass getMofClassForVertex(JmiClassVertex vertex)
          Gets the MOF representation for a class.
 RefAssociation getRefAssocForEdge(JmiAssocEdge edge)
          Gets the JMI reflective representation for an association.
 RefClass getRefClassForVertex(JmiClassVertex vertex)
          Gets the JMI reflective representation for a class.
 RefPackage getRefRootPackage()
           
 JmiClassVertex getVertexForClassName(String name)
          Gets the vertex representing a MOF class by name.
 JmiClassVertex getVertexForJavaInterface(Class javaInterface)
          Gets the vertex representing a Java interface.
 JmiClassVertex getVertexForMofClass(MofClass mofClass)
          Gets the vertex representing a MOF class.
 JmiClassVertex getVertexForRefClass(RefClass refClass)
          Gets the vertex representing a class from JMI reflection.
 
Methods inherited from class org.jgrapht.graph.UnmodifiableGraph
addEdge, addEdge, addVertex, removeAllEdges, removeAllEdges, removeAllVertices, removeEdge, removeEdge, removeVertex
 
Methods inherited from class org.jgrapht.graph.GraphDelegator
containsEdge, containsVertex, degreeOf, edgeSet, edgesOf, getAllEdges, getEdge, getEdgeFactory, getEdgeSource, getEdgeTarget, getEdgeWeight, incomingEdgesOf, inDegreeOf, outDegreeOf, outgoingEdgesOf, setEdgeWeight, toString, vertexSet
 
Methods inherited from class org.jgrapht.graph.AbstractGraph
assertVertexExist, containsEdge, removeAllEdges, toStringFromSets
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.jgrapht.DirectedGraph
incomingEdgesOf, inDegreeOf, outDegreeOf, outgoingEdgesOf
 
Methods inherited from interface org.jgrapht.Graph
addEdge, addEdge, addVertex, containsEdge, containsEdge, containsVertex, edgeSet, edgesOf, getAllEdges, getEdge, getEdgeFactory, getEdgeSource, getEdgeTarget, getEdgeWeight, removeAllEdges, removeAllEdges, removeAllVertices, removeEdge, removeEdge, removeVertex, vertexSet
 

Field Detail

classLoader

private final ClassLoader classLoader
Class loader to instantiate MDR classes. It's important to set this correctly if there are extension models (not on the regular classpath).


combinedGraph

private final org.jgrapht.DirectedGraph<JmiClassVertex,org.jgrapht.graph.DefaultEdge> combinedGraph
The underlying graph structure; we hide it here so that it can only be modified internally.


inheritanceGraph

private final org.jgrapht.DirectedGraph<JmiClassVertex,JmiInheritanceEdge> inheritanceGraph
Subgraph with just inheritance edges.


unmodifiableInheritanceGraph

private final org.jgrapht.DirectedGraph<JmiClassVertex,JmiInheritanceEdge> unmodifiableInheritanceGraph
Unmodifiable view of inheritanceGraph.


assocGraph

private final org.jgrapht.DirectedGraph<JmiClassVertex,org.jgrapht.graph.DefaultEdge> assocGraph
Subgraph with just inheritance edges.


unmodifiableAssocGraph

private final org.jgrapht.DirectedGraph<JmiClassVertex,org.jgrapht.graph.DefaultEdge> unmodifiableAssocGraph
Unmodifiable view of assocGraph.


map

private final Map<Object,Object> map
Map from Ref and Mof instances to corresponding graph vertices and edges.


refRootPackage

private final RefPackage refRootPackage

strict

private final boolean strict
Constructor Detail

JmiModelGraph

public JmiModelGraph(RefPackage refRootPackage)
Creates a new graph based on the contents of a RefPackage and all of its subpackages.

Parameters:
refRootPackage - package on which graph is based

JmiModelGraph

public JmiModelGraph(RefPackage refRootPackage,
                     ClassLoader classLoader,
                     boolean strict)
Creates a new graph based on the contents of a RefPackage and all of its subpackages, with control over strictness.

Parameters:
refRootPackage - package on which graph is based
classLoader - class loader, or null to use the system default
strict - true to prevent dangling references in model; false to ignore them

JmiModelGraph

private JmiModelGraph(RefPackage refRootPackage,
                      ClassLoader classLoader,
                      org.jgrapht.DirectedGraph<JmiClassVertex,org.jgrapht.graph.DefaultEdge> combinedGraph,
                      boolean strict)
Method Detail

getInheritanceGraph

public org.jgrapht.DirectedGraph<JmiClassVertex,JmiInheritanceEdge> getInheritanceGraph()
Returns:
the subgraph of only inheritance edges

getAssocGraph

public org.jgrapht.DirectedGraph<JmiClassVertex,org.jgrapht.graph.DefaultEdge> getAssocGraph()
Returns:
the subgraph of only association edges

getVertexForRefClass

public JmiClassVertex getVertexForRefClass(RefClass refClass)
Gets the vertex representing a class from JMI reflection.

Parameters:
refClass - the class of interest
Returns:
corresponding vertex

getVertexForMofClass

public JmiClassVertex getVertexForMofClass(MofClass mofClass)
Gets the vertex representing a MOF class.

Parameters:
mofClass - the class of interest
Returns:
corresponding vertex

getVertexForJavaInterface

public JmiClassVertex getVertexForJavaInterface(Class javaInterface)
Gets the vertex representing a Java interface.

Parameters:
javaInterface - the Java interface of interest
Returns:
corresponding vertex

getEdgeForMofAssoc

public JmiAssocEdge getEdgeForMofAssoc(Association mofAssoc)
Gets the edge representing a MOF association.

Parameters:
mofAssoc - the association of interest
Returns:
corresponding edge

getEdgeForRefAssoc

public JmiAssocEdge getEdgeForRefAssoc(RefAssociation refAssoc)
Gets the edge representing a JMI reflective association.

Parameters:
refAssoc - the association of interest
Returns:
corresponding edge

getVertexForClassName

public JmiClassVertex getVertexForClassName(String name)
Gets the vertex representing a MOF class by name.

Parameters:
name - name of the class of interest
Returns:
corresponding vertex

getEdgeForAssocName

public JmiAssocEdge getEdgeForAssocName(String name)
Gets the edge representing a MOF association by name.

Parameters:
name - name of the association of interest
Returns:
corresponding edge

getRefClassForVertex

public RefClass getRefClassForVertex(JmiClassVertex vertex)
Gets the JMI reflective representation for a class.

Parameters:
vertex - vertex representing class of interest
Returns:
reflective representation for class

getMofClassForVertex

public MofClass getMofClassForVertex(JmiClassVertex vertex)
Gets the MOF representation for a class.

Parameters:
vertex - vertex representing class of interest
Returns:
MOF representation for class

getMofAssocForEdge

public Association getMofAssocForEdge(JmiAssocEdge edge)
Gets the MOF representation for an association.

Parameters:
edge - edge representing association of interest
Returns:
MOF representation for association

getRefAssocForEdge

public RefAssociation getRefAssocForEdge(JmiAssocEdge edge)
Gets the JMI reflective representation for an association.

Parameters:
edge - edge representing association of interest
Returns:
JMI reflective representation for association

getRefRootPackage

public RefPackage getRefRootPackage()
Returns:
the JMI reflective representation for the root package represented by this graph

addMofPackage

private void addMofPackage(MofPackage mofPackage)

addMofClass

private JmiClassVertex addMofClass(MofClass mofClass)

addMofAssoc

private void addMofAssoc(Association mofAssoc)

addRefPackage

private void addRefPackage(RefPackage refPackage)

addRefClass

private void addRefClass(RefClass refClass)

addRefAssoc

private void addRefAssoc(RefAssociation refAssoc)