org.sonar.api.profiles
Class RulesProfile

java.lang.Object
  extended by org.sonar.api.profiles.RulesProfile
All Implemented Interfaces:
Cloneable

public class RulesProfile
extends Object
implements Cloneable

This class is badly named. It should be "QualityProfile". Indeed it does not relate only to rules but to metric thresholds too.


Field Summary
static String SONAR_WAY_FINDBUGS_NAME
          Name of the default java profile "Sonar way with Findbugs"
static String SONAR_WAY_NAME
          Name of the default profile "Sonar Way"
static String SUN_CONVENTIONS_NAME
          Name of the default java profile "Sun checks"
 
Constructor Summary
RulesProfile()
          Deprecated. use the factory method create()
RulesProfile(String name, String language)
          Deprecated. since 2.3. Use the factory method create()
RulesProfile(String name, String language, boolean defaultProfile, boolean provided)
          Deprecated. since 2.3. Use the factory method create()
 
Method Summary
 ActiveRule activateRule(Rule rule, RulePriority optionalSeverity)
           
 RulesProfile addActiveRule(ActiveRule activeRule)
           
 Object clone()
           
static RulesProfile create()
           
static RulesProfile create(String name, String language)
           
 boolean equals(Object obj)
           
 ActiveRule getActiveRule(Rule rule)
          Note: disabled rules are excluded.
 ActiveRule getActiveRule(String repositoryKey, String ruleKey)
          Note: disabled rules are excluded.
 ActiveRule getActiveRuleByConfigKey(String repositoryKey, String configKey)
          Note: disabled rules are excluded.
 List<ActiveRule> getActiveRules()
           
 List<ActiveRule> getActiveRules(boolean acceptDisabledRules)
           
 List<ActiveRule> getActiveRules(RulePriority severity)
          Note: disabled rules are excluded.
 List<ActiveRule> getActiveRulesByPlugin(String repositoryKey)
          Deprecated. since 2.3 use getActiveRulesByRepository(String) instead.
 List<ActiveRule> getActiveRulesByRepository(String repositoryKey)
          Get the active rules of a specific repository.
 List<Alert> getAlerts()
           
 Boolean getDefaultProfile()
           
 Boolean getEnabled()
           
 Integer getId()
           
 String getLanguage()
           
 String getName()
           
 String getParentName()
          For internal use only.
 List<ResourceModel> getProjects()
           
 Boolean getProvided()
           
 Boolean getUsed()
           
 int getVersion()
           
 int hashCode()
           
 boolean isEnabled()
           
 RulesProfile removeActiveRule(ActiveRule activeRule)
           
 void setActiveRules(List<ActiveRule> activeRules)
          Set the list of active rules
 void setAlerts(List<Alert> alerts)
          Sets the list of alerts for the profile
 void setDefaultProfile(Boolean b)
          Set whether this is the default profile for the language.
 RulesProfile setEnabled(Boolean b)
           
 RulesProfile setLanguage(String s)
          Set the profile language
 RulesProfile setName(String s)
          Set the profile name.
 void setParentName(String parentName)
          For internal use only.
 void setProjects(List<ResourceModel> projects)
          Sets the list of projects attached to the profile
 void setProvided(Boolean b)
          Set whether the profile is provided by a plugin
 RulesProfile setUsed(Boolean used)
           
 RulesProfile setVersion(int version)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

SONAR_WAY_NAME

public static final String SONAR_WAY_NAME
Name of the default profile "Sonar Way"

See Also:
Constant Field Values

SONAR_WAY_FINDBUGS_NAME

public static final String SONAR_WAY_FINDBUGS_NAME
Name of the default java profile "Sonar way with Findbugs"

See Also:
Constant Field Values

SUN_CONVENTIONS_NAME

public static final String SUN_CONVENTIONS_NAME
Name of the default java profile "Sun checks"

See Also:
Constant Field Values
Constructor Detail

RulesProfile

@Deprecated
public RulesProfile()
Deprecated. use the factory method create()


RulesProfile

@Deprecated
public RulesProfile(String name,
                               String language)
Deprecated. since 2.3. Use the factory method create()


RulesProfile

@Deprecated
public RulesProfile(String name,
                               String language,
                               boolean defaultProfile,
                               boolean provided)
Deprecated. since 2.3. Use the factory method create()

Method Detail

getId

public Integer getId()

getName

public String getName()
Returns:
the profile name, unique by language.

setName

public RulesProfile setName(String s)
Set the profile name.


getVersion

public int getVersion()

setVersion

public RulesProfile setVersion(int version)

getUsed

public Boolean getUsed()

setUsed

public RulesProfile setUsed(Boolean used)

getActiveRules

public List<ActiveRule> getActiveRules()
Returns:
the list of active rules

getActiveRules

public List<ActiveRule> getActiveRules(boolean acceptDisabledRules)
Returns:
the list of active rules

removeActiveRule

public RulesProfile removeActiveRule(ActiveRule activeRule)

addActiveRule

public RulesProfile addActiveRule(ActiveRule activeRule)

setActiveRules

public void setActiveRules(List<ActiveRule> activeRules)
Set the list of active rules


getDefaultProfile

public Boolean getDefaultProfile()
Returns:
whether this is the default profile for the language

setDefaultProfile

public void setDefaultProfile(Boolean b)
Set whether this is the default profile for the language. The default profile is used when none is explicitly defined when auditing a project.


getProvided

public Boolean getProvided()
Returns:
whether the profile is defined in a plugin. Provided profiles are automatically restored during server startup and can not be updated by end users.

setProvided

public void setProvided(Boolean b)
Set whether the profile is provided by a plugin


getEnabled

public Boolean getEnabled()

isEnabled

public boolean isEnabled()

setEnabled

public RulesProfile setEnabled(Boolean b)

getLanguage

public String getLanguage()
Returns:
the profile language

setLanguage

public RulesProfile setLanguage(String s)
Set the profile language


getParentName

public String getParentName()
For internal use only.

Since:
2.5

setParentName

public void setParentName(String parentName)
For internal use only.

Since:
2.5

getAlerts

public List<Alert> getAlerts()
Returns:
the list of alerts defined in the profile

setAlerts

public void setAlerts(List<Alert> alerts)
Sets the list of alerts for the profile


getProjects

public List<ResourceModel> getProjects()
Returns:
the list of projects attached to the profile

setProjects

public void setProjects(List<ResourceModel> projects)
Sets the list of projects attached to the profile


getActiveRules

public List<ActiveRule> getActiveRules(RulePriority severity)
Note: disabled rules are excluded.

Returns:
the list of active rules for a given severity

getActiveRulesByPlugin

@Deprecated
public List<ActiveRule> getActiveRulesByPlugin(String repositoryKey)
Deprecated. since 2.3 use getActiveRulesByRepository(String) instead.


getActiveRulesByRepository

public List<ActiveRule> getActiveRulesByRepository(String repositoryKey)
Get the active rules of a specific repository. Only enabled rules are selected. Disabled rules are excluded.


getActiveRule

public ActiveRule getActiveRule(String repositoryKey,
                                String ruleKey)
Note: disabled rules are excluded.

Returns:
an active rule from a plugin key and a rule key if the rule is activated, null otherwise

getActiveRuleByConfigKey

public ActiveRule getActiveRuleByConfigKey(String repositoryKey,
                                           String configKey)
Note: disabled rules are excluded.


getActiveRule

public ActiveRule getActiveRule(Rule rule)
Note: disabled rules are excluded.


activateRule

public ActiveRule activateRule(Rule rule,
                               RulePriority optionalSeverity)
Parameters:
optionalSeverity - if null, then the default rule severity is used

equals

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

hashCode

public int hashCode()
Overrides:
hashCode in class Object

clone

public Object clone()
Overrides:
clone in class Object

toString

public String toString()
Overrides:
toString in class Object

create

public static RulesProfile create(String name,
                                  String language)

create

public static RulesProfile create()


Copyright © 2009-2011 SonarSource. All Rights Reserved.