Class PackageMemberAnnotation

java.lang.Object
edu.umd.cs.findbugs.BugAnnotationWithSourceLines
edu.umd.cs.findbugs.PackageMemberAnnotation
All Implemented Interfaces:
BugAnnotation, XMLWriteable, XMLWriteableWithMessages, Serializable, Cloneable, Comparable<BugAnnotation>
Direct Known Subclasses:
ClassAnnotation, FieldAnnotation, MethodAnnotation

public abstract class PackageMemberAnnotation extends BugAnnotationWithSourceLines
Abstract base class for BugAnnotations describing constructs which are contained in a Java package. Specifically, this includes classes, methods, and fields.
Author:
David Hovemeyer
See Also:
  • Field Details

  • Constructor Details

    • PackageMemberAnnotation

      protected PackageMemberAnnotation(@DottedClassName String className, String description)
      Constructor.
      Parameters:
      className - name of the class
    • PackageMemberAnnotation

      protected PackageMemberAnnotation(@DottedClassName String className, String description, String sourceFileName)
      Constructor.
      Parameters:
      className - name of the class
  • Method Details

    • getClassName

      @DottedClassName public final String getClassName()
      Get the dotted class name.
    • getSlashedClassName

      @SlashedClassName public final String getSlashedClassName()
      Get the dotted class name.
    • getSimpleClassName

      public String getSimpleClassName()
    • getClassDescriptor

      public final ClassDescriptor getClassDescriptor()
      Get the class descriptor.
    • getPackageName

      @DottedClassName public final String getPackageName()
      Get the package name.
    • format

      public final String format(String key, ClassAnnotation primaryClass)
      Format the annotation. Note that this version (defined by PackageMemberAnnotation) only handles the "class" and "package" keys, and calls formatPackageMember() for all other keys.
      Parameters:
      key - the key
      primaryClass - The primary class for the bug; some bug annotation format msgs are simplified in relation to that class.
      Returns:
      the formatted annotation
    • setDescription

      public void setDescription(String description)
      Description copied from interface: BugAnnotation
      Set a description of this bug annotation. The description is a key for the FindBugsAnnotationDescriptions resource bundle.
    • getDescription

      public String getDescription()
      Description copied from interface: BugAnnotation
      Get a description of this bug annotation. The description is a key for the FindBugsAnnotationDescriptions resource bundle.
    • getJavaAnnotationNames

      public List<String> getJavaAnnotationNames()
      Returns:
      the javaAnnotationNames
    • setJavaAnnotationNames

      public void setJavaAnnotationNames(List<String> aJavaAnnotationNames)
      Parameters:
      aJavaAnnotationNames - the javaAnnotationNames to set
    • shorten

      protected static String shorten(String pkgName, String typeName)
      Shorten a type name of remove extraneous components. Candidates for shortening are classes in same package as this annotation and classes in the java.lang package.
    • removePackage

      protected static String removePackage(String typeName)
    • removePackageName

      protected static String removePackageName(String typeName)
      Shorten a type name by removing the package name
    • formatPackageMember

      protected abstract String formatPackageMember(String key, ClassAnnotation primaryClass)
      Do default and subclass-specific formatting.
      Parameters:
      key - the key specifying how to do the formatting
      primaryClass - TODO
    • toString

      public String toString()
      All PackageMemberAnnotation object share a common toString() implementation. It uses the annotation description as a pattern for FindBugsMessageFormat, passing a reference to this object as the single message parameter.
      Overrides:
      toString in class Object
    • toString

      public String toString(ClassAnnotation primaryClass)
      Specified by:
      toString in interface BugAnnotation
      Overrides:
      toString in class BugAnnotationWithSourceLines
    • isSignificant

      public boolean isSignificant()
      Description copied from interface: BugAnnotation
      Is this annotation used to compute instance hashes or match bug instances across versions
      Returns:
      true if significant