edu.umd.cs.findbugs.config

Class ProjectFilterSettings

public class ProjectFilterSettings extends Object implements Cloneable

Settings for user filtering of warnings for a project. This includes selecting particular bug categories to view, as well as a minimum warning priority. Includes support for encoding these settings as a String, which can easily be stored as a persistent project property in Eclipse.

Author: David Hovemeyer

See Also: BugInstance

Field Summary
static StringDEFAULT_PRIORITY
Default warning threshold priority.
static StringEXPERIMENTAL_PRIORITY
Text string for experimental priority.
static StringHIGH_PRIORITY
Text string for high priority.
static StringLOW_PRIORITY
Text string for low priority.
static StringMEDIUM_PRIORITY
Text string for medium priority.
Method Summary
voidaddCategory(String category)
Add a bug category to the set of categories to be displayed.
voidclearAllCategories()
Clear all bug categories from the hidden list.
booleancontainsCategory(String category)
Returns false if the given category is hidden in the project filter settings.
static ProjectFilterSettingscreateDefault()
Factory method to create a default ProjectFilterSettings object.
booleandisplayFalseWarnings()
Get whether or not false warnings should be displayed.
booleandisplayWarning(BugInstance bugInstance)
Return whether or not a warning should be displayed, according to the project filter settings.
static ProjectFilterSettingsfromEncodedString(String s)
Create ProjectFilterSettings from an encoded string.
Set<String>getActiveCategorySet()
Return set of active (enabled) bug categories.
static StringgetIntPriorityAsString(int prio)
Convert an integer warning priority threshold value to a String.
StringgetMinPriority()
Get the minimum warning priority threshold.
intgetMinPriorityAsInt()
Return the minimum warning priority threshold as an integer.
static voidhiddenFromEncodedString(ProjectFilterSettings result, String s)
set the hidden bug categories on the specifed ProjectFilterSettings from an encoded string
StringhiddenToEncodedString()
Create a string containing the encoded form of the hidden bug categories
voidremoveCategory(String category)
Remove a bug category from the set of categories to be displayed.
voidsetDisplayFalseWarnings(boolean displayFalseWarnings)
Set whether or not false warnings should be displayed.
voidsetMinPriority(String minPriority)
Set minimum warning priority threshold.
StringtoEncodedString()
Create a string containing the encoded form of the ProjectFilterSettings.

Field Detail

DEFAULT_PRIORITY

public static final String DEFAULT_PRIORITY
Default warning threshold priority.

EXPERIMENTAL_PRIORITY

public static final String EXPERIMENTAL_PRIORITY
Text string for experimental priority.

HIGH_PRIORITY

public static final String HIGH_PRIORITY
Text string for high priority.

LOW_PRIORITY

public static final String LOW_PRIORITY
Text string for low priority.

MEDIUM_PRIORITY

public static final String MEDIUM_PRIORITY
Text string for medium priority.

Method Detail

addCategory

public void addCategory(String category)
Add a bug category to the set of categories to be displayed.

Parameters: category the bug category: e.g., "CORRECTNESS"

clearAllCategories

public void clearAllCategories()
Clear all bug categories from the hidden list. So the effect is to enable all bug categories.

containsCategory

public boolean containsCategory(String category)
Returns false if the given category is hidden in the project filter settings.

Parameters: category the category

Returns: false if the category is hidden, true if not

createDefault

public static ProjectFilterSettings createDefault()
Factory method to create a default ProjectFilterSettings object. Uses the default warning priority threshold, and enables all bug categories.

Returns: a default ProjectFilterSettings object

displayFalseWarnings

public boolean displayFalseWarnings()
Get whether or not false warnings should be displayed.

Returns: true if false warnings should be displayed, false if not

displayWarning

public boolean displayWarning(BugInstance bugInstance)
Return whether or not a warning should be displayed, according to the project filter settings.

Parameters: bugInstance the warning

Returns: true if the warning should be displayed, false if not

fromEncodedString

public static ProjectFilterSettings fromEncodedString(String s)
Create ProjectFilterSettings from an encoded string.

Parameters: s the encoded string

Returns: the ProjectFilterSettings

getActiveCategorySet

public Set<String> getActiveCategorySet()
Return set of active (enabled) bug categories. Note that bug categories that are not explicity hidden will appear active even if they are not members of this set.

Returns: the set of active categories

getIntPriorityAsString

public static String getIntPriorityAsString(int prio)
Convert an integer warning priority threshold value to a String.

getMinPriority

public String getMinPriority()
Get the minimum warning priority threshold.

Returns: minimum warning priority threshold: one of "High", "Medium", or "Low"

getMinPriorityAsInt

public int getMinPriorityAsInt()
Return the minimum warning priority threshold as an integer.

Returns: the minimum warning priority threshold as an integer

hiddenFromEncodedString

public static void hiddenFromEncodedString(ProjectFilterSettings result, String s)
set the hidden bug categories on the specifed ProjectFilterSettings from an encoded string

Parameters: result the ProjectFilterSettings from which to remove bug categories s the encoded string

See Also: ProjectFilterSettings

hiddenToEncodedString

public String hiddenToEncodedString()
Create a string containing the encoded form of the hidden bug categories

Returns: an encoded string

removeCategory

public void removeCategory(String category)
Remove a bug category from the set of categories to be displayed.

Parameters: category the bug category: e.g., "CORRECTNESS"

setDisplayFalseWarnings

public void setDisplayFalseWarnings(boolean displayFalseWarnings)
Set whether or not false warnings should be displayed.

Parameters: displayFalseWarnings true if false warnings should be displayed, false if not

setMinPriority

public void setMinPriority(String minPriority)
Set minimum warning priority threshold.

Parameters: minPriority the priority threshold: one of "High", "Medium", or "Low"

toEncodedString

public String toEncodedString()
Create a string containing the encoded form of the ProjectFilterSettings.

Returns: an encoded string

FindBugs™ is licenced under the LGPL. Copyright © 2006 University of Maryland.