org.sonar.api.rules
Class Rule

java.lang.Object
  extended by org.sonar.api.rules.Rule

public final class Rule
extends Object


Field Summary
static RulePriority DEFAULT_PRIORITY
          The default priority given to a rule if not explicitly set
 
Constructor Summary
Rule()
          Deprecated. since 2.3. Use the factory method create()
Rule(String pluginName, String key)
          Deprecated. since 2.3. Use the factory method create()
Rule(String name, String key, RulesCategory rulesCategory, String pluginName, String description)
          Deprecated. since 2.3. Use the factory method create()
Rule(String pluginKey, String key, String name, RulesCategory rulesCategory, RulePriority severity)
          Deprecated. since 2.3. Use the factory method create()
Rule(String name, String key, String configKey, RulesCategory rulesCategory, String pluginName, String description)
          Deprecated. since 2.3. Use the factory method create()
 
Method Summary
static Rule create()
           
static Rule create(String repositoryKey, String key)
          Create with all required fields
static Rule create(String repositoryKey, String key, String name)
          Create with all required fields
 RuleParam createParameter()
           
 RuleParam createParameter(String key)
           
 boolean equals(Object obj)
           
 Cardinality getCardinality()
           
 Integer getCategoryId()
          Deprecated. since 2.5 See http://jira.codehaus.org/browse/SONAR-2007
 String getConfigKey()
           
 String getDescription()
           
 Integer getId()
           
 String getKey()
           
 String getName()
           
 RuleParam getParam(String key)
           
 List<RuleParam> getParams()
           
 Rule getParent()
           
 String getPluginName()
          Deprecated. since 2.5 use getRepositoryKey() instead
 RulePriority getPriority()
          Deprecated. since 2.5 use getSeverity() instead. See http://jira.codehaus.org/browse/SONAR-1829
 String getRepositoryKey()
           
 RulesCategory getRulesCategory()
          Deprecated. since 2.5 See http://jira.codehaus.org/browse/SONAR-2007
 RulePriority getSeverity()
           
 int hashCode()
           
 Boolean isEnabled()
           
 Rule setCardinality(Cardinality c)
           
 Rule setConfigKey(String configKey)
          Sets the configuration key
 Rule setDescription(String description)
          Sets the rule description
 Rule setEnabled(Boolean b)
          Do not call.
 void setId(Integer id)
          Deprecated. since 2.3. visibility should be decreased to protected or package
 Rule setKey(String key)
          Sets the rule key
 Rule setName(String name)
          Sets the rule name
 Rule setParams(List<RuleParam> params)
          Sets the rule parameters
 Rule setParent(Rule parent)
           
 Rule setPluginName(String pluginName)
          Deprecated. since 2.5 use setRepositoryKey(String) instead
 Rule setPriority(RulePriority priority)
          Deprecated. since 2.5 use setSeverity(RulePriority) instead. See http://jira.codehaus.org/browse/SONAR-1829
 Rule setRepositoryKey(String s)
           
 Rule setRulesCategory(RulesCategory rulesCategory)
          Deprecated. since 2.5 See http://jira.codehaus.org/browse/SONAR-2007
 Rule setSeverity(RulePriority severity)
           
 Rule setUniqueKey(String repositoryKey, String key)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_PRIORITY

public static final RulePriority DEFAULT_PRIORITY
The default priority given to a rule if not explicitly set

Constructor Detail

Rule

@Deprecated
public Rule()
Deprecated. since 2.3. Use the factory method create()


Rule

@Deprecated
public Rule(String pluginName,
                       String key)
Deprecated. since 2.3. Use the factory method create()

Creates rule with minimum set of info

Parameters:
pluginName - the plugin name indicates which plugin the rule belongs to
key - the key should be unique within a plugin, but it is even more careful for the time being that it is unique across the application

Rule

@Deprecated
public Rule(String pluginKey,
                       String key,
                       String name,
                       RulesCategory rulesCategory,
                       RulePriority severity)
Deprecated. since 2.3. Use the factory method create()

Creates a fully qualified rule

Parameters:
pluginKey - the plugin the rule belongs to
key - the key should be unique within a plugin, but it is even more careful for the time being that it is unique across the application
name - the name displayed in the UI
rulesCategory - the ISO category the rule belongs to
severity - this is the severity associated to the rule

Rule

@Deprecated
public Rule(String name,
                       String key,
                       RulesCategory rulesCategory,
                       String pluginName,
                       String description)
Deprecated. since 2.3. Use the factory method create()


Rule

@Deprecated
public Rule(String name,
                       String key,
                       String configKey,
                       RulesCategory rulesCategory,
                       String pluginName,
                       String description)
Deprecated. since 2.3. Use the factory method create()

Method Detail

getId

public Integer getId()

setId

@Deprecated
public void setId(Integer id)
Deprecated. since 2.3. visibility should be decreased to protected or package


getName

public String getName()

setName

public Rule setName(String name)
Sets the rule name


getKey

public String getKey()

setKey

public Rule setKey(String key)
Sets the rule key


getRulesCategory

@Deprecated
public RulesCategory getRulesCategory()
Deprecated. since 2.5 See http://jira.codehaus.org/browse/SONAR-2007


setRulesCategory

@Deprecated
public Rule setRulesCategory(RulesCategory rulesCategory)
Deprecated. since 2.5 See http://jira.codehaus.org/browse/SONAR-2007


getPluginName

@Deprecated
public String getPluginName()
Deprecated. since 2.5 use getRepositoryKey() instead


setPluginName

@Deprecated
public Rule setPluginName(String pluginName)
Deprecated. since 2.5 use setRepositoryKey(String) instead


getConfigKey

public String getConfigKey()

setConfigKey

public Rule setConfigKey(String configKey)
Sets the configuration key


getDescription

public String getDescription()

setDescription

public Rule setDescription(String description)
Sets the rule description


isEnabled

public Boolean isEnabled()

setEnabled

public Rule setEnabled(Boolean b)
Do not call. Used only by sonar.


getParams

public List<RuleParam> getParams()

getParam

public RuleParam getParam(String key)

setParams

public Rule setParams(List<RuleParam> params)
Sets the rule parameters


createParameter

public RuleParam createParameter()

createParameter

public RuleParam createParameter(String key)

getCategoryId

@Deprecated
public Integer getCategoryId()
Deprecated. since 2.5 See http://jira.codehaus.org/browse/SONAR-2007


getSeverity

public RulePriority getSeverity()
Since:
2.5

setSeverity

public Rule setSeverity(RulePriority severity)
Parameters:
severity - severity to set, if null, uses the default priority.
Since:
2.5

getPriority

@Deprecated
public RulePriority getPriority()
Deprecated. since 2.5 use getSeverity() instead. See http://jira.codehaus.org/browse/SONAR-1829


setPriority

@Deprecated
public Rule setPriority(RulePriority priority)
Deprecated. since 2.5 use setSeverity(RulePriority) instead. See http://jira.codehaus.org/browse/SONAR-1829

Sets the rule priority. If null, uses the default priority


getRepositoryKey

public String getRepositoryKey()

setRepositoryKey

public Rule setRepositoryKey(String s)

setUniqueKey

public Rule setUniqueKey(String repositoryKey,
                         String key)

getCardinality

public Cardinality getCardinality()

setCardinality

public Rule setCardinality(Cardinality c)

getParent

public Rule getParent()

setParent

public Rule setParent(Rule parent)

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object

create

public static Rule create()

create

public static Rule create(String repositoryKey,
                          String key,
                          String name)
Create with all required fields


create

public static Rule create(String repositoryKey,
                          String key)
Create with all required fields

Since:
2.10


Copyright © 2009-2011 SonarSource. All Rights Reserved.