com.jeantessier.dependency
Class CodeDependencyCollector

java.lang.Object
  |
  +--com.jeantessier.classreader.VisitorBase
        |
        +--com.jeantessier.dependency.CodeDependencyCollector
All Implemented Interfaces:
Collector, java.util.EventListener, LoadListener, Visitor

public class CodeDependencyCollector
extends VisitorBase
implements Collector

Traverses a Classfile and extracts dependencies from its code. Does not see dependencies on static final simple constants (basic type or String) and does not look at local variables.


Constructor Summary
CodeDependencyCollector()
           
CodeDependencyCollector(NodeFactory factory)
           
 
Method Summary
 void addDependencyListener(DependencyListener listener)
           
 void BeginClassfile(LoadEvent event)
          The loader is starting on a new .class file.
 void BeginFile(LoadEvent event)
          The loader is starting on a new file.
 void BeginGroup(LoadEvent event)
          The loader is starting on a new group of files.
 void BeginSession(LoadEvent event)
           
 java.util.Collection Collection()
           
 void EndClassfile(LoadEvent event)
          The loader is finished loading a .class file.
 void EndFile(LoadEvent event)
          The loader is finished with a file.
 void EndGroup(LoadEvent event)
          The loader finished the group of files.
 void EndSession(LoadEvent event)
           
 NodeFactory Factory()
           
protected  void fireBeginClass(java.lang.String classname)
           
protected  void fireBeginSession()
           
protected  void fireDependency(Node dependent, Node dependable)
           
protected  void fireEndClass(java.lang.String classname)
           
protected  void fireEndSession()
           
 void removeDependencyListener(DependencyListener listener)
           
 void VisitClass_info(Class_info entry)
           
 void VisitClassfile(Classfile classfile)
           
 void VisitCode_attribute(Code_attribute attribute)
           
 void VisitExceptionHandler(ExceptionHandler helper)
           
 void VisitField_info(Field_info entry)
           
 void VisitFieldRef_info(FieldRef_info entry)
           
 void VisitInterfaceMethodRef_info(InterfaceMethodRef_info entry)
           
 void VisitMethod_info(Method_info entry)
           
 void VisitMethodRef_info(MethodRef_info entry)
           
 
Methods inherited from class com.jeantessier.classreader.VisitorBase
CurrentCount, RaiseCount, ResetCount, VisitConstantPool, VisitConstantValue_attribute, VisitCustom_attribute, VisitDeprecated_attribute, VisitDouble_info, VisitExceptions_attribute, VisitFloat_info, VisitInnerClass, VisitInnerClasses_attribute, VisitInteger_info, VisitLineNumber, VisitLineNumberTable_attribute, VisitLocalVariable, VisitLocalVariableTable_attribute, VisitLong_info, VisitNameAndType_info, VisitSourceFile_attribute, VisitString_info, VisitSynthetic_attribute, VisitUTF8_info
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.jeantessier.classreader.Visitor
VisitConstantPool, VisitConstantValue_attribute, VisitCustom_attribute, VisitDeprecated_attribute, VisitDouble_info, VisitExceptions_attribute, VisitFloat_info, VisitInnerClass, VisitInnerClasses_attribute, VisitInteger_info, VisitLineNumber, VisitLineNumberTable_attribute, VisitLocalVariable, VisitLocalVariableTable_attribute, VisitLong_info, VisitNameAndType_info, VisitSourceFile_attribute, VisitString_info, VisitSynthetic_attribute, VisitUTF8_info
 

Constructor Detail

CodeDependencyCollector

public CodeDependencyCollector()

CodeDependencyCollector

public CodeDependencyCollector(NodeFactory factory)
Method Detail

Factory

public NodeFactory Factory()

Collection

public java.util.Collection Collection()
Specified by:
Collection in interface Collector

VisitClassfile

public void VisitClassfile(Classfile classfile)
Specified by:
VisitClassfile in interface Visitor
Overrides:
VisitClassfile in class VisitorBase

VisitClass_info

public void VisitClass_info(Class_info entry)
Specified by:
VisitClass_info in interface Visitor
Overrides:
VisitClass_info in class VisitorBase

VisitFieldRef_info

public void VisitFieldRef_info(FieldRef_info entry)
Specified by:
VisitFieldRef_info in interface Visitor
Overrides:
VisitFieldRef_info in class VisitorBase

VisitMethodRef_info

public void VisitMethodRef_info(MethodRef_info entry)
Specified by:
VisitMethodRef_info in interface Visitor
Overrides:
VisitMethodRef_info in class VisitorBase

VisitInterfaceMethodRef_info

public void VisitInterfaceMethodRef_info(InterfaceMethodRef_info entry)
Specified by:
VisitInterfaceMethodRef_info in interface Visitor
Overrides:
VisitInterfaceMethodRef_info in class VisitorBase

VisitField_info

public void VisitField_info(Field_info entry)
Specified by:
VisitField_info in interface Visitor
Overrides:
VisitField_info in class VisitorBase

VisitMethod_info

public void VisitMethod_info(Method_info entry)
Specified by:
VisitMethod_info in interface Visitor
Overrides:
VisitMethod_info in class VisitorBase

VisitCode_attribute

public void VisitCode_attribute(Code_attribute attribute)
Specified by:
VisitCode_attribute in interface Visitor
Overrides:
VisitCode_attribute in class VisitorBase

VisitExceptionHandler

public void VisitExceptionHandler(ExceptionHandler helper)
Specified by:
VisitExceptionHandler in interface Visitor
Overrides:
VisitExceptionHandler in class VisitorBase

addDependencyListener

public void addDependencyListener(DependencyListener listener)

removeDependencyListener

public void removeDependencyListener(DependencyListener listener)

fireBeginSession

protected void fireBeginSession()

fireBeginClass

protected void fireBeginClass(java.lang.String classname)

fireDependency

protected void fireDependency(Node dependent,
                              Node dependable)

fireEndClass

protected void fireEndClass(java.lang.String classname)

fireEndSession

protected void fireEndSession()

BeginSession

public void BeginSession(LoadEvent event)
Specified by:
BeginSession in interface LoadListener

BeginGroup

public void BeginGroup(LoadEvent event)
Description copied from interface: LoadListener

The loader is starting on a new group of files. For example, this can be a new JAR file or a collection of loose .class files.

The event's filename attribute points to the source or the group of files, such as the JAR file's name or the root directory of the loose files.

The element and classfile attributes are null.

Specified by:
BeginGroup in interface LoadListener

BeginClassfile

public void BeginClassfile(LoadEvent event)
Description copied from interface: LoadListener

The loader is starting on a new .class file.

The event's element attribute contains the name of the .class file being processed.

The event's filename attribute points to the group of files that contains the current file. For example, the JAR file's name or the root directory of loose files.

The classfile attribute is null.

Specified by:
BeginClassfile in interface LoadListener

BeginFile

public void BeginFile(LoadEvent event)
Description copied from interface: LoadListener

The loader is starting on a new file.

The event's element attribute contains the name of the file being processed.

The event's filename attribute points to the group of files that contains the current file. For example, the JAR file's name or the root directory of loose files.

The classfile attribute is null.

Specified by:
BeginFile in interface LoadListener

EndClassfile

public void EndClassfile(LoadEvent event)
Description copied from interface: LoadListener

The loader is finished loading a .class file.

The event's classfile attribute contains the newly loaded Classfile instance from the .class file.

The event's filename attribute points to the group of files that contains the current file. For example, the JAR file's name or the root directory of loose files.

The element attribute is null.

Specified by:
EndClassfile in interface LoadListener

EndFile

public void EndFile(LoadEvent event)
Description copied from interface: LoadListener

The loader is finished with a file.

The event's element attribute contains the name of the file being processed.

The event's filename attribute points to the group of files that contains the current file. For example, the JAR file's name or the root directory of loose files.

The event's classfile attribute may contains a newly loaded Classfile instance from the file.

Specified by:
EndFile in interface LoadListener

EndGroup

public void EndGroup(LoadEvent event)
Description copied from interface: LoadListener

The loader finished the group of files. For example, this can be a new JAR file or a collection of loose .class files.

The event's filename attribute points to the source or the group of files, such as the JAR file's name or the root directory of the loose files.

The element and classfile attributes are null.

Specified by:
EndGroup in interface LoadListener

EndSession

public void EndSession(LoadEvent event)
Specified by:
EndSession in interface LoadListener