org.sonar.api.rules
Class RulesManager

java.lang.Object
  extended by org.sonar.api.rules.RulesManager
All Implemented Interfaces:
BatchExtension, Extension

public class RulesManager
extends Object
implements BatchExtension

A class to manage and access rules defined in Sonar


Constructor Summary
protected RulesManager(DaoFacade dao)
          Constructor for tests only
  RulesManager(Plugins plugins, RulesRepository[] repositories, DaoFacade dao)
          Creates a RuleManager
 
Method Summary
 Map<String,Long> countRulesByCategory(Language language)
          Gets count of rules by categories defined for a given language
protected  Map<String,Long> countRulesByCategory(Language language, RulesDao rulesDao)
           
 List<Plugin> getExportablePlugins(Language language)
          Get the list of rules plugin that implement a mechanism of export for a given language
 List<Plugin> getImportablePlugins(Language language)
          Get the list of rules plugin that implement a mechanism of import for a given language
 Set<Language> getLanguages()
          Returns the list of languages for which there is a rule repository
 Rule getPluginRule(String pluginKey, String ruleKey)
          Gets a rule belonging to a defined plugin based on its key
 Collection<Rule> getPluginRules(String pluginKey)
          Gets a collection of rules belonging to a plugin
 Map<String,Rule> getPluginRulesIndexedByKey(String pluginKey)
          Gets a list of rules indexed by their key for a given plugin
 List<Plugin> getPlugins(Language language)
          Gets the list of rules plugins for a given language
 List<RulesRepository<?>> getRulesRepositories()
          Gets the complete list of Rules Repositories in the Sonar instance
 List<RulesRepository<?>> getRulesRepositories(Language language)
          Gets the list of Rules Repositories available for a language
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RulesManager

public RulesManager(Plugins plugins,
                    RulesRepository[] repositories,
                    DaoFacade dao)
Creates a RuleManager

Parameters:
plugins - the plugins dictionnary
repositories - the repositories of rules
dao - the dao object

RulesManager

protected RulesManager(DaoFacade dao)
Constructor for tests only

Parameters:
dao - the dao
Method Detail

getLanguages

public Set<Language> getLanguages()
Returns the list of languages for which there is a rule repository

Returns:
a Set of languages

getRulesRepositories

public List<RulesRepository<?>> getRulesRepositories(Language language)
Gets the list of Rules Repositories available for a language

Parameters:
language - the language
Returns:
the list of rules repositories

getRulesRepositories

public List<RulesRepository<?>> getRulesRepositories()
Gets the complete list of Rules Repositories in the Sonar instance

Returns:
the list of rules repositories

getPlugins

public List<Plugin> getPlugins(Language language)
Gets the list of rules plugins for a given language

Parameters:
language - the language
Returns:
the list of plugins

countRulesByCategory

public Map<String,Long> countRulesByCategory(Language language)
Gets count of rules by categories defined for a given language

Parameters:
language - the language
Returns:
a Map with the category as key and the count as value

countRulesByCategory

protected Map<String,Long> countRulesByCategory(Language language,
                                                RulesDao rulesDao)

getExportablePlugins

public List<Plugin> getExportablePlugins(Language language)
Get the list of rules plugin that implement a mechanism of export for a given language

Parameters:
language - the language
Returns:
the list of plugins

getImportablePlugins

public List<Plugin> getImportablePlugins(Language language)
Get the list of rules plugin that implement a mechanism of import for a given language

Parameters:
language - the language
Returns:
the list of plugins

getPluginRulesIndexedByKey

public Map<String,Rule> getPluginRulesIndexedByKey(String pluginKey)
Gets a list of rules indexed by their key for a given plugin

Parameters:
pluginKey - the plugin key
Returns:
a Map with the rule key and the rule

getPluginRules

public Collection<Rule> getPluginRules(String pluginKey)
Gets a collection of rules belonging to a plugin

Parameters:
pluginKey - the plugin key
Returns:
the collection of rules

getPluginRule

public Rule getPluginRule(String pluginKey,
                          String ruleKey)
Gets a rule belonging to a defined plugin based on its key

Parameters:
pluginKey - the plugin key
ruleKey - the rule key
Returns:
the rule


Copyright © 2009-2010 SonarSource SA. All Rights Reserved.