|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.umd.cs.findbugs.BugInstance
public class BugInstance
An instance of a bug pattern. A BugInstance consists of several parts:
BugInstance objects are built up by calling a string of add
methods. (These methods all "return this", so they can be chained).
Some of the add methods are specialized to get information automatically from
a BetterVisitor or DismantleBytecode object.
BugAnnotation
Field Summary | |
---|---|
private static boolean |
adjustExperimental
This value is used to indicate whether BugInstances should be reprioritized very low, when the BugPattern is marked as experimental |
private java.util.ArrayList<BugAnnotation> |
annotationList
|
private java.lang.String |
annotationText
|
private int |
cachedHashCode
|
private static java.lang.String |
ELEMENT_NAME
|
private static int |
INVALID_HASH_CODE
This value is used to indicate that the cached hashcode is invalid, and should be recomputed. |
private ClassAnnotation |
primaryClassAnnotation
|
private FieldAnnotation |
primaryFieldAnnotation
|
private MethodAnnotation |
primaryMethodAnnotation
|
private int |
priority
|
private java.lang.String |
type
|
private static java.lang.String |
USER_ANNOTATION_ELEMENT_NAME
|
Constructor Summary | |
---|---|
BugInstance(Detector detector,
java.lang.String type,
int priority)
Create a new BugInstance. |
|
BugInstance(java.lang.String type,
int priority)
Constructor. |
Method Summary | |
---|---|
(package private) void |
add(BugAnnotation annotation)
|
BugInstance |
addCalledMethod(DismantleBytecode visitor)
Add a method annotation for the method which has been called by the method currently being visited by given visitor. |
BugInstance |
addCalledMethod(org.apache.bcel.generic.MethodGen methodGen,
org.apache.bcel.generic.InvokeInstruction inv)
Add a method annotation for the method which is called by given instruction. |
BugInstance |
addCalledMethod(java.lang.String className,
java.lang.String methodName,
java.lang.String methodSig)
Add a method annotation. |
BugInstance |
addClass(org.apache.bcel.classfile.JavaClass jclass)
Add a class annotation. |
BugInstance |
addClass(PreorderVisitor visitor)
Add a class annotation for the class that the visitor is currently visiting. |
BugInstance |
addClass(java.lang.String className)
Add a class annotation. |
BugInstance |
addClassAndMethod(org.apache.bcel.generic.MethodGen methodGen,
java.lang.String sourceFile)
Add class and method annotations for given method. |
BugInstance |
addClassAndMethod(PreorderVisitor visitor)
Add a class annotation and a method annotation for the class and method which the given visitor is currently visiting. |
BugInstance |
addField(FieldAnnotation fieldAnnotation)
Add a field annotation |
BugInstance |
addField(FieldVariable field)
Add a field annotation for a FieldVariable matched in a ByteCodePattern. |
BugInstance |
addField(java.lang.String className,
java.lang.String fieldName,
java.lang.String fieldSig,
boolean isStatic)
Add a field annotation. |
BugInstance |
addField(XField xfield)
Add a field annotation for an XField. |
BugInstance |
addInt(int value)
Add an integer annotation. |
BugInstance |
addMethod(MethodAnnotation methodAnnotation)
Add a method annotation. |
BugInstance |
addMethod(org.apache.bcel.generic.MethodGen methodGen,
java.lang.String sourceFile)
Add a method annotation. |
BugInstance |
addMethod(PreorderVisitor visitor)
Add a method annotation for the method which the given visitor is currently visiting. |
BugInstance |
addMethod(java.lang.String className,
java.lang.String methodName,
java.lang.String methodSig)
Add a method annotation. |
BugInstance |
addReferencedField(DismantleBytecode visitor)
Add a field annotation for the field which has just been accessed by the method currently being visited by given visitor. |
BugInstance |
addReferencedField(FieldAnnotation fa)
Add a field annotation for the field referenced by the FieldAnnotation parameter |
BugInstance |
addSourceLine(DismantleBytecode visitor)
Add a source line annotation for instruction currently being visited by given visitor. |
BugInstance |
addSourceLine(org.apache.bcel.generic.MethodGen methodGen,
java.lang.String sourceFile,
org.apache.bcel.generic.InstructionHandle handle)
Add a source line annotation for the given instruction in the given method. |
BugInstance |
addSourceLine(org.apache.bcel.generic.MethodGen methodGen,
java.lang.String sourceFile,
org.apache.bcel.generic.InstructionHandle start,
org.apache.bcel.generic.InstructionHandle end)
Add a source line annotation describing a range of instructions. |
BugInstance |
addSourceLine(PreorderVisitor visitor,
int pc)
Add a source line annotation for instruction whose PC is given in the method that the given visitor is currently visiting. |
BugInstance |
addSourceLine(SourceLineAnnotation sourceLine)
Add a source line annotation. |
BugInstance |
addSourceLineRange(PreorderVisitor visitor,
int startPC,
int endPC)
Add a source line annotation describing the source line numbers for a range of instructions in the method being visited by the given visitor. |
private void |
addSourceLinesForMethod(MethodAnnotation methodAnnotation,
SourceLineAnnotation sourceLineAnnotation)
|
BugInstance |
addSuperclass(PreorderVisitor visitor)
Add a class annotation for the superclass of the class the visitor is currently visiting. |
BugInstance |
addUnknownSourceLine(java.lang.String className,
java.lang.String sourceFile)
Add a non-specific source line annotation. |
BugInstance |
addVisitedField(PreorderVisitor visitor)
Add a field annotation for the field which is being visited by given visitor. |
java.util.Iterator<BugAnnotation> |
annotationIterator()
Get an Iterator over all bug annotations. |
boolean |
annotationTextContainsWord(java.lang.String word)
Determine whether or not the annotation text contains the given word. |
int |
compareTo(java.lang.Object o)
|
BugInstance |
describe(java.lang.String description)
Add a description to the most recently added bug annotation. |
boolean |
equals(java.lang.Object o)
|
java.lang.String |
getAbbrev()
Get the abbreviation of this bug instance's BugPattern. |
java.lang.String |
getAnnotationText()
Get the user annotation text. |
BugPattern |
getBugPattern()
Get the BugPattern. |
java.lang.String |
getMessage()
Format a string describing this bug instance. |
ClassAnnotation |
getPrimaryClass()
Get the primary class annotation, which indicates where the bug occurs. |
FieldAnnotation |
getPrimaryField()
Get the primary method annotation, which indicates where the bug occurs. |
MethodAnnotation |
getPrimaryMethod()
Get the primary method annotation, which indicates where the bug occurs. |
SourceLineAnnotation |
getPrimarySourceLineAnnotation()
Get the primary source line annotation. |
int |
getPriority()
Get the bug priority. |
java.util.Set<java.lang.String> |
getTextAnnotationWords()
Get set of words in the text annotation. |
java.lang.String |
getType()
Get the bug type. |
int |
hashCode()
|
boolean |
isExperimental()
Is this bug instance the result of an experimental detector? |
static void |
setAdjustExperimental(boolean adjust)
|
void |
setAnnotationText(java.lang.String annotationText)
Set the user annotation text. |
void |
setPriority(int p)
Set the bug priority. |
java.lang.String |
toString()
Convert to String. |
void |
writeXML(XMLOutput xmlOutput)
Write this object to given XMLOutput. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private java.lang.String type
private int priority
private java.util.ArrayList<BugAnnotation> annotationList
private ClassAnnotation primaryClassAnnotation
private MethodAnnotation primaryMethodAnnotation
private FieldAnnotation primaryFieldAnnotation
private int cachedHashCode
private java.lang.String annotationText
private static final int INVALID_HASH_CODE
private static boolean adjustExperimental
private static final java.lang.String ELEMENT_NAME
private static final java.lang.String USER_ANNOTATION_ELEMENT_NAME
Constructor Detail |
---|
public BugInstance(java.lang.String type, int priority)
type
- the bug typepriority
- the bug prioritypublic BugInstance(Detector detector, java.lang.String type, int priority)
detector
- the Detector that is reporting the BugInstancetype
- the bug typepriority
- the bug priorityMethod Detail |
---|
public static void setAdjustExperimental(boolean adjust)
public java.lang.String getType()
public BugPattern getBugPattern()
public int getPriority()
public void setPriority(int p)
public boolean isExperimental()
public ClassAnnotation getPrimaryClass()
public MethodAnnotation getPrimaryMethod()
public FieldAnnotation getPrimaryField()
public SourceLineAnnotation getPrimarySourceLineAnnotation()
public java.util.Iterator<BugAnnotation> annotationIterator()
public java.lang.String getAbbrev()
public void setAnnotationText(java.lang.String annotationText)
annotationText
- the user annotation textpublic java.lang.String getAnnotationText()
public boolean annotationTextContainsWord(java.lang.String word)
word
- the word
public java.util.Set<java.lang.String> getTextAnnotationWords()
public BugInstance addClassAndMethod(PreorderVisitor visitor)
visitor
- the BetterVisitor
public BugInstance addClassAndMethod(org.apache.bcel.generic.MethodGen methodGen, java.lang.String sourceFile)
methodGen
- the methodsourceFile
- source file the method is defined in
public BugInstance addClass(java.lang.String className)
className
- the name of the class
public BugInstance addClass(org.apache.bcel.classfile.JavaClass jclass)
jclass
- the JavaClass object for the class
public BugInstance addClass(PreorderVisitor visitor)
visitor
- the BetterVisitor
public BugInstance addSuperclass(PreorderVisitor visitor)
visitor
- the BetterVisitor
public BugInstance addField(java.lang.String className, java.lang.String fieldName, java.lang.String fieldSig, boolean isStatic)
className
- name of the class containing the fieldfieldName
- the name of the fieldfieldSig
- type signature of the fieldisStatic
- whether or not the field is static
public BugInstance addField(FieldAnnotation fieldAnnotation)
fieldAnnotation
- the field annotation
public BugInstance addField(FieldVariable field)
field
- the FieldVariable
public BugInstance addField(XField xfield)
xfield
- the XField
public BugInstance addReferencedField(DismantleBytecode visitor)
visitor
- the DismantleBytecode object
public BugInstance addReferencedField(FieldAnnotation fa)
public BugInstance addVisitedField(PreorderVisitor visitor)
visitor
- the visitor
public BugInstance addMethod(java.lang.String className, java.lang.String methodName, java.lang.String methodSig)
className
- name of the class containing the methodmethodName
- name of the methodmethodSig
- type signature of the method
public BugInstance addMethod(org.apache.bcel.generic.MethodGen methodGen, java.lang.String sourceFile)
methodGen
- the MethodGen object for the methodsourceFile
- source file method is defined in
public BugInstance addMethod(PreorderVisitor visitor)
visitor
- the BetterVisitor
public BugInstance addCalledMethod(DismantleBytecode visitor)
visitor
- the DismantleBytecode object
public BugInstance addCalledMethod(java.lang.String className, java.lang.String methodName, java.lang.String methodSig)
public BugInstance addCalledMethod(org.apache.bcel.generic.MethodGen methodGen, org.apache.bcel.generic.InvokeInstruction inv)
methodGen
- the method containing the callinv
- the InvokeInstruction
public BugInstance addMethod(MethodAnnotation methodAnnotation)
methodAnnotation
- the method annotation
public BugInstance addInt(int value)
value
- the integer value
public BugInstance addSourceLine(SourceLineAnnotation sourceLine)
sourceLine
- the source line annotation
public BugInstance addSourceLine(PreorderVisitor visitor, int pc)
visitor
- a BetterVisitor that is currently visiting the methodpc
- bytecode offset of the instruction
public BugInstance addSourceLine(org.apache.bcel.generic.MethodGen methodGen, java.lang.String sourceFile, org.apache.bcel.generic.InstructionHandle handle)
methodGen
- the method being visitedsourceFile
- source file the method is defined inhandle
- the InstructionHandle containing the visited instruction
public BugInstance addSourceLine(org.apache.bcel.generic.MethodGen methodGen, java.lang.String sourceFile, org.apache.bcel.generic.InstructionHandle start, org.apache.bcel.generic.InstructionHandle end)
methodGen
- the methodsourceFile
- source file the method is defined instart
- the start instruction in the rangeend
- the end instruction in the range (inclusive)
public BugInstance addSourceLineRange(PreorderVisitor visitor, int startPC, int endPC)
visitor
- a BetterVisitor which is visiting the methodstartPC
- the bytecode offset of the start instruction in the rangeendPC
- the bytecode offset of the end instruction in the range
public BugInstance addSourceLine(DismantleBytecode visitor)
visitor
- a DismantleBytecode visitor that is currently visiting the instruction
public BugInstance addUnknownSourceLine(java.lang.String className, java.lang.String sourceFile)
className
- the class namesourceFile
- the source file name
public java.lang.String getMessage()
public BugInstance describe(java.lang.String description)
description
- the description to add
public java.lang.String toString()
toString
in class java.lang.Object
public void writeXML(XMLOutput xmlOutput) throws java.io.IOException
XMLWriteable
writeXML
in interface XMLWriteable
xmlOutput
- the XMLOutput for the document
java.io.IOException
void add(BugAnnotation annotation)
private void addSourceLinesForMethod(MethodAnnotation methodAnnotation, SourceLineAnnotation sourceLineAnnotation)
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int compareTo(java.lang.Object o)
compareTo
in interface java.lang.Comparable
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |