edu.umd.cs.findbugs.config
Class ProjectFilterSettings

java.lang.Object
  extended by edu.umd.cs.findbugs.config.ProjectFilterSettings

public class ProjectFilterSettings
extends java.lang.Object

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
private  java.util.Set<java.lang.String> activeBugCategorySet
           
static java.lang.String DEFAULT_PRIORITY
          Default warning threshold priority.
static java.lang.String EXPERIMENTAL_PRIORITY
          Text string for experimental priority.
static java.lang.String HIGH_PRIORITY
          Text string for high priority.
static java.lang.String LOW_PRIORITY
          Text string for low priority.
static java.lang.String MEDIUM_PRIORITY
          Text string for medium priority.
private  java.lang.String minPriority
           
private  int minPriorityAsInt
           
private static java.util.Map<java.lang.String,java.lang.Integer> priorityNameToValueMap
          Map of priority level names to their numeric values.
 
Constructor Summary
private ProjectFilterSettings()
          Constructor.
 
Method Summary
 void addCategory(java.lang.String category)
          Add a bug category to the set of categories to be displayed.
 void clearAllCategories()
          Clear all bug categories.
 boolean containsCategory(java.lang.String category)
          Return whether or not the given category is enabled in the project filter settings.
static ProjectFilterSettings createDefault()
          Factory method to create a default ProjectFilterSettings object.
 boolean displayWarning(BugInstance bugInstance)
          Return whether or not a warning should be displayed, according to the project filter settings.
 boolean equals(java.lang.Object obj)
           
static ProjectFilterSettings fromEncodedString(java.lang.String s)
          Create ProjectFilterSettings from an encoded string.
 java.util.Set<java.lang.String> getActiveCategorySet()
          Return set of active (enabled) bug categories.
static java.lang.String getIntPriorityAsString(int prio)
          Convert an integer warning priority threshold value to a String.
 java.lang.String getMinPriority()
          Get the minimum warning priority threshold.
 int getMinPriorityAsInt()
          Return the minimum warning priority threshold as an integer.
 int hashCode()
           
 void removeCategory(java.lang.String category)
          Remove a bug category from the set of categories to be displayed.
 void setMinPriority(java.lang.String minPriority)
          Set minimum warning priority threshold.
 java.lang.String toEncodedString()
          Create a string containing the encoded form of the ProjectFilterSettings.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

HIGH_PRIORITY

public static final java.lang.String HIGH_PRIORITY
Text string for high priority.

See Also:
Constant Field Values

MEDIUM_PRIORITY

public static final java.lang.String MEDIUM_PRIORITY
Text string for medium priority.

See Also:
Constant Field Values

LOW_PRIORITY

public static final java.lang.String LOW_PRIORITY
Text string for low priority.

See Also:
Constant Field Values

EXPERIMENTAL_PRIORITY

public static final java.lang.String EXPERIMENTAL_PRIORITY
Text string for experimental priority.

See Also:
Constant Field Values

DEFAULT_PRIORITY

public static final java.lang.String DEFAULT_PRIORITY
Default warning threshold priority.

See Also:
Constant Field Values

priorityNameToValueMap

private static java.util.Map<java.lang.String,java.lang.Integer> priorityNameToValueMap
Map of priority level names to their numeric values.


activeBugCategorySet

private java.util.Set<java.lang.String> activeBugCategorySet

minPriority

private java.lang.String minPriority

minPriorityAsInt

private int minPriorityAsInt
Constructor Detail

ProjectFilterSettings

private ProjectFilterSettings()
Constructor. This is not meant to be called directly; use one of the factory methods instead.

Method Detail

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

fromEncodedString

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

Parameters:
s - the encoded string
Returns:
the ProjectFilterSettings

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

setMinPriority

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

Parameters:
value - the priority: one of "High", "Medium", or "Low"

getMinPriority

public java.lang.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

addCategory

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

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

removeCategory

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

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

clearAllCategories

public void clearAllCategories()
Clear all bug categories.


containsCategory

public boolean containsCategory(java.lang.String category)
Return whether or not the given category is enabled in the project filter settings.

Parameters:
category - the category
Returns:
true if the category is enabled, false if not

getActiveCategorySet

public java.util.Set<java.lang.String> getActiveCategorySet()
Return set of active (enabled) bug categories.

Returns:
the set of active categories

toEncodedString

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

Returns:
an encoded string

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

equals

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

hashCode

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

getIntPriorityAsString

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