edu.umd.cs.findbugs
Class PackageMemberAnnotation

java.lang.Object
  extended by 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 java.lang.Object
implements BugAnnotation

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
protected  java.lang.String className
           
protected  java.lang.String description
           
protected  java.lang.String sourceFileName
           
protected  SourceLineAnnotation sourceLines
           
 
Fields inherited from interface edu.umd.cs.findbugs.BugAnnotation
MESSAGE_TAG
 
Constructor Summary
protected PackageMemberAnnotation(java.lang.String className, java.lang.String description)
          Constructor.
 
Method Summary
 java.lang.Object clone()
           
 java.lang.String format(java.lang.String key)
          Format the annotation.
protected abstract  java.lang.String formatPackageMember(java.lang.String key)
          Do default and subclass-specific formatting.
 java.lang.String getClassName()
          Get the class name.
 java.lang.String getDescription()
          Get a description of this bug annotation.
 java.lang.String getPackageName()
          Get the package name.
 java.lang.String getSourceFileName()
          Get the source file name.
 SourceLineAnnotation getSourceLines()
          Get the SourceLineAnnotation describing the source lines where the method is defined.
 void setDescription(java.lang.String description)
          Set a description of this bug annotation.
 void setSourceLines(SourceLineAnnotation sourceLines)
          Set a SourceLineAnnotation describing the source lines where the package element is defined.
protected static java.lang.String shorten(java.lang.String pkgName, java.lang.String typeName)
          Shorten a type name of remove extraneous components.
 java.lang.String toString()
          All PackageMemberAnnotation object share a common toString() implementation.
 
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 java.lang.Comparable
compareTo
 
Methods inherited from interface edu.umd.cs.findbugs.XMLWriteableWithMessages
writeXML
 
Methods inherited from interface edu.umd.cs.findbugs.xml.XMLWriteable
writeXML
 

Field Detail

className

protected java.lang.String className

sourceFileName

protected java.lang.String sourceFileName

description

protected java.lang.String description

sourceLines

protected SourceLineAnnotation sourceLines
Constructor Detail

PackageMemberAnnotation

protected PackageMemberAnnotation(java.lang.String className,
                                  java.lang.String description)
Constructor.

Parameters:
className - name of the class
Method Detail

clone

public java.lang.Object clone()
Specified by:
clone in interface BugAnnotation
Overrides:
clone in class java.lang.Object

getSourceFileName

public final java.lang.String getSourceFileName()
Get the source file name.


getClassName

public final java.lang.String getClassName()
Get the class name.


getPackageName

public final java.lang.String getPackageName()
Get the package name.


format

public final java.lang.String format(java.lang.String key)
Format the annotation. Note that this version (defined by PackageMemberAnnotation) only handles the "class" and "package" keys, and calls formatPackageMember() for all other keys.

Specified by:
format in interface BugAnnotation
Parameters:
key - the key
Returns:
the formatted annotation

setDescription

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

Specified by:
setDescription in interface BugAnnotation

getDescription

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

Specified by:
getDescription in interface BugAnnotation

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 the java.lang package.


formatPackageMember

protected abstract java.lang.String formatPackageMember(java.lang.String key)
Do default and subclass-specific formatting.

Parameters:
key - the key specifying how to do the formatting

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:
toString in class java.lang.Object

setSourceLines

public void setSourceLines(SourceLineAnnotation sourceLines)
Set a SourceLineAnnotation describing the source lines where the package element is defined.


getSourceLines

public SourceLineAnnotation getSourceLines()
Get the SourceLineAnnotation describing the source lines where the method is defined.

Returns:
the SourceLineAnnotation, or null if there is no source information for this package element