edu.neu.ccs.demeter.dj
Class ClassGraph

java.lang.Object
  |
  +--edu.neu.ccs.demeter.aplib.cd.ClassGraph
        |
        +--edu.neu.ccs.demeter.dj.ClassGraph
All Implemented Interfaces:
ClassGraphI

public class ClassGraph
extends ClassGraph

A graph whose nodes are classes and whose edges are subclass, superclass, and part-of relationships between classes.


Nested Class Summary
protected  class ClassGraph.Added
          Values in the classesAdded map.
 
Field Summary
protected  Map classesAdded
          A table of classes and what parts have been added.
static boolean debug
           
protected  Map namesClasses
           
protected  Set packages
          The set of packages that have been added.
 
Fields inherited from class edu.neu.ccs.demeter.aplib.cd.ClassGraph
classes, preamble
 
Constructor Summary
ClassGraph()
          Make a class graph from all classes in the default package, including all non-static fields and non-static non-void no-argument methods.
ClassGraph(boolean f, boolean m)
          Make a class graph from all classes in the default package.
ClassGraph(ClassGraph cg, Strategy s)
          Make a class graph with just the classes and edges in cg reachable by following s.
ClassGraph(ClassGraph cg, String s)
          Make a class graph with just the classes and edges in cg reachable by following strategy s.
ClassGraph(String pkg)
          Make a class graph from all classes in the package named pkg, including all non-static fields and non-static non-void no-argument methods.
ClassGraph(String pkg, boolean f, boolean m)
          Make a class graph from all classes in the package named pkg.
ClassGraph(Traversal tg)
          Make a class graph with just the classes and edges in tg.
 
Method Summary
 void addClass(Class cl)
          Add cl and all its non-static members to the class graph as construction edges, if they haven't already been added.
 void addClass(Class cl, boolean addFields, boolean addMethods)
          Add cl to the class graph, if it hasn't already been added.
 Part addConstructionEdge(Field field)
          Add a field as a construction edge.
 Part addConstructionEdge(Method method)
          Add a no-args method as a construction edge.
 Part addConstructionEdge(String source, Field field)
          Add a field as a construction edge.
 Part addConstructionEdge(String source, Method method)
          Add a no-args method as a construction edge.
 Part addConstructionEdge(String source, String label, Class target)
          Add a class member as a construction edge.
 void addPackage(String p)
          Add all classes in package p that can be found on the class path.
 void addRepetitionEdge(String source, String target)
          Add a repetition edge from source to target.
 List asList(Object o, Strategy s)
          A fixed-size List backed by the object graph rooted at o.
 List asList(Object o, String s)
          A fixed-size List backed by the object graph rooted at o.
 Object fetch(Object o, Strategy s)
          Fetch the object in the object graph rooted at o corresponding to the target of s.
 Object fetch(Object o, String s)
          Fetch the object in the object graph rooted at o corresponding to the target of strategy s.
 List gather(Object o, Strategy s)
          Gather into a list the objects in the object graph rooted at o corresponding to the target of s.
 List gather(Object o, String s)
          Gather the objects in the object graph rooted at o corresponding to the target of strategy s.
 Class getClassNamed(String name)
          The Class object corresponding to the node named name.
 Class getNodeClass(Object node)
          The Class object corresponding to the node o.
static String getVersion()
          The DJ version string.
static boolean isRepetitionEdge(EdgeI edge)
           
static void main(String[] args)
          Testing stub.
 ObjectGraphSlice slice(Object o, Strategy s)
          The slice of the object graph rooted at o determined by s.
 ObjectGraphSlice slice(Object o, String s)
          The slice of the object graph rooted at o determined by strategy s.
 Object traverse(Object o, Strategy s, Visitor v)
          Traverse the object graph rooted at o along s, visiting v at each node and returning the value of v.getReturnValue() at the end of the traversal.
 Object traverse(Object o, Strategy s, Visitor[] v)
          Traverse the object graph rooted at o along s, visiting the visitors in array v in sequence at each node and returning the value of v[0].getReturnValue() at the end of the traversal.
 Object traverse(Object o, String s, Visitor v)
          Traverse the object graph rooted at o along strategy s using v, returning the value of v.getReturnValue() at the end of the traversal.
 Object traverse(Object o, String s, Visitor[] v)
          Traverse the object graph rooted at o along strategy s using visitors in array v in parallel, returning the value of v[0].getReturnValue() at the end of the traversal.
static String version()
          Deprecated. getVersion()
 
Methods inherited from class edu.neu.ccs.demeter.aplib.cd.ClassGraph
__trav_convertRepetition, __trav_expandParamDefs, __trav_removeParamDefs, __trav_setBackLinks, __trav_setInheritanceLinks, addAlternationEdge, addConstructionEdge, addEdge, addInheritanceEdge, allClassDefs, allParts, definesClass, fromString, get_classes, get_preamble, getIncomingEdges, getNode, getNodes, getOutgoingEdges, normalize, parse, parse, parse, printTraversalEdges, readFrom, readFrom, set_classes, set_preamble, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

debug

public static boolean debug

packages

protected Set packages
The set of packages that have been added.


classesAdded

protected Map classesAdded
A table of classes and what parts have been added. ClassGraph.definesClass(java.lang.String) will be true for classes we've added on either end of an edge, but we want to keep track of edge sources in particular.


namesClasses

protected Map namesClasses
Constructor Detail

ClassGraph

public ClassGraph()
Make a class graph from all classes in the default package, including all non-static fields and non-static non-void no-argument methods.


ClassGraph

public ClassGraph(String pkg)
Make a class graph from all classes in the package named pkg, including all non-static fields and non-static non-void no-argument methods.


ClassGraph

public ClassGraph(boolean f,
                  boolean m)
Make a class graph from all classes in the default package. If f is true, include all non-static fields; if m is true, include all non-static non-void no-argument methods. These settings will apply by default for all classes added to the class graph in the future.


ClassGraph

public ClassGraph(String pkg,
                  boolean f,
                  boolean m)
Make a class graph from all classes in the package named pkg. If f is true, include all non-static fields; if m is true, include all non-static non-void no-argument methods. These settings will apply by default for all classes added to the class graph in the future.


ClassGraph

public ClassGraph(Traversal tg)
Make a class graph with just the classes and edges in tg.


ClassGraph

public ClassGraph(ClassGraph cg,
                  Strategy s)
           throws TraversalException
Make a class graph with just the classes and edges in cg reachable by following s.


ClassGraph

public ClassGraph(ClassGraph cg,
                  String s)
           throws TraversalException
Make a class graph with just the classes and edges in cg reachable by following strategy s.

Method Detail

getVersion

public static String getVersion()
The DJ version string.


version

public static String version()
Deprecated. getVersion()


addPackage

public void addPackage(String p)
Add all classes in package p that can be found on the class path.


addClass

public void addClass(Class cl)
Add cl and all its non-static members to the class graph as construction edges, if they haven't already been added.


addClass

public void addClass(Class cl,
                     boolean addFields,
                     boolean addMethods)
Add cl to the class graph, if it hasn't already been added. If addFields is true, add all its non-static fields as construction edges. If addMethods is true, add all its non-static non-void methods with no arguments as derived construction edges.


addConstructionEdge

public Part addConstructionEdge(Field field)
Add a field as a construction edge.


addConstructionEdge

public Part addConstructionEdge(Method method)
Add a no-args method as a construction edge.


addConstructionEdge

public Part addConstructionEdge(String source,
                                Field field)
Add a field as a construction edge.


addConstructionEdge

public Part addConstructionEdge(String source,
                                Method method)
Add a no-args method as a construction edge.


addConstructionEdge

public Part addConstructionEdge(String source,
                                String label,
                                Class target)
Add a class member as a construction edge.


addRepetitionEdge

public void addRepetitionEdge(String source,
                              String target)
Add a repetition edge from source to target.


isRepetitionEdge

public static boolean isRepetitionEdge(EdgeI edge)

getNodeClass

public Class getNodeClass(Object node)
The Class object corresponding to the node o.


getClassNamed

public Class getClassNamed(String name)
The Class object corresponding to the node named name.


slice

public ObjectGraphSlice slice(Object o,
                              Strategy s)
The slice of the object graph rooted at o determined by s.


slice

public ObjectGraphSlice slice(Object o,
                              String s)
The slice of the object graph rooted at o determined by strategy s.


traverse

public Object traverse(Object o,
                       Strategy s,
                       Visitor v)
Traverse the object graph rooted at o along s, visiting v at each node and returning the value of v.getReturnValue() at the end of the traversal.


traverse

public Object traverse(Object o,
                       Strategy s,
                       Visitor[] v)
Traverse the object graph rooted at o along s, visiting the visitors in array v in sequence at each node and returning the value of v[0].getReturnValue() at the end of the traversal.


fetch

public Object fetch(Object o,
                    Strategy s)
             throws FetchException
Fetch the object in the object graph rooted at o corresponding to the target of s.

FetchException

gather

public List gather(Object o,
                   Strategy s)
Gather into a list the objects in the object graph rooted at o corresponding to the target of s.


asList

public List asList(Object o,
                   Strategy s)
A fixed-size List backed by the object graph rooted at o. The elements of the list are the objects reachable by s in the object graph with the given root whose class is a target of s. Throws TraversalSourceException if the type of root is not a source of the strategy. Note that this list (like the List returned by Arrays.asList, but unlike the List returned by gather()) is write-through, i.e. modifying it will modify the underlying object graph, and vice versa.


traverse

public Object traverse(Object o,
                       String s,
                       Visitor v)
Traverse the object graph rooted at o along strategy s using v, returning the value of v.getReturnValue() at the end of the traversal.


traverse

public Object traverse(Object o,
                       String s,
                       Visitor[] v)
Traverse the object graph rooted at o along strategy s using visitors in array v in parallel, returning the value of v[0].getReturnValue() at the end of the traversal.


fetch

public Object fetch(Object o,
                    String s)
             throws FetchException
Fetch the object in the object graph rooted at o corresponding to the target of strategy s.

FetchException

gather

public List gather(Object o,
                   String s)
Gather the objects in the object graph rooted at o corresponding to the target of strategy s.


asList

public List asList(Object o,
                   String s)
A fixed-size List backed by the object graph rooted at o. The elements of the list are the objects reachable by strategy s in the object graph with the given root whose class is a target of s. Throws TraversalSourceException if the type of root is not a source of the strategy. Note that this list (like the List returned by Arrays.asList, but unlike the List returned by gather()) is write-through, i.e. modifying it will modify the underlying object graph, and vice versa.


main

public static void main(String[] args)
Testing stub.