Package edu.umd.cs.findbugs
Class PackageMemberAnnotation
- java.lang.Object
-
- edu.umd.cs.findbugs.BugAnnotationWithSourceLines
-
- edu.umd.cs.findbugs.PackageMemberAnnotation
-
- All Implemented Interfaces:
BugAnnotation,XMLWriteable,XMLWriteableWithMessages,java.io.Serializable,java.lang.Cloneable,java.lang.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:
BugAnnotation, Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.StringclassNameprotected java.lang.Stringdescription-
Fields inherited from class edu.umd.cs.findbugs.BugAnnotationWithSourceLines
sourceFileName, sourceLines
-
Fields inherited from interface edu.umd.cs.findbugs.BugAnnotation
MESSAGE_TAG
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedPackageMemberAnnotation(java.lang.String className, java.lang.String description)Constructor.protectedPackageMemberAnnotation(java.lang.String className, java.lang.String description, java.lang.String sourceFileName)Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description java.lang.Stringformat(java.lang.String key, ClassAnnotation primaryClass)Format the annotation.protected abstract java.lang.StringformatPackageMember(java.lang.String key, ClassAnnotation primaryClass)Do default and subclass-specific formatting.ClassDescriptorgetClassDescriptor()Get the class descriptor.java.lang.StringgetClassName()Get the dotted class name.java.lang.StringgetDescription()Get a description of this bug annotation.java.lang.StringgetPackageName()Get the package name.java.lang.StringgetSimpleClassName()java.lang.StringgetSlashedClassName()Get the dotted class name.booleanisSignificant()Is this annotation used to compute instance hashes or match bug instances across versionsprotected static java.lang.StringremovePackage(java.lang.String typeName)protected static java.lang.StringremovePackageName(java.lang.String typeName)Shorten a type name by removing the package namevoidsetDescription(java.lang.String description)Set a description of this bug annotation.protected static java.lang.Stringshorten(java.lang.String pkgName, java.lang.String typeName)Shorten a type name of remove extraneous components.java.lang.StringtoString()All PackageMemberAnnotation object share a common toString() implementation.java.lang.StringtoString(ClassAnnotation primaryClass)-
Methods inherited from class edu.umd.cs.findbugs.BugAnnotationWithSourceLines
clone, getSourceFileName, getSourceLines, setSourceLines
-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface edu.umd.cs.findbugs.BugAnnotation
accept
-
Methods inherited from interface edu.umd.cs.findbugs.xml.XMLWriteable
writeXML
-
Methods inherited from interface edu.umd.cs.findbugs.XMLWriteableWithMessages
writeXML
-
-
-
-
Field Detail
-
className
@DottedClassName protected final java.lang.String className
-
description
protected java.lang.String description
-
-
Constructor Detail
-
PackageMemberAnnotation
protected PackageMemberAnnotation(@DottedClassName java.lang.String className, java.lang.String description)
Constructor.- Parameters:
className- name of the class
-
PackageMemberAnnotation
protected PackageMemberAnnotation(@DottedClassName java.lang.String className, java.lang.String description, java.lang.String sourceFileName)
Constructor.- Parameters:
className- name of the class
-
-
Method Detail
-
getClassName
@DottedClassName public final java.lang.String getClassName()
Get the dotted class name.
-
getSlashedClassName
@SlashedClassName public final java.lang.String getSlashedClassName()
Get the dotted class name.
-
getSimpleClassName
public java.lang.String getSimpleClassName()
-
getClassDescriptor
public final ClassDescriptor getClassDescriptor()
Get the class descriptor.
-
getPackageName
@DottedClassName public final java.lang.String getPackageName()
Get the package name.
-
format
public final java.lang.String format(java.lang.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 keyprimaryClass- 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(java.lang.String description)
Description copied from interface:BugAnnotationSet a description of this bug annotation. The description is a key for the FindBugsAnnotationDescriptions resource bundle.
-
getDescription
public java.lang.String getDescription()
Description copied from interface:BugAnnotationGet a description of this bug annotation. The description is a key for the FindBugsAnnotationDescriptions resource bundle.
-
shorten
protected static java.lang.String shorten(java.lang.String pkgName, java.lang.String typeName)Shorten a type name of remove extraneous components. Candidates for shortening are classes in same package as this annotation and classes in thejava.langpackage.
-
removePackage
protected static java.lang.String removePackage(java.lang.String typeName)
-
removePackageName
protected static java.lang.String removePackageName(java.lang.String typeName)
Shorten a type name by removing the package name
-
formatPackageMember
protected abstract java.lang.String formatPackageMember(java.lang.String key, ClassAnnotation primaryClass)Do default and subclass-specific formatting.- Parameters:
key- the key specifying how to do the formattingprimaryClass- TODO
-
toString
public java.lang.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:
toStringin classjava.lang.Object
-
toString
public java.lang.String toString(ClassAnnotation primaryClass)
- Specified by:
toStringin interfaceBugAnnotation- Overrides:
toStringin classBugAnnotationWithSourceLines
-
isSignificant
public boolean isSignificant()
Description copied from interface:BugAnnotationIs this annotation used to compute instance hashes or match bug instances across versions- Returns:
- true if significant
-
-