Package edu.umd.cs.findbugs
Class DetectorFactoryCollection
- java.lang.Object
-
- edu.umd.cs.findbugs.DetectorFactoryCollection
-
public class DetectorFactoryCollection extends java.lang.ObjectThe DetectorFactoryCollection stores all of the DetectorFactory objects used to create the Detectors which implement the various analyses. It is a singleton class.- See Also:
DetectorFactory
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Map<java.lang.String,BugCode>bugCodeMapprotected java.util.Map<java.lang.String,BugPattern>bugPatternMapprotected java.util.Map<java.lang.String,BugCategory>categoryDescriptionMapprivate PlugincorePluginprivate static booleanDEBUG_JAWSprivate java.util.Map<java.lang.String,DetectorFactory>factoriesByDetectorClassNameprivate java.util.Map<java.lang.String,DetectorFactory>factoriesByNameprivate java.util.List<DetectorFactory>factoryList(package private) java.util.Map<java.lang.String,java.lang.String>globalOptions(package private) java.util.Map<java.lang.String,Plugin>globalOptionsSetterprivate static java.lang.Objectlockprivate static java.util.logging.LoggerLOGGERprivate java.util.Map<java.lang.String,Plugin>pluginByIdMapprivate static DetectorFactoryCollectiontheInstance
-
Constructor Summary
Constructors Modifier Constructor Description DetectorFactoryCollection()privateDetectorFactoryCollection(boolean loadCore, boolean forceLoad, java.util.Collection<Plugin> pluginsToLoad, java.util.Collection<Plugin> enabledPlugins)DetectorFactoryCollection(Plugin onlyPlugin)protectedDetectorFactoryCollection(java.util.Collection<Plugin> enabled)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Iterator<BugPattern>bugPatternIterator()Get an Iterator over all registered bug patterns.java.util.Iterator<DetectorFactory>factoryIterator()Return an Iterator over the DetectorFactory objects for all registered Detectors.java.util.Collection<java.lang.String>getBugCategories()Get a Collection containing all known bug category keys.BugCategorygetBugCategory(java.lang.String category)Get the BugCategory object for a category key.java.util.Collection<BugCategory>getBugCategoryObjects()BugCodegetBugCode(java.lang.String shortBugType)Get a description for given "bug type".java.util.Collection<BugCode>getBugCodes()java.util.Collection<BugPattern>getBugPatterns()Get an Iterator over all registered bug patterns.PlugingetCorePlugin()static java.net.URLgetCoreResource(java.lang.String name)java.lang.Iterable<DetectorFactory>getFactories()Return an Iterable over the DetectorFactory objects for all registered Detectors.DetectorFactorygetFactory(java.lang.String name)Look up a DetectorFactory by its short name.DetectorFactorygetFactoryByClassName(java.lang.String className)Look up a DetectorFactory by its class name.static java.lang.StringgetFindBugsHome()PlugingetPluginById(java.lang.String pluginId)Get a Plugin by its unique id.private static java.lang.StringinferSpotBugsHome()See if the location of ${spotbugs.home} can be inferred from the location of findbugs.jar in the classpath.static DetectorFactoryCollectioninstance()Get the single instance of DetectorFactoryCollection, which knows each and every loaded plugin, independently of it's enablementbooleanisDisabledByDefault(java.lang.String bugPatternOrCode)static voidjawsDebugMessage(java.lang.String message)private voidloadCorePlugin()(package private) voidloadPlugin(Plugin plugin)BugCodelookupBugCode(java.lang.String shortBugType)BugPatternlookupBugPattern(java.lang.String bugType)Look up bug pattern.java.util.Iterator<Plugin>pluginIterator()Return an Iterator over all available Plugin objects.java.util.Collection<Plugin>plugins()Return an Collection of all available Plugin objects.booleanregisterBugCategory(BugCategory bc)Set the metadata for a bug category.voidregisterBugCode(BugCode bugCode)voidregisterBugPattern(BugPattern bugPattern)Register a BugPattern.(package private) voidregisterDetector(DetectorFactory factory)Register a DetectorFactory.static voidresetInstance(DetectorFactoryCollection instance)Reset the factory singleton.private voidsetGlobalOptions()(package private) voidunLoadPlugin(Plugin plugin)protected booleanunRegisterBugCategory(BugCategory bc)protected voidunRegisterBugCode(BugCode bugCode)protected voidunRegisterBugPattern(BugPattern bugPattern)(package private) voidunRegisterDetector(DetectorFactory factory)
-
-
-
Field Detail
-
LOGGER
private static final java.util.logging.Logger LOGGER
-
DEBUG_JAWS
private static final boolean DEBUG_JAWS
-
theInstance
private static DetectorFactoryCollection theInstance
-
lock
private static final java.lang.Object lock
-
pluginByIdMap
private final java.util.Map<java.lang.String,Plugin> pluginByIdMap
-
corePlugin
private Plugin corePlugin
-
factoryList
private final java.util.List<DetectorFactory> factoryList
-
factoriesByName
private final java.util.Map<java.lang.String,DetectorFactory> factoriesByName
-
factoriesByDetectorClassName
private final java.util.Map<java.lang.String,DetectorFactory> factoriesByDetectorClassName
-
categoryDescriptionMap
protected final java.util.Map<java.lang.String,BugCategory> categoryDescriptionMap
-
bugPatternMap
protected final java.util.Map<java.lang.String,BugPattern> bugPatternMap
-
bugCodeMap
protected final java.util.Map<java.lang.String,BugCode> bugCodeMap
-
globalOptions
final java.util.Map<java.lang.String,java.lang.String> globalOptions
-
globalOptionsSetter
final java.util.Map<java.lang.String,Plugin> globalOptionsSetter
-
-
Method Detail
-
resetInstance
public static void resetInstance(@CheckForNull DetectorFactoryCollection instance)Reset the factory singleton.Implementation note: This method is public for tests only!
- Parameters:
instance- use null to clear the instance
-
instance
public static DetectorFactoryCollection instance()
Get the single instance of DetectorFactoryCollection, which knows each and every loaded plugin, independently of it's enablement
-
setGlobalOptions
private void setGlobalOptions()
-
pluginIterator
public java.util.Iterator<Plugin> pluginIterator()
Return an Iterator over all available Plugin objects.
-
plugins
public java.util.Collection<Plugin> plugins()
Return an Collection of all available Plugin objects.
-
getCorePlugin
@Nonnull public Plugin getCorePlugin()
-
getPluginById
public Plugin getPluginById(java.lang.String pluginId)
Get a Plugin by its unique id.- Parameters:
pluginId- the unique id- Returns:
- the Plugin with that id, or null if no such Plugin is found
-
factoryIterator
public java.util.Iterator<DetectorFactory> factoryIterator()
Return an Iterator over the DetectorFactory objects for all registered Detectors.
-
getFactories
public java.lang.Iterable<DetectorFactory> getFactories()
Return an Iterable over the DetectorFactory objects for all registered Detectors.
-
isDisabledByDefault
public boolean isDisabledByDefault(java.lang.String bugPatternOrCode)
-
getFactory
public DetectorFactory getFactory(java.lang.String name)
Look up a DetectorFactory by its short name.- Parameters:
name- the short name- Returns:
- the DetectorFactory, or null if there is no factory with that short name
-
getFactoryByClassName
public DetectorFactory getFactoryByClassName(java.lang.String className)
Look up a DetectorFactory by its class name.- Parameters:
className- the class name- Returns:
- the DetectoryFactory, or null if there is no factory with that class name
-
registerDetector
void registerDetector(DetectorFactory factory)
Register a DetectorFactory.
-
unRegisterDetector
void unRegisterDetector(DetectorFactory factory)
-
inferSpotBugsHome
private static java.lang.String inferSpotBugsHome()
See if the location of ${spotbugs.home} can be inferred from the location of findbugs.jar in the classpath.- Returns:
- inferred ${spotbugs.home}, or null if we can't figure it out
-
getFindBugsHome
public static java.lang.String getFindBugsHome()
-
getCoreResource
@CheckForNull public static java.net.URL getCoreResource(java.lang.String name)
-
loadCorePlugin
private void loadCorePlugin()
-
jawsDebugMessage
public static void jawsDebugMessage(java.lang.String message)
-
loadPlugin
void loadPlugin(Plugin plugin)
-
unLoadPlugin
void unLoadPlugin(Plugin plugin)
-
registerBugCategory
public boolean registerBugCategory(BugCategory bc)
Set the metadata for a bug category. If the category's metadata has already been set, this does nothing.- Parameters:
bc- the BugCategory object holding the metadata for the category- Returns:
- false if the category's metadata has already been set, true otherwise
-
unRegisterBugCategory
protected boolean unRegisterBugCategory(BugCategory bc)
-
registerBugPattern
public void registerBugPattern(BugPattern bugPattern)
Register a BugPattern.- Parameters:
bugPattern- the BugPattern
-
unRegisterBugPattern
protected void unRegisterBugPattern(BugPattern bugPattern)
-
bugPatternIterator
public java.util.Iterator<BugPattern> bugPatternIterator()
Get an Iterator over all registered bug patterns.
-
getBugPatterns
public java.util.Collection<BugPattern> getBugPatterns()
Get an Iterator over all registered bug patterns.
-
lookupBugPattern
@CheckForNull public BugPattern lookupBugPattern(java.lang.String bugType)
Look up bug pattern.- Parameters:
bugType- the bug type for the bug pattern- Returns:
- the BugPattern, or null if it can't be found
-
registerBugCode
public void registerBugCode(BugCode bugCode)
-
unRegisterBugCode
protected void unRegisterBugCode(BugCode bugCode)
-
getBugCodes
public java.util.Collection<BugCode> getBugCodes()
-
getBugCode
@Nonnull public BugCode getBugCode(java.lang.String shortBugType)
Get a description for given "bug type". FIXME: this is referred to elsewhere as the "bug code" or "bug abbrev". Should make the terminology consistent everywhere. In this case, the bug type refers to the short prefix code prepended to the long and short bug messages.- Parameters:
shortBugType- the short bug type code- Returns:
- the description of that short bug type code means
-
lookupBugCode
@CheckForNull public BugCode lookupBugCode(java.lang.String shortBugType)
- Parameters:
shortBugType- the short bug type code- Returns:
- the description of that short bug type code means
-
getBugCategory
public BugCategory getBugCategory(java.lang.String category)
Get the BugCategory object for a category key. Returns null if no BugCategory object can be found.- Parameters:
category- the category key- Returns:
- the BugCategory object (may be null)
-
getBugCategories
public java.util.Collection<java.lang.String> getBugCategories()
Get a Collection containing all known bug category keys. E.g., "CORRECTNESS", "MT_CORRECTNESS", "PERFORMANCE", etc. Excludes hidden bug categories- Returns:
- Collection of bug category keys.
-
getBugCategoryObjects
public java.util.Collection<BugCategory> getBugCategoryObjects()
-
-