Package edu.umd.cs.findbugs
Class DetectorFactory
- java.lang.Object
-
- edu.umd.cs.findbugs.DetectorFactory
-
public class DetectorFactory extends java.lang.Object
A DetectorFactory is responsible for creating instances of Detector objects and for maintaining meta-information about the detector class.- See Also:
Detector
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
DetectorFactory.ReflectionDetectorCreator
-
Field Summary
Fields Modifier and Type Field Description private java.lang.String
className
private static java.lang.Class<?>[]
constructorArgTypes
private static boolean
DEBUG_JAVA_VERSION
private boolean
defEnabled
private java.lang.String
detailHTML
private DetectorFactory.ReflectionDetectorCreator
detectorCreator
private boolean
enabledButNonReporting
private boolean
hidden
private Plugin
plugin
private int
positionSpecifiedInPluginDescriptor
private static int
PRIME
private int
priorityAdjustment
private java.lang.String
reports
private java.lang.String
requireJRE
private java.lang.String
speed
Deprecated.This attribute is not used actively, and could be removed in future releaseprivate static boolean
SUPPORT_OLD_DETECTOR_INTERFACE
-
Constructor Summary
Constructors Constructor Description DetectorFactory(Plugin plugin, java.lang.String className, java.lang.Class<?> detectorClass, boolean enabled, java.lang.String speed, java.lang.String reports, java.lang.String requireJRE)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description private void
checkForNoAnalysis()
Detector
create(BugReporter bugReporter)
Deprecated.Use createDetector2 in new codeDetector2
createDetector2(BugReporter bugReporter)
Create a Detector2 instance.boolean
equals(java.lang.Object obj)
java.lang.String
getDetailHTML()
Get an HTML document describing the Detector.java.lang.String
getFullName()
Get the full name of the detector.Plugin
getPlugin()
Get the Plugin that this Detector is part of.int
getPositionSpecifiedInPluginDescriptor()
Get the overall position in which this detector was specified in the plugin descriptor.int
getPriorityAdjustment()
Get the priority adjustment for the detector produced by this factory.java.lang.String
getReportedBugPatternCodes()
Get list of bug pattern codes reported by the detector: empty if unknown.java.util.Set<BugPattern>
getReportedBugPatterns()
Get set of all BugPatterns this detector reports.java.lang.String
getShortName()
Get the short name of the Detector.java.lang.String
getSpeed()
Deprecated.This attribute is not used actively, and could be removed in future releaseint
hashCode()
boolean
isDefaultEnabled()
Is this factory enabled by defaultboolean
isDetectorClassSubtypeOf(java.lang.Class<?> otherClass)
Determine whether the detector class is a subtype of the given class (or interface).boolean
isEnabledForCurrentJRE()
Check to see if we are running on a recent-enough JRE for this detector to be enabled.boolean
isHidden()
Get visibility of the factory (to GUI dialogs to configure detectors).boolean
isReportingDetector()
Return whether or not this DetectorFactory produces detectors which report warnings.void
setDetailHTML(java.lang.String detailHTML)
Set the HTML document describing the Detector.void
setEnabledButNonReporting(boolean notReporting)
void
setHidden(boolean hidden)
Set visibility of the factory (to GUI dialogs to configure detectors).void
setPositionSpecifiedInPluginDescriptor(int positionSpecifiedInPluginDescriptor)
Set the overall position in which this detector was specified in the plugin descriptor.void
setPriorityAdjustment(int priorityAdjustment)
Set the priority adjustment for the detector produced by this factory.java.lang.String
toString()
-
-
-
Field Detail
-
PRIME
private static final int PRIME
- See Also:
- Constant Field Values
-
DEBUG_JAVA_VERSION
private static final boolean DEBUG_JAVA_VERSION
-
SUPPORT_OLD_DETECTOR_INTERFACE
private static final boolean SUPPORT_OLD_DETECTOR_INTERFACE
-
constructorArgTypes
private static final java.lang.Class<?>[] constructorArgTypes
-
plugin
@Nonnull private final Plugin plugin
-
detectorCreator
private final DetectorFactory.ReflectionDetectorCreator detectorCreator
-
className
@Nonnull @DottedClassName private final java.lang.String className
-
positionSpecifiedInPluginDescriptor
private int positionSpecifiedInPluginDescriptor
-
defEnabled
private final boolean defEnabled
-
speed
@Deprecated private final java.lang.String speed
Deprecated.This attribute is not used actively, and could be removed in future release
-
reports
private final java.lang.String reports
-
requireJRE
private final java.lang.String requireJRE
-
detailHTML
private java.lang.String detailHTML
-
priorityAdjustment
private int priorityAdjustment
-
enabledButNonReporting
private boolean enabledButNonReporting
-
hidden
private boolean hidden
-
-
Constructor Detail
-
DetectorFactory
public DetectorFactory(@Nonnull Plugin plugin, @Nonnull java.lang.String className, java.lang.Class<?> detectorClass, boolean enabled, java.lang.String speed, java.lang.String reports, java.lang.String requireJRE)
Constructor.- Parameters:
plugin
- the Plugin the Detector is part ofclassName
- TODOdetectorClass
- the Class object of the Detectorenabled
- true if the Detector is enabled by default, false if disabledspeed
- a string describing roughly how expensive the analysis performed by the detector is; suggested values are "fast", "moderate", and "slow"reports
- comma separated list of bug pattern codes reported by the detector; empty if unknownrequireJRE
- string describing JRE version required to run the detector: e.g., "1.5"
-
-
Method Detail
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
setPositionSpecifiedInPluginDescriptor
public void setPositionSpecifiedInPluginDescriptor(int positionSpecifiedInPluginDescriptor)
Set the overall position in which this detector was specified in the plugin descriptor.- Parameters:
positionSpecifiedInPluginDescriptor
- position in plugin descriptor
-
getPositionSpecifiedInPluginDescriptor
public int getPositionSpecifiedInPluginDescriptor()
Get the overall position in which this detector was specified in the plugin descriptor.- Returns:
- position in plugin descriptor
-
getPlugin
public Plugin getPlugin()
Get the Plugin that this Detector is part of.- Returns:
- the Plugin this Detector is part of
-
isDetectorClassSubtypeOf
public boolean isDetectorClassSubtypeOf(java.lang.Class<?> otherClass)
Determine whether the detector class is a subtype of the given class (or interface).- Parameters:
otherClass
- a class or interface- Returns:
- true if the detector class is a subtype of the given class or interface
-
isReportingDetector
public boolean isReportingDetector()
Return whether or not this DetectorFactory produces detectors which report warnings.- Returns:
- true if the created Detectors report warnings, false if not
-
isEnabledForCurrentJRE
public boolean isEnabledForCurrentJRE()
Check to see if we are running on a recent-enough JRE for this detector to be enabled.- Returns:
- true if the current JRE is recent enough to run the Detector, false if it is too old
-
setHidden
public void setHidden(boolean hidden)
Set visibility of the factory (to GUI dialogs to configure detectors). Invisible detectors are those that are needed behind the scenes, but shouldn't be explicitly enabled or disabled by the user.- Parameters:
hidden
- true if this factory should be hidden, false if not
-
isHidden
public boolean isHidden()
Get visibility of the factory (to GUI dialogs to configure detectors).
-
isDefaultEnabled
public boolean isDefaultEnabled()
Is this factory enabled by default
-
setPriorityAdjustment
public void setPriorityAdjustment(int priorityAdjustment)
Set the priority adjustment for the detector produced by this factory.- Parameters:
priorityAdjustment
- the priority adjustment
-
setEnabledButNonReporting
public void setEnabledButNonReporting(boolean notReporting)
-
getPriorityAdjustment
public int getPriorityAdjustment()
Get the priority adjustment for the detector produced by this factory.- Returns:
- the priority adjustment
-
getSpeed
@Deprecated public java.lang.String getSpeed()
Deprecated.This attribute is not used actively, and could be removed in future releaseGet the speed of the Detector produced by this factory.
-
getReportedBugPatternCodes
public java.lang.String getReportedBugPatternCodes()
Get list of bug pattern codes reported by the detector: empty if unknown.
-
getReportedBugPatterns
public java.util.Set<BugPattern> getReportedBugPatterns()
Get set of all BugPatterns this detector reports. An empty set means that we don't know what kind of bug patterns might be reported.
-
getDetailHTML
public java.lang.String getDetailHTML()
Get an HTML document describing the Detector.
-
setDetailHTML
public void setDetailHTML(java.lang.String detailHTML)
Set the HTML document describing the Detector.
-
create
@Deprecated public Detector create(BugReporter bugReporter)
Deprecated.Use createDetector2 in new codeCreate a Detector instance. This method is only guaranteed to work for old-style detectors using the BCEL bytecode framework.- Parameters:
bugReporter
- the BugReporter to be used to report bugs- Returns:
- the Detector
-
createDetector2
public Detector2 createDetector2(BugReporter bugReporter)
Create a Detector2 instance.- Parameters:
bugReporter
- the BugReporter to be used to report bugs- Returns:
- the Detector2
-
getShortName
public java.lang.String getShortName()
Get the short name of the Detector. This is the name of the detector class without the package qualification.
-
checkForNoAnalysis
private void checkForNoAnalysis()
-
getFullName
@Nonnull @DottedClassName public java.lang.String getFullName()
Get the full name of the detector. This is the name of the detector class, with package qualification.
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
-