|
||||||||||
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
,
Serialized FormConstructor Summary | |
---|---|
BugInstance(Detector detector,
java.lang.String type,
int priority)
Create a new BugInstance. |
|
BugInstance(java.lang.String type,
int priority)
Constructor. |
Method Summary | |
---|---|
BugInstance |
add(BugAnnotation annotation)
|
BugInstance |
addAnnotations(java.util.Collection<? extends BugAnnotation> annotationCollection)
Add a Collection of BugAnnotations. |
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,
boolean isStatic)
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, but look up the source file name from the class name (using currentAnalysisContext) |
BugInstance |
addClass(java.lang.String className,
java.lang.String sourceFileName)
Add a class annotation. |
BugInstance |
addClassAndMethod(org.apache.bcel.classfile.JavaClass javaClass,
org.apache.bcel.classfile.Method method)
Add class and method annotations for given class and method. |
BugInstance |
addClassAndMethod(MethodAnnotation methodAnnotation)
Add class and method annotations for given method. |
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(JavaClassAndMethod classAndMethod)
Add a method annotation. |
BugInstance |
addMethod(org.apache.bcel.classfile.JavaClass javaClass,
org.apache.bcel.classfile.Method method)
Add a method 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,
boolean isStatic)
Add a method annotation. |
BugInstance |
addMethod(XMethod xmethod)
Add a MethodAnnotation from an XMethod. |
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(BytecodeScanningDetector visitor)
Add a source line annotation for instruction currently being visited by given visitor. |
BugInstance |
addSourceLine(BytecodeScanningDetector 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(ClassContext classContext,
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(ClassContext classContext,
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(ClassContext classContext,
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(BytecodeScanningDetector 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. |
BugInstance |
addSourceLineRange(ClassContext classContext,
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. |
BugInstance |
addString(java.lang.String value)
Add a String annotation. |
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. |
java.lang.Object |
clone()
|
int |
compareTo(BugInstance other)
|
boolean |
deleteProperty(java.lang.String name)
Delete property with given name. |
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. |
long |
getFirstVersion()
|
java.lang.String |
getInstanceHash()
|
java.lang.String |
getInstanceKey()
|
int |
getInstanceOccurrenceMax()
|
int |
getInstanceOccurrenceNum()
|
long |
getLastVersion()
|
java.lang.String |
getMessage()
Format a string describing this bug instance. |
java.lang.String |
getMessageWithoutPrefix()
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.lang.String |
getProperty(java.lang.String name)
Get value of given property. |
java.lang.String |
getProperty(java.lang.String name,
java.lang.String defaultValue)
Get value of given property, returning given default value if the property has not been set. |
java.util.Set<java.lang.String> |
getTextAnnotationWords()
Get set of words in the text annotation. |
java.lang.String |
getType()
Get the bug type. |
java.lang.String |
getUniqueId()
Get the BugInstance's unique id. |
int |
hashCode()
|
boolean |
isExperimental()
Is this bug instance the result of an experimental detector? |
boolean |
isIntroducedByChangeOfExistingClass()
|
boolean |
isRemovedByChangeOfPersistingClass()
|
BugProperty |
lookupProperty(java.lang.String name)
Look up a property by name. |
java.util.Iterator<BugProperty> |
propertyIterator()
Get an Iterator over the properties defined in this BugInstance. |
static void |
setAdjustExperimental(boolean adjust)
|
void |
setAnnotationText(java.lang.String annotationText)
Set the user annotation text. |
void |
setFirstVersion(long firstVersion)
|
void |
setInstanceHash(java.lang.String instanceHash)
|
void |
setInstanceOccurrenceMax(int instanceOccurrenceMax)
|
void |
setInstanceOccurrenceNum(int instanceOccurrenceNum)
|
void |
setIntroducedByChangeOfExistingClass(boolean introducedByChangeOfExistingClass)
|
void |
setLastVersion(long lastVersion)
|
void |
setPriority(int p)
Set the bug priority. |
BugInstance |
setProperty(java.lang.String name,
java.lang.String value)
Set value of given property. |
void |
setRemovedByChangeOfPersistingClass(boolean removedByChangeOfPersistingClass)
|
void |
setUniqueId(java.lang.String uniqueId)
Set the unique id of the BugInstance. |
java.lang.String |
toString()
Convert to String. |
void |
writeXML(XMLOutput xmlOutput)
Write this object to given XMLOutput. |
void |
writeXML(XMLOutput xmlOutput,
boolean addMessages)
|
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
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 java.lang.Object clone()
clone
in class java.lang.Object
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.lang.String getInstanceKey()
public java.util.Iterator<BugAnnotation> annotationIterator()
public java.lang.String getAbbrev()
public void setAnnotationText(@NonNull java.lang.String annotationText)
annotationText
- the user annotation text@NonNull public java.lang.String getAnnotationText()
public boolean annotationTextContainsWord(java.lang.String word)
word
- the word
public java.util.Set<java.lang.String> getTextAnnotationWords()
public java.lang.String getUniqueId()
public void setUniqueId(java.lang.String uniqueId)
uniqueId
- the unique idpublic java.lang.String getProperty(java.lang.String name)
name
- name of the property to get
public java.lang.String getProperty(java.lang.String name, java.lang.String defaultValue)
name
- name of the property to getdefaultValue
- default value to return if propery is not set
public java.util.Iterator<BugProperty> propertyIterator()
public BugInstance setProperty(java.lang.String name, java.lang.String value)
name
- name of the property to setvalue
- the value of the property
public BugProperty lookupProperty(java.lang.String name)
name
- name of the property to look for
public boolean deleteProperty(java.lang.String name)
name
- name of the property to delete
public BugInstance addAnnotations(java.util.Collection<? extends BugAnnotation> annotationCollection)
annotationCollection
- Collection of BugAnnotationspublic BugInstance addClassAndMethod(PreorderVisitor visitor)
visitor
- the BetterVisitor
public BugInstance addClassAndMethod(MethodAnnotation methodAnnotation)
methodAnnotation
- the method
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 addClassAndMethod(org.apache.bcel.classfile.JavaClass javaClass, org.apache.bcel.classfile.Method method)
javaClass
- the classmethod
- the method
public BugInstance addClass(java.lang.String className, java.lang.String sourceFileName)
className
- the name of the classsourceFileName
- the source file of the class
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, boolean isStatic)
className
- name of the class containing the methodmethodName
- name of the methodmethodSig
- type signature of the methodisStatic
- true if the method is static, false otherwise
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(org.apache.bcel.classfile.JavaClass javaClass, org.apache.bcel.classfile.Method method)
javaClass
- the class the method is defined inmethod
- the method
public BugInstance addMethod(JavaClassAndMethod classAndMethod)
classAndMethod
- JavaClassAndMethod identifying the method to add
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, boolean isStatic)
className
- name of class containing called methodmethodName
- name of called methodmethodSig
- signature of called methodisStatic
- true if called method is static, false if not
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(XMethod xmethod)
xmethod
- the XMethod
public BugInstance addMethod(MethodAnnotation methodAnnotation)
methodAnnotation
- the method annotation
public BugInstance addInt(int value)
value
- the integer value
public BugInstance addString(java.lang.String value)
value
- the String value
public BugInstance addSourceLine(SourceLineAnnotation sourceLine)
sourceLine
- the source line annotation
public BugInstance addSourceLine(BytecodeScanningDetector visitor, int pc)
visitor
- a BytecodeScanningDetector that is currently visiting the methodpc
- bytecode offset of the instruction
public BugInstance addSourceLine(ClassContext classContext, PreorderVisitor visitor, int pc)
classContext
- the ClassContextvisitor
- a PreorderVisitor that is currently visiting the methodpc
- bytecode offset of the instruction
public BugInstance addSourceLine(ClassContext classContext, org.apache.bcel.generic.MethodGen methodGen, java.lang.String sourceFile, @NonNull org.apache.bcel.generic.InstructionHandle handle)
classContext
- the ClassContextmethodGen
- the method being visitedsourceFile
- source file the method is defined inhandle
- the InstructionHandle containing the visited instruction
public BugInstance addSourceLine(ClassContext classContext, org.apache.bcel.generic.MethodGen methodGen, java.lang.String sourceFile, org.apache.bcel.generic.InstructionHandle start, org.apache.bcel.generic.InstructionHandle end)
classContext
- the ClassContextmethodGen
- 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(BytecodeScanningDetector 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 addSourceLineRange(ClassContext classContext, PreorderVisitor visitor, int startPC, int endPC)
classContext
- the ClassContextvisitor
- 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(BytecodeScanningDetector visitor)
visitor
- a BytecodeScanningDetector 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 getMessageWithoutPrefix()
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
public void writeXML(XMLOutput xmlOutput, boolean addMessages) throws java.io.IOException
writeXML
in interface XMLWriteableWithMessages
java.io.IOException
public BugInstance add(BugAnnotation annotation)
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(BugInstance other)
compareTo
in interface java.lang.Comparable<BugInstance>
public void setFirstVersion(long firstVersion)
firstVersion
- The firstVersion to set.public long getFirstVersion()
public void setLastVersion(long lastVersion)
lastVersion
- The lastVersion to set.public long getLastVersion()
public void setIntroducedByChangeOfExistingClass(boolean introducedByChangeOfExistingClass)
introducedByChangeOfExistingClass
- The introducedByChangeOfExistingClass to set.public boolean isIntroducedByChangeOfExistingClass()
public void setRemovedByChangeOfPersistingClass(boolean removedByChangeOfPersistingClass)
removedByChangeOfPersistingClass
- The removedByChangeOfPersistingClass to set.public boolean isRemovedByChangeOfPersistingClass()
public void setInstanceHash(java.lang.String instanceHash)
instanceHash
- The instanceHash to set.public java.lang.String getInstanceHash()
public void setInstanceOccurrenceNum(int instanceOccurrenceNum)
instanceOccurrenceNum
- The instanceOccurrenceNum to set.public int getInstanceOccurrenceNum()
public void setInstanceOccurrenceMax(int instanceOccurrenceMax)
instanceOccurrenceMax
- The instanceOccurrenceMax to set.public int getInstanceOccurrenceMax()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |