org.apache.maven.shared.jar.classes
Class ImportVisitor

java.lang.Object
  extended by org.apache.bcel.classfile.EmptyVisitor
      extended by org.apache.maven.shared.jar.classes.ImportVisitor
All Implemented Interfaces:
org.apache.bcel.classfile.Visitor

public class ImportVisitor
extends org.apache.bcel.classfile.EmptyVisitor

Implementation of a BCEL class visitor that analyzes a class and collects imports.


Field Summary
private  java.util.List imports
          The list of imports discovered.
private  org.apache.bcel.classfile.JavaClass javaClass
          The Java class that is being analyzed.
private static java.util.regex.Pattern QUALIFIED_IMPORT_PATTERN
          Pattern to detect if the import is qualified and allows retrieval of the actual import name from the string via the group 1.
private static java.util.regex.Pattern VALID_UTF8_PATTERN
          Pattern that checks whether a string is valid UTF-8.
 
Constructor Summary
ImportVisitor(org.apache.bcel.classfile.JavaClass javaClass)
          Create an Import visitor.
 
Method Summary
 java.util.List getImports()
          Get the list of discovered imports.
 void visitConstantClass(org.apache.bcel.classfile.ConstantClass constantClass)
          Find any formally declared import in the Constant Pool.
 void visitConstantUtf8(org.apache.bcel.classfile.ConstantUtf8 constantUtf8)
          Find any package class Strings in the UTF8 String Pool.
 
Methods inherited from class org.apache.bcel.classfile.EmptyVisitor
visitCode, visitCodeException, visitConstantDouble, visitConstantFieldref, visitConstantFloat, visitConstantInteger, visitConstantInterfaceMethodref, visitConstantLong, visitConstantMethodref, visitConstantNameAndType, visitConstantPool, visitConstantString, visitConstantValue, visitDeprecated, visitExceptionTable, visitField, visitInnerClass, visitInnerClasses, visitJavaClass, visitLineNumber, visitLineNumberTable, visitLocalVariable, visitLocalVariableTable, visitMethod, visitSignature, visitSourceFile, visitStackMap, visitStackMapEntry, visitSynthetic, visitUnknown
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

imports

private java.util.List imports
The list of imports discovered.


javaClass

private org.apache.bcel.classfile.JavaClass javaClass
The Java class that is being analyzed.


QUALIFIED_IMPORT_PATTERN

private static final java.util.regex.Pattern QUALIFIED_IMPORT_PATTERN
Pattern to detect if the import is qualified and allows retrieval of the actual import name from the string via the group 1.


VALID_UTF8_PATTERN

private static final java.util.regex.Pattern VALID_UTF8_PATTERN
Pattern that checks whether a string is valid UTF-8. Imports that are not are ignored.

Constructor Detail

ImportVisitor

public ImportVisitor(org.apache.bcel.classfile.JavaClass javaClass)
Create an Import visitor.

Parameters:
javaClass - the javaclass to work from
Method Detail

getImports

public java.util.List getImports()
Get the list of discovered imports.

Returns:
Returns the imports.

visitConstantClass

public void visitConstantClass(org.apache.bcel.classfile.ConstantClass constantClass)
Find any formally declared import in the Constant Pool.

Specified by:
visitConstantClass in interface org.apache.bcel.classfile.Visitor
Overrides:
visitConstantClass in class org.apache.bcel.classfile.EmptyVisitor
See Also:
EmptyVisitor.visitConstantClass(org.apache.bcel.classfile.ConstantClass)

visitConstantUtf8

public void visitConstantUtf8(org.apache.bcel.classfile.ConstantUtf8 constantUtf8)
Find any package class Strings in the UTF8 String Pool.

Specified by:
visitConstantUtf8 in interface org.apache.bcel.classfile.Visitor
Overrides:
visitConstantUtf8 in class org.apache.bcel.classfile.EmptyVisitor
See Also:
EmptyVisitor.visitConstantUtf8(org.apache.bcel.classfile.ConstantUtf8)