001 /*
002 * Sonar, open source software quality management tool.
003 * Copyright (C) 2009 SonarSource SA
004 * mailto:contact AT sonarsource DOT com
005 *
006 * Sonar is free software; you can redistribute it and/or
007 * modify it under the terms of the GNU Lesser General Public
008 * License as published by the Free Software Foundation; either
009 * version 3 of the License, or (at your option) any later version.
010 *
011 * Sonar is distributed in the hope that it will be useful,
012 * but WITHOUT ANY WARRANTY; without even the implied warranty of
013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014 * Lesser General Public License for more details.
015 *
016 * You should have received a copy of the GNU Lesser General Public
017 * License along with Sonar; if not, write to the Free Software
018 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
019 */
020 package org.sonar.api.rules;
021
022 import org.sonar.api.Plugin;
023 import org.sonar.api.resources.Language;
024
025 import java.util.Collection;
026 import java.util.List;
027 import java.util.Map;
028 import java.util.Set;
029
030 /**
031 * Manage and access rules defined in Sonar.
032 *
033 * @deprecated UGLY COMPONENT - WILL BE COMPLETELY REFACTORED IN SONAR 2.3
034 */
035 @Deprecated
036 public abstract class RulesManager {
037
038 /**
039 * Returns the list of languages for which there is a rule repository
040 *
041 * @return a Set of languages
042 */
043 public abstract Set<Language> getLanguages();
044
045 /**
046 * Gets the list of Rules Repositories available for a language
047 *
048 * @param language the language
049 * @return the list of rules repositories
050 */
051 public abstract List<RulesRepository<?>> getRulesRepositories(Language language);
052
053 /**
054 * Gets the complete list of Rules Repositories in the Sonar instance
055 *
056 * @return the list of rules repositories
057 */
058 public abstract List<RulesRepository<?>> getRulesRepositories();
059
060 /**
061 * Gets the list of rules plugins for a given language
062 * @param language the language
063 * @return the list of plugins
064 */
065 public abstract List<Plugin> getPlugins(Language language);
066
067 /**
068 * Gets count of rules by categories defined for a given language
069 *
070 * @param language the language
071 * @return a Map with the category as key and the count as value
072 */
073 public abstract Map<String, Long> countRulesByCategory(Language language);
074
075
076 /**
077 * Get the list of rules plugin that implement a mechanism of export for a given language
078 *
079 * @param language the language
080 * @return the list of plugins
081 */
082 public abstract List<Plugin> getExportablePlugins(Language language);
083 /**
084 * Get the list of rules plugin that implement a mechanism of import for a given language
085 *
086 * @param language the language
087 * @return the list of plugins
088 */
089 public abstract List<Plugin> getImportablePlugins(Language language);
090
091 /**
092 * Gets a list of rules indexed by their key for a given plugin
093 * @param pluginKey the plugin key
094 * @return a Map with the rule key and the rule
095 */
096 public abstract Map<String, Rule> getPluginRulesIndexedByKey(String pluginKey);
097
098 /**
099 * Gets a collection of rules belonging to a plugin
100 *
101 * @param pluginKey the plugin key
102 * @return the collection of rules
103 */
104 public abstract Collection<Rule> getPluginRules(String pluginKey);
105
106 /**
107 * Gets a rule belonging to a defined plugin based on its key
108 *
109 * @param pluginKey the plugin key
110 * @param ruleKey the rule key
111 * @return the rule
112 */
113 public abstract Rule getPluginRule(String pluginKey, String ruleKey);
114 }