edu.umd.cs.findbugs

Class BugInstance

public class BugInstance extends Object implements Comparable<BugInstance>, XMLWriteableWithMessages, Serializable, Cloneable

An instance of a bug pattern. A BugInstance consists of several parts:

The annotations describe classes, methods, fields, source locations, and other relevant context information about the bug instance. Every BugInstance must have at least one ClassAnnotation, which describes the class in which the instance was found. This is the "primary class annotation".

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.

Author: David Hovemeyer

See Also: BugAnnotation

Constructor Summary
BugInstance(String type, int priority)
Constructor.
BugInstance(Detector detector, String type, int priority)
Create a new BugInstance.
BugInstance(Detector2 detector, String type, int priority)
Create a new BugInstance.
Method Summary
BugInstanceadd(BugAnnotation annotation)
BugInstanceaddAnnotations(Collection<? extends BugAnnotation> annotationCollection)
Add a Collection of BugAnnotations.
BugInstanceaddCalledMethod(DismantleBytecode visitor)
Add a method annotation for the method which has been called by the method currently being visited by given visitor.
BugInstanceaddCalledMethod(String className, String methodName, String methodSig, boolean isStatic)
Add a method annotation.
BugInstanceaddCalledMethod(MethodGen methodGen, InvokeInstruction inv)
Add a method annotation for the method which is called by given instruction.
BugInstanceaddClass(String className, String sourceFileName)
Add a class annotation.
BugInstanceaddClass(String className)
Add a class annotation.
BugInstanceaddClass(ClassNode classNode)
Add a class annotation for the classNode.
BugInstanceaddClass(ClassDescriptor classDescriptor)
Add a class annotation.
BugInstanceaddClass(JavaClass jclass)
Add a class annotation.
BugInstanceaddClass(PreorderVisitor visitor)
Add a class annotation for the class that the visitor is currently visiting.
BugInstanceaddClassAndMethod(MethodDescriptor methodDescriptor)
BugInstanceaddClassAndMethod(PreorderVisitor visitor)
Add a class annotation and a method annotation for the class and method which the given visitor is currently visiting.
BugInstanceaddClassAndMethod(MethodAnnotation methodAnnotation)
Add class and method annotations for given method.
BugInstanceaddClassAndMethod(MethodGen methodGen, String sourceFile)
Add class and method annotations for given method.
BugInstanceaddClassAndMethod(JavaClass javaClass, Method method)
Add class and method annotations for given class and method.
BugInstanceaddField(String className, String fieldName, String fieldSig, boolean isStatic)
Add a field annotation.
BugInstanceaddField(String className, String fieldName, String fieldSig, int accessFlags)
Add a field annotation.
BugInstanceaddField(PreorderVisitor visitor)
BugInstanceaddField(FieldAnnotation fieldAnnotation)
Add a field annotation
BugInstanceaddField(FieldVariable field)
Add a field annotation for a FieldVariable matched in a ByteCodePattern.
BugInstanceaddField(XField xfield)
Add a field annotation for an XField.
BugInstanceaddField(FieldDescriptor fieldDescriptor)
Add a field annotation for a FieldDescriptor.
BugInstanceaddFoundAndExpectedType(String foundType, String expectedType)
BugInstanceaddInt(int value)
Add an integer annotation.
BugInstanceaddMethod(String className, String methodName, String methodSig, boolean isStatic)
Add a method annotation.
BugInstanceaddMethod(String className, String methodName, String methodSig, int accessFlags)
Add a method annotation.
BugInstanceaddMethod(MethodGen methodGen, String sourceFile)
Add a method annotation.
BugInstanceaddMethod(JavaClass javaClass, Method method)
Add a method annotation.
BugInstanceaddMethod(JavaClassAndMethod classAndMethod)
Add a method annotation.
BugInstanceaddMethod(PreorderVisitor visitor)
Add a method annotation for the method which the given visitor is currently visiting.
BugInstanceaddMethod(XMethod xmethod)
Add a MethodAnnotation from an XMethod.
BugInstanceaddMethod(MethodAnnotation methodAnnotation)
Add a method annotation.
BugInstanceaddOptionalAnnotation(BugAnnotation annotation)
BugInstanceaddOptionalField(XField xfield)
Add a field annotation for an XField.
BugInstanceaddReferencedField(DismantleBytecode visitor)
Add a field annotation for the field which has just been accessed by the method currently being visited by given visitor.
BugInstanceaddReferencedField(FieldAnnotation fa)
Add a field annotation for the field referenced by the FieldAnnotation parameter
BugInstanceaddSourceLine(SourceLineAnnotation sourceLine)
Add a source line annotation.
BugInstanceaddSourceLine(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.
BugInstanceaddSourceLine(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.
BugInstanceaddSourceLine(ClassContext classContext, MethodGen methodGen, String sourceFile, InstructionHandle handle)
Add a source line annotation for the given instruction in the given method.
BugInstanceaddSourceLine(ClassContext classContext, MethodGen methodGen, String sourceFile, InstructionHandle start, InstructionHandle end)
Add a source line annotation describing a range of instructions.
BugInstanceaddSourceLine(ClassContext classContext, Method method, Location location)
Add source line annotation for given Location in a method.
BugInstanceaddSourceLine(ClassContext classContext, Method method, InstructionHandle handle)
Add source line annotation for given Location in a method.
BugInstanceaddSourceLine(BytecodeScanningDetector visitor)
Add a source line annotation for instruction currently being visited by given visitor.
BugInstanceaddSourceLineRange(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.
BugInstanceaddSourceLineRange(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.
BugInstanceaddString(String value)
Add a String annotation.
BugInstanceaddSuperclass(PreorderVisitor visitor)
Add a class annotation for the superclass of the class the visitor is currently visiting.
BugInstanceaddType(String typeDescriptor)
Add a type annotation.
BugInstanceaddTypeOfNamedClass(String typeName)
BugInstanceaddUnknownSourceLine(String className, String sourceFile)
Add a non-specific source line annotation.
BugInstanceaddVisitedField(PreorderVisitor visitor)
Add a field annotation for the field which is being visited by given visitor.
Iterator<BugAnnotation>annotationIterator()
Get an Iterator over all bug annotations.
booleanannotationTextContainsWord(String word)
Determine whether or not the annotation text contains the given word.
intcompareTo(BugInstance other)
booleandeleteProperty(String name)
Delete property with given name.
BugInstancedescribe(String description)
Add a description to the most recently added bug annotation.
StringgetAbbrev()
Get the abbreviation of this bug instance's BugPattern.
StringgetAbridgedMessage()
StringgetCategoryAbbrev()
longgetFirstVersion()
StringgetInstanceHash()
StringgetInstanceKey()
intgetInstanceOccurrenceMax()
intgetInstanceOccurrenceNum()
longgetLastVersion()
StringgetMessage()
Format a string describing this bug instance.
StringgetMessageWithoutPrefix()
Format a string describing this bug instance.
StringgetMessageWithPriorityType()
Format a string describing this bug pattern, with the priority and type at the beginning. e.g.
StringgetMessageWithPriorityTypeAbbreviation()
ClassAnnotationgetPrimaryClass()
Get the primary class annotation, which indicates where the bug occurs.
FieldAnnotationgetPrimaryField()
Get the primary method annotation, which indicates where the bug occurs.
LocalVariableAnnotationgetPrimaryLocalVariableAnnotation()
MethodAnnotationgetPrimaryMethod()
Get the primary method annotation, which indicates where the bug occurs.
SourceLineAnnotationgetPrimarySourceLineAnnotation()
Get the primary source line annotation.
intgetPriority()
Get the bug priority.
StringgetPriorityAbbreviation()
StringgetPriorityString()
StringgetPriorityTypeAbbreviation()
StringgetPriorityTypeString()
Get a string describing the bug priority and type. e.g.
StringgetProperty(String name)
Get value of given property.
StringgetProperty(String name, String defaultValue)
Get value of given property, returning given default value if the property has not been set.
Set<String>getTextAnnotationWords()
Get set of words in the text annotation.
StringgetType()
Get the bug type.
booleanisExperimental()
Is this bug instance the result of an experimental detector?
booleanisInstanceHashConsistent()
booleanisIntroducedByChangeOfExistingClass()
booleanisRemovedByChangeOfPersistingClass()
BugPropertylookupProperty(String name)
Look up a property by name.
voidlowerPriority()
voidlowerPriorityALot()
BugInstancelowerPriorityIfDeprecated()
Iterator<BugProperty>propertyIterator()
Get an Iterator over the properties defined in this BugInstance.
voidraisePriority()
static voidsetAdjustExperimental(boolean adjust)
voidsetAnnotationText(String annotationText)
Set the user annotation text.
voidsetFirstVersion(long firstVersion)
voidsetInstanceHash(String instanceHash)
voidsetInstanceOccurrenceMax(int instanceOccurrenceMax)
voidsetInstanceOccurrenceNum(int instanceOccurrenceNum)
voidsetIntroducedByChangeOfExistingClass(boolean introducedByChangeOfExistingClass)
voidsetLastVersion(long lastVersion)
voidsetOldInstanceHash(String oldInstanceHash)
voidsetPriority(int p)
Set the bug priority.
BugInstancesetProperty(String name, String value)
Set value of given property.
voidsetRemovedByChangeOfPersistingClass(boolean removedByChangeOfPersistingClass)
voidsetUserDesignation(BugDesignation bd)
set the user designation object.
voidwriteXML(XMLOutput xmlOutput)
voidwriteXML(XMLOutput xmlOutput, boolean addMessages)

Constructor Detail

BugInstance

public BugInstance(String type, int priority)
Constructor.

Parameters: type the bug type priority the bug priority

BugInstance

public BugInstance(Detector detector, String type, int priority)
Create a new BugInstance. This is the constructor that should be used by Detectors.

Parameters: detector the Detector that is reporting the BugInstance type the bug type priority the bug priority

BugInstance

public BugInstance(Detector2 detector, String type, int priority)
Create a new BugInstance. This is the constructor that should be used by Detectors.

Parameters: detector the Detector2 that is reporting the BugInstance type the bug type priority the bug priority

Method Detail

add

public BugInstance add(BugAnnotation annotation)

addAnnotations

public BugInstance addAnnotations(Collection<? extends BugAnnotation> annotationCollection)
Add a Collection of BugAnnotations.

Parameters: annotationCollection Collection of BugAnnotations

addCalledMethod

public BugInstance addCalledMethod(DismantleBytecode visitor)
Add a method annotation for the method which has been called by the method currently being visited by given visitor. Assumes that the visitor has just looked at an invoke instruction of some kind.

Parameters: visitor the DismantleBytecode object

Returns: this object

addCalledMethod

public BugInstance addCalledMethod(String className, String methodName, String methodSig, boolean isStatic)
Add a method annotation.

Parameters: className name of class containing called method methodName name of called method methodSig signature of called method isStatic true if called method is static, false if not

Returns: this object

addCalledMethod

public BugInstance addCalledMethod(MethodGen methodGen, InvokeInstruction inv)
Add a method annotation for the method which is called by given instruction.

Parameters: methodGen the method containing the call inv the InvokeInstruction

Returns: this object

addClass

public BugInstance addClass(String className, String sourceFileName)

Deprecated: use addClass(String) instead

Add a class annotation. If this is the first class annotation added, it becomes the primary class annotation.

Parameters: className the name of the class sourceFileName the source file of the class

Returns: this object

addClass

public BugInstance addClass(String className)
Add a class annotation. If this is the first class annotation added, it becomes the primary class annotation.

Parameters: className the name of the class

Returns: this object

addClass

public BugInstance addClass(ClassNode classNode)
Add a class annotation for the classNode.

Parameters: classNode the ASM visitor

Returns: this object

addClass

public BugInstance addClass(ClassDescriptor classDescriptor)
Add a class annotation. If this is the first class annotation added, it becomes the primary class annotation.

Parameters: classDescriptor the class to add

Returns: this object

addClass

public BugInstance addClass(JavaClass jclass)
Add a class annotation. If this is the first class annotation added, it becomes the primary class annotation.

Parameters: jclass the JavaClass object for the class

Returns: this object

addClass

public BugInstance addClass(PreorderVisitor visitor)
Add a class annotation for the class that the visitor is currently visiting.

Parameters: visitor the BetterVisitor

Returns: this object

addClassAndMethod

public BugInstance addClassAndMethod(MethodDescriptor methodDescriptor)

addClassAndMethod

public BugInstance addClassAndMethod(PreorderVisitor visitor)
Add a class annotation and a method annotation for the class and method which the given visitor is currently visiting.

Parameters: visitor the BetterVisitor

Returns: this object

addClassAndMethod

public BugInstance addClassAndMethod(MethodAnnotation methodAnnotation)
Add class and method annotations for given method.

Parameters: methodAnnotation the method

Returns: this object

addClassAndMethod

public BugInstance addClassAndMethod(MethodGen methodGen, String sourceFile)
Add class and method annotations for given method.

Parameters: methodGen the method sourceFile source file the method is defined in

Returns: this object

addClassAndMethod

public BugInstance addClassAndMethod(JavaClass javaClass, Method method)
Add class and method annotations for given class and method.

Parameters: javaClass the class method the method

Returns: this object

addField

public BugInstance addField(String className, String fieldName, String fieldSig, boolean isStatic)
Add a field annotation.

Parameters: className name of the class containing the field fieldName the name of the field fieldSig type signature of the field isStatic whether or not the field is static

Returns: this object

addField

public BugInstance addField(String className, String fieldName, String fieldSig, int accessFlags)
Add a field annotation.

Parameters: className name of the class containing the field fieldName the name of the field fieldSig type signature of the field isStatic whether or not the field is static

Returns: this object

addField

public BugInstance addField(PreorderVisitor visitor)

addField

public BugInstance addField(FieldAnnotation fieldAnnotation)
Add a field annotation

Parameters: fieldAnnotation the field annotation

Returns: this object

addField

public BugInstance addField(FieldVariable field)
Add a field annotation for a FieldVariable matched in a ByteCodePattern.

Parameters: field the FieldVariable

Returns: this object

addField

public BugInstance addField(XField xfield)
Add a field annotation for an XField.

Parameters: xfield the XField

Returns: this object

addField

public BugInstance addField(FieldDescriptor fieldDescriptor)
Add a field annotation for a FieldDescriptor.

Parameters: fieldDescriptor the FieldDescriptor

Returns: this object

addFoundAndExpectedType

public BugInstance addFoundAndExpectedType(String foundType, String expectedType)

addInt

public BugInstance addInt(int value)
Add an integer annotation.

Parameters: value the integer value

Returns: this object

addMethod

public BugInstance addMethod(String className, String methodName, String methodSig, boolean isStatic)
Add a method annotation. If this is the first method annotation added, it becomes the primary method annotation.

Parameters: className name of the class containing the method methodName name of the method methodSig type signature of the method isStatic true if the method is static, false otherwise

Returns: this object

addMethod

public BugInstance addMethod(String className, String methodName, String methodSig, int accessFlags)
Add a method annotation. If this is the first method annotation added, it becomes the primary method annotation.

Parameters: className name of the class containing the method methodName name of the method methodSig type signature of the method accessFlags accessFlags for the method

Returns: this object

addMethod

public BugInstance addMethod(MethodGen methodGen, String sourceFile)
Add a method annotation. If this is the first method annotation added, it becomes the primary method annotation. If the method has source line information, then a SourceLineAnnotation is added to the method.

Parameters: methodGen the MethodGen object for the method sourceFile source file method is defined in

Returns: this object

addMethod

public BugInstance addMethod(JavaClass javaClass, Method method)
Add a method annotation. If this is the first method annotation added, it becomes the primary method annotation. If the method has source line information, then a SourceLineAnnotation is added to the method.

Parameters: javaClass the class the method is defined in method the method

Returns: this object

addMethod

public BugInstance addMethod(JavaClassAndMethod classAndMethod)
Add a method annotation. If this is the first method annotation added, it becomes the primary method annotation. If the method has source line information, then a SourceLineAnnotation is added to the method.

Parameters: classAndMethod JavaClassAndMethod identifying the method to add

Returns: this object

addMethod

public BugInstance addMethod(PreorderVisitor visitor)
Add a method annotation for the method which the given visitor is currently visiting. If the method has source line information, then a SourceLineAnnotation is added to the method.

Parameters: visitor the BetterVisitor

Returns: this object

addMethod

public BugInstance addMethod(XMethod xmethod)
Add a MethodAnnotation from an XMethod.

Parameters: xmethod the XMethod

Returns: this object

addMethod

public BugInstance addMethod(MethodAnnotation methodAnnotation)
Add a method annotation. If this is the first method annotation added, it becomes the primary method annotation.

Parameters: methodAnnotation the method annotation

Returns: this object

addOptionalAnnotation

public BugInstance addOptionalAnnotation(BugAnnotation annotation)

addOptionalField

public BugInstance addOptionalField(XField xfield)
Add a field annotation for an XField.

Parameters: xfield the XField

Returns: this object

addReferencedField

public 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. Assumes that a getfield/putfield or getstatic/putstatic has just been seen.

Parameters: visitor the DismantleBytecode object

Returns: this object

addReferencedField

public BugInstance addReferencedField(FieldAnnotation fa)
Add a field annotation for the field referenced by the FieldAnnotation parameter

addSourceLine

public BugInstance addSourceLine(SourceLineAnnotation sourceLine)
Add a source line annotation.

Parameters: sourceLine the source line annotation

Returns: this object

addSourceLine

public 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. Note that if the method does not have line number information, then no source line annotation will be added.

Parameters: visitor a BytecodeScanningDetector that is currently visiting the method pc bytecode offset of the instruction

Returns: this object

addSourceLine

public 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. Note that if the method does not have line number information, then no source line annotation will be added.

Parameters: classContext the ClassContext visitor a PreorderVisitor that is currently visiting the method pc bytecode offset of the instruction

Returns: this object

addSourceLine

public BugInstance addSourceLine(ClassContext classContext, MethodGen methodGen, String sourceFile, InstructionHandle handle)
Add a source line annotation for the given instruction in the given method. Note that if the method does not have line number information, then no source line annotation will be added.

Parameters: classContext the ClassContext methodGen the method being visited sourceFile source file the method is defined in handle the InstructionHandle containing the visited instruction

Returns: this object

addSourceLine

public BugInstance addSourceLine(ClassContext classContext, MethodGen methodGen, String sourceFile, InstructionHandle start, InstructionHandle end)
Add a source line annotation describing a range of instructions.

Parameters: classContext the ClassContext methodGen the method sourceFile source file the method is defined in start the start instruction in the range end the end instruction in the range (inclusive)

Returns: this object

addSourceLine

public BugInstance addSourceLine(ClassContext classContext, Method method, Location location)
Add source line annotation for given Location in a method.

Parameters: classContext the ClassContext method the Method location the Location in the method

Returns: this BugInstance

addSourceLine

public BugInstance addSourceLine(ClassContext classContext, Method method, InstructionHandle handle)
Add source line annotation for given Location in a method.

Parameters: classContext the ClassContext method the Method location the Location in the method

Returns: this BugInstance

addSourceLine

public BugInstance addSourceLine(BytecodeScanningDetector visitor)
Add a source line annotation for instruction currently being visited by given visitor. Note that if the method does not have line number information, then no source line annotation will be added.

Parameters: visitor a BytecodeScanningDetector visitor that is currently visiting the instruction

Returns: this object

addSourceLineRange

public 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. Note that if the method does not have line number information, then no source line annotation will be added.

Parameters: visitor a BetterVisitor which is visiting the method startPC the bytecode offset of the start instruction in the range endPC the bytecode offset of the end instruction in the range

Returns: this object

addSourceLineRange

public 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. Note that if the method does not have line number information, then no source line annotation will be added.

Parameters: classContext the ClassContext visitor a BetterVisitor which is visiting the method startPC the bytecode offset of the start instruction in the range endPC the bytecode offset of the end instruction in the range

Returns: this object

addString

public BugInstance addString(String value)
Add a String annotation.

Parameters: value the String value

Returns: this object

addSuperclass

public BugInstance addSuperclass(PreorderVisitor visitor)
Add a class annotation for the superclass of the class the visitor is currently visiting.

Parameters: visitor the BetterVisitor

Returns: this object

addType

public BugInstance addType(String typeDescriptor)
Add a type annotation. Handy for referring to array types.

For information on type descriptors,
see http://java.sun.com/docs/books/vmspec/2nd-edition/html/ClassFile.doc.html#14152
or http://www.murrayc.com/learning/java/java_classfileformat.shtml#TypeDescriptors

Parameters: typeDescriptor a jvm type descriptor, such as "[I"

Returns: this object

addTypeOfNamedClass

public BugInstance addTypeOfNamedClass(String typeName)

addUnknownSourceLine

public BugInstance addUnknownSourceLine(String className, String sourceFile)
Add a non-specific source line annotation. This will result in the entire source file being displayed.

Parameters: className the class name sourceFile the source file name

Returns: this object

addVisitedField

public BugInstance addVisitedField(PreorderVisitor visitor)
Add a field annotation for the field which is being visited by given visitor.

Parameters: visitor the visitor

Returns: this object

annotationIterator

public Iterator<BugAnnotation> annotationIterator()
Get an Iterator over all bug annotations.

annotationTextContainsWord

public boolean annotationTextContainsWord(String word)
Determine whether or not the annotation text contains the given word.

Parameters: word the word

Returns: true if the annotation text contains the word, false otherwise

compareTo

public int compareTo(BugInstance other)

deleteProperty

public boolean deleteProperty(String name)
Delete property with given name.

Parameters: name name of the property to delete

Returns: true if a property with that name was deleted, or false if there is no such property

describe

public BugInstance describe(String description)
Add a description to the most recently added bug annotation.

Parameters: description the description to add

Returns: this object

getAbbrev

public String getAbbrev()
Get the abbreviation of this bug instance's BugPattern. This is the same abbreviation used by the BugCode which the BugPattern is a particular species of.

getAbridgedMessage

public String getAbridgedMessage()

getCategoryAbbrev

public String getCategoryAbbrev()

getFirstVersion

public long getFirstVersion()

Returns: Returns the firstVersion.

getInstanceHash

public String getInstanceHash()

Returns: Returns the instanceHash.

getInstanceKey

public String getInstanceKey()

getInstanceOccurrenceMax

public int getInstanceOccurrenceMax()

Returns: Returns the instanceOccurrenceMax.

getInstanceOccurrenceNum

public int getInstanceOccurrenceNum()

Returns: Returns the instanceOccurrenceNum.

getLastVersion

public long getLastVersion()

Returns: Returns the lastVersion.

getMessage

public String getMessage()
Format a string describing this bug instance.

Returns: the description

getMessageWithoutPrefix

public String getMessageWithoutPrefix()
Format a string describing this bug instance.

Returns: the description

getMessageWithPriorityType

public String getMessageWithPriorityType()
Format a string describing this bug pattern, with the priority and type at the beginning. e.g. "(High Priority Correctness) Guaranteed null pointer dereference..."

getMessageWithPriorityTypeAbbreviation

public String getMessageWithPriorityTypeAbbreviation()

getPrimaryClass

public ClassAnnotation getPrimaryClass()
Get the primary class annotation, which indicates where the bug occurs.

getPrimaryField

public FieldAnnotation getPrimaryField()
Get the primary method annotation, which indicates where the bug occurs.

getPrimaryLocalVariableAnnotation

public LocalVariableAnnotation getPrimaryLocalVariableAnnotation()

getPrimaryMethod

public MethodAnnotation getPrimaryMethod()
Get the primary method annotation, which indicates where the bug occurs.

getPrimarySourceLineAnnotation

public SourceLineAnnotation getPrimarySourceLineAnnotation()
Get the primary source line annotation. There is guaranteed to be one (unless some Detector constructed an invalid BugInstance).

Returns: the source line annotation

getPriority

public int getPriority()
Get the bug priority.

getPriorityAbbreviation

public String getPriorityAbbreviation()

getPriorityString

public String getPriorityString()

getPriorityTypeAbbreviation

public String getPriorityTypeAbbreviation()

getPriorityTypeString

public String getPriorityTypeString()
Get a string describing the bug priority and type. e.g. "High Priority Correctness"

Returns: a string describing the bug priority and type

getProperty

public String getProperty(String name)
Get value of given property.

Parameters: name name of the property to get

Returns: the value of the named property, or null if the property has not been set

getProperty

public String getProperty(String name, String defaultValue)
Get value of given property, returning given default value if the property has not been set.

Parameters: name name of the property to get defaultValue default value to return if propery is not set

Returns: the value of the named property, or the default value if the property has not been set

getTextAnnotationWords

public Set<String> getTextAnnotationWords()
Get set of words in the text annotation.

getType

public String getType()
Get the bug type.

isExperimental

public boolean isExperimental()
Is this bug instance the result of an experimental detector?

isInstanceHashConsistent

public boolean isInstanceHashConsistent()

isIntroducedByChangeOfExistingClass

public boolean isIntroducedByChangeOfExistingClass()

Returns: Returns the introducedByChangeOfExistingClass.

isRemovedByChangeOfPersistingClass

public boolean isRemovedByChangeOfPersistingClass()

Returns: Returns the removedByChangeOfPersistingClass.

lookupProperty

public BugProperty lookupProperty(String name)
Look up a property by name.

Parameters: name name of the property to look for

Returns: the BugProperty with the given name, or null if the property has not been set

lowerPriority

public void lowerPriority()

lowerPriorityALot

public void lowerPriorityALot()

lowerPriorityIfDeprecated

public BugInstance lowerPriorityIfDeprecated()

propertyIterator

public Iterator<BugProperty> propertyIterator()
Get an Iterator over the properties defined in this BugInstance.

Returns: Iterator over properties

raisePriority

public void raisePriority()

setAdjustExperimental

public static void setAdjustExperimental(boolean adjust)

setAnnotationText

public void setAnnotationText(String annotationText)
Set the user annotation text.

Parameters: annotationText the user annotation text

setFirstVersion

public void setFirstVersion(long firstVersion)

Parameters: firstVersion The firstVersion to set.

setInstanceHash

public void setInstanceHash(String instanceHash)

Parameters: instanceHash The instanceHash to set.

setInstanceOccurrenceMax

public void setInstanceOccurrenceMax(int instanceOccurrenceMax)

Parameters: instanceOccurrenceMax The instanceOccurrenceMax to set.

setInstanceOccurrenceNum

public void setInstanceOccurrenceNum(int instanceOccurrenceNum)

Parameters: instanceOccurrenceNum The instanceOccurrenceNum to set.

setIntroducedByChangeOfExistingClass

public void setIntroducedByChangeOfExistingClass(boolean introducedByChangeOfExistingClass)

Parameters: introducedByChangeOfExistingClass The introducedByChangeOfExistingClass to set.

setLastVersion

public void setLastVersion(long lastVersion)

Parameters: lastVersion The lastVersion to set.

setOldInstanceHash

public void setOldInstanceHash(String oldInstanceHash)

Parameters: oldInstanceHash The oldInstanceHash to set.

setPriority

public void setPriority(int p)
Set the bug priority.

setProperty

public BugInstance setProperty(String name, String value)
Set value of given property.

Parameters: name name of the property to set value the value of the property

Returns: this object, so calls can be chained

setRemovedByChangeOfPersistingClass

public void setRemovedByChangeOfPersistingClass(boolean removedByChangeOfPersistingClass)

Parameters: removedByChangeOfPersistingClass The removedByChangeOfPersistingClass to set.

setUserDesignation

public void setUserDesignation(BugDesignation bd)
set the user designation object. This will clobber any existing annotationText (or any other BugDesignation field).

writeXML

public void writeXML(XMLOutput xmlOutput)

writeXML

public void writeXML(XMLOutput xmlOutput, boolean addMessages)
FindBugs™ is licenced under the LGPL. Copyright © 2006 University of Maryland.