Package edu.umd.cs.findbugs
Class Plugin
- java.lang.Object
-
- edu.umd.cs.findbugs.Plugin
-
public class Plugin extends java.lang.Object
A FindBugs plugin. A plugin contains executable Detector classes, as well as meta information describing those detectors (such as human-readable detector and bug descriptions).- Author:
- David Hovemeyer
- See Also:
PluginLoader
-
-
Constructor Summary
Constructors Constructor Description Plugin(java.lang.String pluginId, java.lang.String version, java.util.Date releaseDate, PluginLoader pluginLoader, boolean enabled, boolean cannotDisable)
Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addBugCategory(BugCategory bugCategory)
Add a BugCategory reported by the Plugin.void
addBugCode(BugCode bugCode)
Add a BugCode reported by the Plugin.void
addBugPattern(BugPattern bugPattern)
Add a BugPattern reported by the Plugin.static Plugin
addCustomPlugin(java.net.URI u)
static Plugin
addCustomPlugin(java.net.URI u, java.lang.ClassLoader parent)
static Plugin
addCustomPlugin(java.net.URL u)
static Plugin
addCustomPlugin(java.net.URL u, java.lang.ClassLoader parent)
void
addDetectorFactory(DetectorFactory factory)
Add a DetectorFactory for a Detector implemented by the Plugin.void
addInterPassOrderingConstraint(DetectorOrderingConstraint constraint)
Add an inter-pass Detector ordering constraint.void
addIntraPassOrderingConstraint(DetectorOrderingConstraint constraint)
Add an intra-pass Detector ordering constraint.BugCategory
addOrCreateBugCategory(java.lang.String id)
boolean
cannotDisable()
java.util.Collection<FindBugsMain>
getAllFindBugsMain()
static java.util.Collection<java.lang.String>
getAllPluginIds()
static java.util.Collection<Plugin>
getAllPlugins()
static java.util.Map<java.net.URI,Plugin>
getAllPluginsMap()
static java.util.Set<java.net.URI>
getAllPluginsURIs()
java.util.Collection<BugCategory>
getBugCategories()
Get Iterator over BugCategories objects in the Plugin.BugCategory
getBugCategory(java.lang.String id)
java.util.Set<BugCode>
getBugCodes()
Get Iterator over BugCode objects in the Plugin.java.util.Set<BugPattern>
getBugPatterns()
Get the set of BugPatternsBugRanker
getBugRanker()
static Plugin
getByPluginId(java.lang.String name)
java.lang.ClassLoader
getClassLoader()
<T> ComponentPlugin<T>
getComponentPlugin(java.lang.Class<T> componentClass, java.lang.String name)
<T> java.lang.Iterable<ComponentPlugin<T>>
getComponentPlugins(java.lang.Class<T> componentClass)
java.lang.String
getDetailedDescription()
java.util.Collection<DetectorFactory>
getDetectorFactories()
Get Iterator over DetectorFactory objects in the Plugin.java.lang.Class<? extends IAnalysisEngineRegistrar>
getEngineRegistrarClass()
Get the analysis engine registrar class that, when instantiated, can be used to register the plugin's analysis engines with the analysis cache.DetectorFactory
getFactoryByFullName(java.lang.String fullName)
Look up a DetectorFactory by full name.DetectorFactory
getFactoryByShortName(java.lang.String shortName)
Look up a DetectorFactory by short name.FindBugsMain
getFindBugsMain(java.lang.String cmd)
Plugin
getParentPlugin()
java.lang.String
getPluginId()
PluginLoader
getPluginLoader()
java.lang.String
getProvider()
Get the plugin provider.java.util.Date
getReleaseDate()
java.net.URL
getResource(java.lang.String name)
java.lang.String
getShortDescription()
java.lang.String
getShortPluginId()
java.net.URI
getUpdateUrl()
java.lang.String
getVersion()
java.lang.String
getWebsite()
Get the plugin website.java.net.URI
getWebsiteURI()
java.util.Iterator<DetectorOrderingConstraint>
interPassConstraintIterator()
Return an Iterator over the inter-pass Detector ordering constraints.java.util.Iterator<DetectorOrderingConstraint>
intraPassConstraintIterator()
Return an Iterator over the intra-pass Detector ordering constraints.boolean
isCorePlugin()
boolean
isEnabledByDefault()
Return whether or not the Plugin is enabled.boolean
isGloballyEnabled()
boolean
isInitialPlugin()
static Plugin
loadCustomPlugin(java.io.File f, Project project)
Loads the given plugin and enables it for the given project.static Plugin
loadCustomPlugin(java.net.URL urlString, Project project)
Loads the given plugin and enables it for the given project.static void
removeCustomPlugin(Plugin plugin)
static void
removePlugin(java.net.URI uri)
void
setBugRanker(BugRanker ranker)
void
setDetailedDescription(java.lang.String detailedDescription)
void
setEngineRegistrarClass(java.lang.Class<? extends IAnalysisEngineRegistrar> engineRegistrarClass)
Set the analysis engine registrar class that, when instantiated, can be used to register the plugin's analysis engines with the analysis cache.void
setGloballyEnabled(boolean enabled)
void
setMyGlobalOption(java.lang.String key, java.lang.String value)
void
setProvider(java.lang.String provider)
Set plugin provider.void
setShortDescription(java.lang.String shortDescription)
void
setUpdateUrl(java.lang.String url)
void
setWebsite(java.lang.String website)
Set plugin website.java.lang.String
toString()
-
-
-
Constructor Detail
-
Plugin
public Plugin(java.lang.String pluginId, java.lang.String version, java.util.Date releaseDate, @Nonnull PluginLoader pluginLoader, boolean enabled, boolean cannotDisable)
Constructor. Creates an empty plugin object.- Parameters:
pluginId
- the plugin's unique identifier
-
-
Method Detail
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
isEnabledByDefault
public boolean isEnabledByDefault()
Return whether or not the Plugin is enabled.- Returns:
- true if the Plugin is enabled, false if not
-
setProvider
public void setProvider(java.lang.String provider)
Set plugin provider.- Parameters:
provider
- the plugin provider
-
getProvider
@CheckForNull public java.lang.String getProvider()
Get the plugin provider.- Returns:
- the provider, or null if the provider was not specified
-
setUpdateUrl
public void setUpdateUrl(java.lang.String url) throws java.net.URISyntaxException
- Throws:
java.net.URISyntaxException
-
getUpdateUrl
@CheckForNull public java.net.URI getUpdateUrl()
-
setMyGlobalOption
public void setMyGlobalOption(java.lang.String key, java.lang.String value)
-
setWebsite
public void setWebsite(java.lang.String website) throws java.net.URISyntaxException
Set plugin website.- Parameters:
website
- the plugin website- Throws:
java.net.URISyntaxException
-
getWebsite
@CheckForNull public java.lang.String getWebsite()
Get the plugin website.- Returns:
- the website, or null if the was not specified
-
getWebsiteURI
@CheckForNull public java.net.URI getWebsiteURI()
-
getVersion
public java.lang.String getVersion()
-
getReleaseDate
public java.util.Date getReleaseDate()
-
setShortDescription
public void setShortDescription(java.lang.String shortDescription)
-
getShortDescription
public java.lang.String getShortDescription()
-
getDetailedDescription
public java.lang.String getDetailedDescription()
-
setDetailedDescription
public void setDetailedDescription(java.lang.String detailedDescription)
-
addDetectorFactory
public void addDetectorFactory(DetectorFactory factory)
Add a DetectorFactory for a Detector implemented by the Plugin.- Parameters:
factory
- the DetectorFactory
-
addBugPattern
public void addBugPattern(BugPattern bugPattern)
Add a BugPattern reported by the Plugin.- Parameters:
bugPattern
-
-
addBugCode
public void addBugCode(BugCode bugCode)
Add a BugCode reported by the Plugin.- Parameters:
bugCode
-
-
addBugCategory
public void addBugCategory(BugCategory bugCategory)
Add a BugCategory reported by the Plugin.- Parameters:
bugCategory
-
-
addOrCreateBugCategory
public BugCategory addOrCreateBugCategory(java.lang.String id)
-
addInterPassOrderingConstraint
public void addInterPassOrderingConstraint(DetectorOrderingConstraint constraint)
Add an inter-pass Detector ordering constraint.- Parameters:
constraint
- the inter-pass Detector ordering constraint
-
addIntraPassOrderingConstraint
public void addIntraPassOrderingConstraint(DetectorOrderingConstraint constraint)
Add an intra-pass Detector ordering constraint.- Parameters:
constraint
- the intra-pass Detector ordering constraint
-
getFactoryByShortName
public DetectorFactory getFactoryByShortName(java.lang.String shortName)
Look up a DetectorFactory by short name.- Parameters:
shortName
- the short name- Returns:
- the DetectorFactory
-
getFactoryByFullName
public DetectorFactory getFactoryByFullName(java.lang.String fullName)
Look up a DetectorFactory by full name.- Parameters:
fullName
- the full name- Returns:
- the DetectorFactory
-
getDetectorFactories
public java.util.Collection<DetectorFactory> getDetectorFactories()
Get Iterator over DetectorFactory objects in the Plugin.- Returns:
- Iterator over DetectorFactory objects
-
getBugPatterns
public java.util.Set<BugPattern> getBugPatterns()
Get the set of BugPatterns
-
getBugCodes
public java.util.Set<BugCode> getBugCodes()
Get Iterator over BugCode objects in the Plugin.- Returns:
- Iterator over BugCode objects
-
getBugCategories
public java.util.Collection<BugCategory> getBugCategories()
Get Iterator over BugCategories objects in the Plugin.- Returns:
- Iterator over BugCategory objects
-
getBugCategory
@CheckForNull public BugCategory getBugCategory(java.lang.String id)
- Parameters:
id
- may be null- Returns:
- return bug category with given id, may return null if the bug category is unknown
-
interPassConstraintIterator
public java.util.Iterator<DetectorOrderingConstraint> interPassConstraintIterator()
Return an Iterator over the inter-pass Detector ordering constraints.
-
intraPassConstraintIterator
public java.util.Iterator<DetectorOrderingConstraint> intraPassConstraintIterator()
Return an Iterator over the intra-pass Detector ordering constraints.
-
getPluginId
public java.lang.String getPluginId()
-
getShortPluginId
public java.lang.String getShortPluginId()
-
setEngineRegistrarClass
public void setEngineRegistrarClass(java.lang.Class<? extends IAnalysisEngineRegistrar> engineRegistrarClass)
Set the analysis engine registrar class that, when instantiated, can be used to register the plugin's analysis engines with the analysis cache.- Parameters:
engineRegistrarClass
- The engine registrar class to set.
-
getEngineRegistrarClass
public java.lang.Class<? extends IAnalysisEngineRegistrar> getEngineRegistrarClass()
Get the analysis engine registrar class that, when instantiated, can be used to register the plugin's analysis engines with the analysis cache.- Returns:
- Returns the engine registrar class.
-
getPluginLoader
public PluginLoader getPluginLoader()
-
setBugRanker
public void setBugRanker(BugRanker ranker)
-
getBugRanker
public BugRanker getBugRanker()
-
getFindBugsMain
@CheckForNull public FindBugsMain getFindBugsMain(java.lang.String cmd)
-
getAllFindBugsMain
public java.util.Collection<FindBugsMain> getAllFindBugsMain()
-
getComponentPlugins
public <T> java.lang.Iterable<ComponentPlugin<T>> getComponentPlugins(java.lang.Class<T> componentClass)
-
getComponentPlugin
public <T> ComponentPlugin<T> getComponentPlugin(java.lang.Class<T> componentClass, java.lang.String name)
-
getByPluginId
@CheckForNull public static Plugin getByPluginId(java.lang.String name)
-
removePlugin
public static void removePlugin(java.net.URI uri)
-
getAllPlugins
public static java.util.Collection<Plugin> getAllPlugins()
- Returns:
- a copy of the internal plugins collection
-
getAllPluginIds
public static java.util.Collection<java.lang.String> getAllPluginIds()
-
getAllPluginsMap
public static java.util.Map<java.net.URI,Plugin> getAllPluginsMap()
- Returns:
- a copy of the internal plugins collection
-
getAllPluginsURIs
public static java.util.Set<java.net.URI> getAllPluginsURIs()
-
isCorePlugin
public boolean isCorePlugin()
-
cannotDisable
public boolean cannotDisable()
-
isGloballyEnabled
public boolean isGloballyEnabled()
-
setGloballyEnabled
public void setGloballyEnabled(boolean enabled)
-
isInitialPlugin
public boolean isInitialPlugin()
-
getResource
public java.net.URL getResource(java.lang.String name)
-
getClassLoader
public java.lang.ClassLoader getClassLoader()
-
getParentPlugin
@CheckForNull public Plugin getParentPlugin()
-
loadCustomPlugin
public static Plugin loadCustomPlugin(java.io.File f, @CheckForNull Project project) throws PluginException
Loads the given plugin and enables it for the given project.- Parameters:
f
- A non-null jar file of custom plugin.project
- A nullable target project- Throws:
PluginException
-
loadCustomPlugin
public static Plugin loadCustomPlugin(java.net.URL urlString, @CheckForNull Project project) throws PluginException
Loads the given plugin and enables it for the given project.- Throws:
PluginException
-
addCustomPlugin
@CheckForNull public static Plugin addCustomPlugin(java.net.URL u) throws PluginException
- Throws:
PluginException
-
addCustomPlugin
@CheckForNull public static Plugin addCustomPlugin(java.net.URI u) throws PluginException
- Throws:
PluginException
-
addCustomPlugin
@CheckForNull public static Plugin addCustomPlugin(java.net.URL u, java.lang.ClassLoader parent) throws PluginException
- Throws:
PluginException
-
addCustomPlugin
@CheckForNull public static Plugin addCustomPlugin(java.net.URI u, java.lang.ClassLoader parent) throws PluginException
- Throws:
PluginException
-
removeCustomPlugin
public static void removeCustomPlugin(Plugin plugin)
-
-