Class PreorderVisitor

java.lang.Object
edu.umd.cs.findbugs.visitclass.BetterVisitor
edu.umd.cs.findbugs.visitclass.PreorderVisitor
All Implemented Interfaces:
org.apache.bcel.classfile.Visitor
Direct Known Subclasses:
AnnotationVisitor, CallToUnconditionalThrower, CheckImmutableAnnotation, ComparatorIdiom, ConfusedInheritance, DontCatchIllegalMonitorStateException, DroppedException, DuplicateBranches, FindBugsSummaryStats, Methods, Naming, PreorderDetector, RedundantInterfaces, ResolveAllReferences, TrainLongInstantfParams

public class PreorderVisitor extends BetterVisitor

Interface to make the use of a visitor pattern programming style possible. I.e. a class that implements this interface can traverse the contents of a Java class just by calling the `accept' method which all classes have.

Implemented by wish of Boris Bokowski.

If don't like it, blame him. If you do like it thank me 8-)

Version:
970819
Author:
M. Dahm
  • Constructor Details

    • PreorderVisitor

      public PreorderVisitor()
  • Method Details

    • getStringFromIndex

      protected String getStringFromIndex(int i)
    • asUnsignedByte

      protected int asUnsignedByte(byte b)
    • getCode

      public org.apache.bcel.classfile.Code getCode()
      Return the current Code attribute; assuming one is being visited
      Returns:
      current code attribute
    • getSurroundingCaughtExceptions

      public Set<String> getSurroundingCaughtExceptions(int pc)
    • getSurroundingCaughtExceptions

      public Set<String> getSurroundingCaughtExceptions(int pc, int maxTryBlockSize)
    • getSurroundingCaughtExceptionTypes

      public Set<Integer> getSurroundingCaughtExceptionTypes(int pc, int maxTryBlockSize)
    • getSizeOfSurroundingTryBlock

      public int getSizeOfSurroundingTryBlock(int pc)
      Get lines of code in try block that surround pc
      Parameters:
      pc -
      Returns:
      number of lines of code in try block
    • getSizeOfSurroundingTryBlock

      public int getSizeOfSurroundingTryBlock(String vmNameOfExceptionClass, int pc)
      Get lines of code in try block that surround pc
      Parameters:
      pc -
      Returns:
      number of lines of code in try block
    • getSurroundingTryBlock

      public org.apache.bcel.classfile.CodeException getSurroundingTryBlock(int pc)
    • getSurroundingTryBlock

      public org.apache.bcel.classfile.CodeException getSurroundingTryBlock(String vmNameOfExceptionClass, int pc)
    • visitCode

      public void visitCode(org.apache.bcel.classfile.Code obj)
      Specified by:
      visitCode in interface org.apache.bcel.classfile.Visitor
      Overrides:
      visitCode in class BetterVisitor
    • visitAfter

      public void visitAfter(org.apache.bcel.classfile.Code obj)
      Called after visiting a code attribute
      Parameters:
      obj - Code that was just visited
    • visitConstantPool

      public void visitConstantPool(org.apache.bcel.classfile.ConstantPool obj)
      Specified by:
      visitConstantPool in interface org.apache.bcel.classfile.Visitor
      Overrides:
      visitConstantPool in class BetterVisitor
    • doVisitMethod

      public void doVisitMethod(org.apache.bcel.classfile.Method method)
    • amVisitingMainMethod

      public boolean amVisitingMainMethod()
    • visitInnerClasses

      public void visitInnerClasses(org.apache.bcel.classfile.InnerClasses obj)
      Specified by:
      visitInnerClasses in interface org.apache.bcel.classfile.Visitor
      Overrides:
      visitInnerClasses in class BetterVisitor
    • visitAfter

      public void visitAfter(org.apache.bcel.classfile.JavaClass obj)
    • shouldVisit

      public boolean shouldVisit(org.apache.bcel.classfile.JavaClass obj)
    • isVisitMethodsInCallOrder

      protected boolean isVisitMethodsInCallOrder()
    • setVisitMethodsInCallOrder

      protected void setVisitMethodsInCallOrder(boolean visitMethodsInCallOrder)
    • getMethodVisitOrder

      protected Iterable<org.apache.bcel.classfile.Method> getMethodVisitOrder(org.apache.bcel.classfile.JavaClass obj)
    • visitJavaClass

      public void visitJavaClass(org.apache.bcel.classfile.JavaClass obj)
      Specified by:
      visitJavaClass in interface org.apache.bcel.classfile.Visitor
      Overrides:
      visitJavaClass in class BetterVisitor
    • setupVisitorForClass

      public void setupVisitorForClass(org.apache.bcel.classfile.JavaClass obj)
    • visitLineNumberTable

      public void visitLineNumberTable(org.apache.bcel.classfile.LineNumberTable obj)
      Specified by:
      visitLineNumberTable in interface org.apache.bcel.classfile.Visitor
      Overrides:
      visitLineNumberTable in class BetterVisitor
    • visitLocalVariableTable

      public void visitLocalVariableTable(org.apache.bcel.classfile.LocalVariableTable obj)
      Specified by:
      visitLocalVariableTable in interface org.apache.bcel.classfile.Visitor
      Overrides:
      visitLocalVariableTable in class BetterVisitor
    • getXClass

      public XClass getXClass()
    • getClassDescriptor

      public ClassDescriptor getClassDescriptor()
    • getXMethod

      public XMethod getXMethod()
    • getMethodDescriptor

      public MethodDescriptor getMethodDescriptor()
    • getXField

      public XField getXField()
    • getFieldDescriptor

      public FieldDescriptor getFieldDescriptor()
    • getConstantPool

      public org.apache.bcel.classfile.ConstantPool getConstantPool()
      Get the constant pool for the current or most recently visited class
    • getClassName

      @SlashedClassName public String getClassName()
      Get the slash-formatted class name for the current or most recently visited class
    • getDottedClassName

      @DottedClassName public String getDottedClassName()
      Get the dotted class name for the current or most recently visited class
    • getPackageName

      public String getPackageName()
      Get the (slash-formatted?) package name for the current or most recently visited class
    • getSourceFile

      public String getSourceFile()
      Get the source file name for the current or most recently visited class
    • getSuperclassName

      @SlashedClassName public String getSuperclassName()
      Get the slash-formatted superclass name for the current or most recently visited class
    • getDottedSuperclassName

      @DottedClassName public String getDottedSuperclassName()
      Get the dotted superclass name for the current or most recently visited class
    • getThisClass

      public org.apache.bcel.classfile.JavaClass getThisClass()
      Get the JavaClass object for the current or most recently visited class
    • getFullyQualifiedMethodName

      public String getFullyQualifiedMethodName()
      If currently visiting a method, get the method's fully qualified name
    • visitingMethod

      public boolean visitingMethod()
      is the visitor currently visiting a method?
    • visitingField

      public boolean visitingField()
      is the visitor currently visiting a field?
    • getField

      public org.apache.bcel.classfile.Field getField()
      If currently visiting a field, get the field's Field object
    • getMethod

      public org.apache.bcel.classfile.Method getMethod()
      If currently visiting a method, get the method's Method object
    • getMethodName

      public String getMethodName()
      If currently visiting a method, get the method's name
    • getNumberArguments

      public static int getNumberArguments(String signature)
    • hasInterestingMethod

      public static boolean hasInterestingMethod(org.apache.bcel.classfile.ConstantPool cp, Collection<MethodDescriptor> methods)
      Returns true if given constant pool probably has a reference to any of supplied methods Useful to exclude from analysis uninteresting classes
      Parameters:
      cp - constant pool
      methods - methods collection
      Returns:
      true if method is found
    • hasInterestingClass

      public static boolean hasInterestingClass(org.apache.bcel.classfile.ConstantPool cp, Collection<String> classes)
    • getNumberMethodArguments

      public int getNumberMethodArguments()
    • getMethodSig

      public String getMethodSig()
      If currently visiting a method, get the method's slash-formatted signature
    • getDottedMethodSig

      public String getDottedMethodSig()
      If currently visiting a method, get the method's dotted method signature
    • getFieldName

      public String getFieldName()
      If currently visiting a field, get the field's name
    • getFieldSig

      public String getFieldSig()
      If currently visiting a field, get the field's slash-formatted signature
    • getFieldIsStatic

      public boolean getFieldIsStatic()
      If currently visiting a field, return whether or not the field is static
    • getFullyQualifiedFieldName

      public String getFullyQualifiedFieldName()
      If currently visiting a field, get the field's fully qualified name
    • getDottedFieldSig

      @Deprecated public String getDottedFieldSig()
      Deprecated.
      If currently visiting a field, get the field's dot-formatted signature
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • visitAnnotation

      public void visitAnnotation(org.apache.bcel.classfile.Annotations arg0)
    • visitAnnotationDefault

      public void visitAnnotationDefault(org.apache.bcel.classfile.AnnotationDefault arg0)
    • visitAnnotationEntry

      public void visitAnnotationEntry(org.apache.bcel.classfile.AnnotationEntry arg0)
    • visitEnclosingMethod

      public void visitEnclosingMethod(org.apache.bcel.classfile.EnclosingMethod arg0)
    • visitParameterAnnotation

      public void visitParameterAnnotation(org.apache.bcel.classfile.ParameterAnnotations arg0)
    • visitStackMap

      public void visitStackMap(org.apache.bcel.classfile.StackMap arg0)
      Specified by:
      visitStackMap in interface org.apache.bcel.classfile.Visitor
      Overrides:
      visitStackMap in class BetterVisitor
    • visitStackMapEntry

      public void visitStackMapEntry(org.apache.bcel.classfile.StackMapEntry arg0)
      Specified by:
      visitStackMapEntry in interface org.apache.bcel.classfile.Visitor
      Overrides:
      visitStackMapEntry in class BetterVisitor
    • visitConstantInvokeDynamic

      public void visitConstantInvokeDynamic(org.apache.bcel.classfile.ConstantInvokeDynamic obj)
    • visitBootstrapMethods

      public void visitBootstrapMethods(org.apache.bcel.classfile.BootstrapMethods obj)
    • visitMethodParameters

      public void visitMethodParameters(org.apache.bcel.classfile.MethodParameters obj)
    • visitConstantMethodType

      public void visitConstantMethodType(org.apache.bcel.classfile.ConstantMethodType obj)
    • visitConstantMethodHandle

      public void visitConstantMethodHandle(org.apache.bcel.classfile.ConstantMethodHandle obj)
    • visitParameterAnnotationEntry

      public void visitParameterAnnotationEntry(org.apache.bcel.classfile.ParameterAnnotationEntry obj)
    • visitConstantModule

      public void visitConstantModule(org.apache.bcel.classfile.ConstantModule obj)
    • visitConstantPackage

      public void visitConstantPackage(org.apache.bcel.classfile.ConstantPackage obj)