edu.umd.cs.findbugs
Class MethodAnnotation

java.lang.Object
  extended by edu.umd.cs.findbugs.PackageMemberAnnotation
      extended by edu.umd.cs.findbugs.MethodAnnotation
All Implemented Interfaces:
BugAnnotation, XMLWriteable, java.lang.Comparable<BugAnnotation>

public class MethodAnnotation
extends PackageMemberAnnotation

A BugAnnotation specifying a particular method in a particular class. A MethodAnnotation may (optionally) have a SourceLineAnnotation directly embedded inside it to indicate the range of source lines where the method is defined.

Author:
David Hovemeyer
See Also:
BugAnnotation

Field Summary
private static java.lang.String DEFAULT_ROLE
           
private static java.lang.String ELEMENT_NAME
           
private  java.lang.String fullMethod
           
private  java.lang.String methodName
           
private  java.lang.String methodSig
           
private  SourceLineAnnotation sourceLines
           
private static boolean UGLY_METHODS
           
 
Fields inherited from class edu.umd.cs.findbugs.PackageMemberAnnotation
className, description
 
Constructor Summary
MethodAnnotation(java.lang.String className, java.lang.String methodName, java.lang.String methodSig)
          Constructor.
 
Method Summary
 void accept(BugAnnotationVisitor visitor)
          Accept a BugAnnotationVisitor.
 int compareTo(BugAnnotation o)
           
 boolean equals(java.lang.Object o)
           
protected  java.lang.String formatPackageMember(java.lang.String key)
          Do default and subclass-specific formatting.
static MethodAnnotation fromVisitedMethod(PreorderVisitor visitor)
          Factory method to create a MethodAnnotation from the method the given visitor is currently visiting.
 java.lang.String getFullMethod()
          Get the "full" method name.
 java.lang.String getMethodName()
          Get the method name.
 java.lang.String getMethodSignature()
          Get the method type signature.
 SourceLineAnnotation getSourceLines()
          Get the SourceLineAnnotation describing the source lines where the method is defined.
private  java.lang.String getUglyMethod()
           
 int hashCode()
           
 void setSourceLines(SourceLineAnnotation sourceLines)
          Set a SourceLineAnnotation describing the source lines where the method is defined.
 void writeXML(XMLOutput xmlOutput)
          Write this object to given XMLOutput.
 
Methods inherited from class edu.umd.cs.findbugs.PackageMemberAnnotation
format, getClassName, getDescription, getPackageName, setDescription, shorten, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

UGLY_METHODS

private static final boolean UGLY_METHODS

DEFAULT_ROLE

private static final java.lang.String DEFAULT_ROLE
See Also:
Constant Field Values

methodName

private java.lang.String methodName

methodSig

private java.lang.String methodSig

fullMethod

private java.lang.String fullMethod

sourceLines

private SourceLineAnnotation sourceLines

ELEMENT_NAME

private static final java.lang.String ELEMENT_NAME
See Also:
Constant Field Values
Constructor Detail

MethodAnnotation

public MethodAnnotation(java.lang.String className,
                        java.lang.String methodName,
                        java.lang.String methodSig)
Constructor.

Parameters:
className - the name of the class containing the method
methodName - the name of the method
methodSig - the Java type signature of the method
Method Detail

fromVisitedMethod

public static MethodAnnotation fromVisitedMethod(PreorderVisitor visitor)
Factory method to create a MethodAnnotation from the method the given visitor is currently visiting.

Parameters:
visitor - the BetterVisitor currently visiting the method

getMethodName

public java.lang.String getMethodName()
Get the method name.


getMethodSignature

public java.lang.String getMethodSignature()
Get the method type signature.


setSourceLines

public void setSourceLines(SourceLineAnnotation sourceLines)
Set a SourceLineAnnotation describing the source lines where the method 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 method

accept

public void accept(BugAnnotationVisitor visitor)
Description copied from interface: BugAnnotation
Accept a BugAnnotationVisitor.

Parameters:
visitor - the visitor to accept

formatPackageMember

protected java.lang.String formatPackageMember(java.lang.String key)
Description copied from class: PackageMemberAnnotation
Do default and subclass-specific formatting.

Specified by:
formatPackageMember in class PackageMemberAnnotation
Parameters:
key - the key specifying how to do the formatting

getFullMethod

public java.lang.String getFullMethod()
Get the "full" method name. This is a format which looks sort of like a method signature that would appear in Java source code.


getUglyMethod

private java.lang.String getUglyMethod()

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

compareTo

public int compareTo(BugAnnotation o)

writeXML

public void writeXML(XMLOutput xmlOutput)
              throws java.io.IOException
Description copied from interface: XMLWriteable
Write this object to given XMLOutput.

Parameters:
xmlOutput - the XMLOutput for the document
Throws:
java.io.IOException