Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## net.sourceforge.pmd.dcd.graph
Class UsageGraph

    java.lang.Object
      net.sourceforge.pmd.dcd.graph.UsageGraph

All Implemented Interfaces:
  NodeVisitorAcceptor

    public class UsageGraph

extends java.lang.Object
implements NodeVisitorAcceptor

A UsageGraph tracks usage references between Java classes, based upon a parsing of the class files. Once the UsageGraph is built, it may be visited to perform additional post-processing, or usage relationship analysis.

The UsageGraph is composed of ClassNodes. Each ClassNode has various MemberNodes, specifically ConstructorNodes, FieldNodes, and MethodNodes. Each of these MemberNodes keeps track of other MemberNodes which it uses and other MemberNodes which are users of it. In this sense, the graph can navigated bi-directionally across the use relationship between MemberNodes.

Great effort is taken to keep the bookkeeping of the UsageGraph as tight as possible, so that rather large code bases can be analyzed. While nodes can grant access to the underlying Java Reflection APIs (e.g. Class, Constructor, Field, Member), the results are stored using WeakReferences to assist with memory usage.

A class Filter can be specified to limit the set of classes on which usage references will be tracked. This is often done to limit memory usage to interesting classes. For example, the `java.util` package is very often used, and tracking usages would require a massive bookkeeping effort which has little value.

See Also:
  `UsageGraphBuilder`, `ClassNode`, `MemberNode`, `ConstructorNode`, `FieldNode`, `MethodNode`, `NodeVisitor`, `NodeVisitorAcceptor`

Field Summary
`protected Filter<java.lang.String>` | `classFilter`

Constructor Summary
`UsageGraph(Filter<java.lang.String> classFilter)`

Method Summary
`java.lang.Object` | `accept(NodeVisitor visitor, java.lang.Object data)`
`ClassNode` | `defineClass(java.lang.String className)`
`MemberNode` | `defineConstructor(java.lang.String className, java.lang.String name, java.lang.String desc)`
`FieldNode` | `defineField(java.lang.String className, java.lang.String name, java.lang.String desc)`
`MemberNode` | `defineMethod(java.lang.String className, java.lang.String name, java.lang.String desc)`
`boolean` | `isClass(java.lang.String className)`
`void` | `usageField(java.lang.String className, java.lang.String name, java.lang.String desc, MemberNode usingMemberNode)`
`void` | `usageMethod(java.lang.String className, java.lang.String name, java.lang.String desc, MemberNode usingMemberNode)`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### classFilter

    protected final Filter<java.lang.String> classFilter

Constructor Detail

### UsageGraph

    public UsageGraph(Filter<java.lang.String> classFilter)

Method Detail

### accept

    public java.lang.Object accept(NodeVisitor visitor,
                                   java.lang.Object data)

  Specified by:
    `accept` in interface `NodeVisitorAcceptor`

### isClass

    public boolean isClass(java.lang.String className)

### defineClass

    public ClassNode defineClass(java.lang.String className)

### defineField

    public FieldNode defineField(java.lang.String className,
                                 java.lang.String name,
                                 java.lang.String desc)

### defineConstructor

    public MemberNode defineConstructor(java.lang.String className,
                                        java.lang.String name,
                                        java.lang.String desc)

### defineMethod

    public MemberNode defineMethod(java.lang.String className,
                                   java.lang.String name,
                                   java.lang.String desc)

### usageField

    public void usageField(java.lang.String className,
                           java.lang.String name,
                           java.lang.String desc,
                           MemberNode usingMemberNode)

### usageMethod

    public void usageMethod(java.lang.String className,
                            java.lang.String name,
                            java.lang.String desc,
                            MemberNode usingMemberNode)

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2002-2009 InfoEther. All Rights Reserved.