org.sonar.api.resources
Class Project

java.lang.Object
  extended by org.sonar.api.resources.Resource
      extended by org.sonar.api.resources.Project

public class Project
extends Resource

A class that manipulates Projects in the Sonar way.

Since:
1.10

Nested Class Summary
static class Project.AnalysisType
          Enumerates the type of possible analysis
 
Field Summary
static String PARAM_DATE
          Deprecated. since version 1.11. Constant moved to CoreProperties
static String PARAM_DYNAMIC_ANALYSIS
          Deprecated. since version 1.11. Constant moved to CoreProperties
static String PARAM_EXCLUSIONS
          Deprecated. since version 1.11. Constant moved to CoreProperties
static String PARAM_LANGUAGE
          Deprecated. since version 1.11. Constant moved to CoreProperties
static String PARAM_REUSE_RULES_CONFIG
          Deprecated. since version 1.11. Constant moved to CoreProperties
static String PARAM_VERSION
          Deprecated. since version 1.11. Constant moved to CoreProperties
static String SCOPE
           
 
Fields inherited from class org.sonar.api.resources.Resource
QUALIFIER_CLASS, QUALIFIER_DIRECTORY, QUALIFIER_FIELD, QUALIFIER_FILE, QUALIFIER_LIB, QUALIFIER_METHOD, QUALIFIER_MODULE, QUALIFIER_PACKAGE, QUALIFIER_PROJECT, QUALIFIER_SUBVIEW, QUALIFIER_UNIT_TEST_CLASS, QUALIFIER_VIEW, SCOPE_ENTITY, SCOPE_SET, SCOPE_SPACE
 
Constructor Summary
Project(String key)
           
Project(String key, String branch, String name)
           
 
Method Summary
static Project createFromMavenIds(String groupId, String artifactId)
           
 Date getAnalysisDate()
           
 Project.AnalysisType getAnalysisType()
           
 String getAnalysisVersion()
           
 String getArtifactId()
          Deprecated. since 2.5. See http://jira.codehaus.org/browse/SONAR-2011
 String getBranch()
           
 org.apache.commons.configuration.Configuration getConfiguration()
           
 String getDescription()
           
 String[] getExclusionPatterns()
          Patterns of resource exclusion as defined in project settings page.
 ProjectFileSystem getFileSystem()
          Note: it's better to get a reference on ProjectFileSystem as an IoC dependency (constructor parameter)
 String getGroupId()
          Deprecated. since 2.5. See http://jira.codehaus.org/browse/SONAR-2011
 Language getLanguage()
           
 String getLanguageKey()
           
 String getLongName()
           
 List<Project> getModules()
           
 String getName()
           
 String getPackaging()
           
 Project getParent()
          The parent is used to build the resources tree, for example for relations between classes, packages and projects.
 org.apache.maven.project.MavenProject getPom()
          Deprecated. since 2.5. See http://jira.codehaus.org/browse/SONAR-2011 , MavenProject can be retrieved as an IoC dependency
 Object getProperty(String key)
           
 String getQualifier()
           
 boolean getReuseExistingRulesConfig()
          Deprecated. since 2.5. See discussion from http://jira.codehaus.org/browse/SONAR-1873
 Project getRoot()
           
 String getScope()
           
 boolean isLatestAnalysis()
          whether it's the latest analysis done on this project (displayed in sonar dashboard) or an analysis on a past revision.
 boolean isModule()
           
 boolean isRoot()
           
 boolean matchFilePattern(String antPattern)
          Check resource against an Ant pattern, like mypackag?/*Foo.java.
 void removeFromParent()
          For internal use only.
 Project setAnalysisDate(Date analysisDate)
          For internal use only.
 Project setAnalysisType(Project.AnalysisType at)
           
 Project setAnalysisVersion(String analysisVersion)
          For internal use only.
 Project setBranch(String branch)
          For internal use only.
 Project setConfiguration(org.apache.commons.configuration.Configuration configuration)
          For internal use only.
 Project setDescription(String description)
          For internal use only.
 Project setExclusionPatterns(String[] s)
          Set exclusion patterns.
 Project setFileSystem(ProjectFileSystem fs)
          Deprecated. since 2.6. See http://jira.codehaus.org/browse/SONAR-2126
 Project setLanguage(Language language)
           
 Project setLanguageKey(String languageKey)
          For internal use only.
 Project setLatestAnalysis(boolean b)
          For internal use only.
 Project setName(String name)
          For internal use only.
 Project setPackaging(String packaging)
          For internal use only.
 Project setParent(Project parent)
          For internal use only.
 Project setPom(org.apache.maven.project.MavenProject pom)
          For internal use only.
 String toString()
           
 
Methods inherited from class org.sonar.api.resources.Resource
equals, getEffectiveKey, getId, getKey, hashCode, isExcluded, setEffectiveKey, setExcluded, setId, setKey
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

SCOPE

public static final String SCOPE
See Also:
Constant Field Values

PARAM_VERSION

@Deprecated
public static final String PARAM_VERSION
Deprecated. since version 1.11. Constant moved to CoreProperties
See Also:
Constant Field Values

PARAM_DATE

@Deprecated
public static final String PARAM_DATE
Deprecated. since version 1.11. Constant moved to CoreProperties
See Also:
Constant Field Values

PARAM_LANGUAGE

@Deprecated
public static final String PARAM_LANGUAGE
Deprecated. since version 1.11. Constant moved to CoreProperties
See Also:
Constant Field Values

PARAM_DYNAMIC_ANALYSIS

@Deprecated
public static final String PARAM_DYNAMIC_ANALYSIS
Deprecated. since version 1.11. Constant moved to CoreProperties
See Also:
Constant Field Values

PARAM_EXCLUSIONS

@Deprecated
public static final String PARAM_EXCLUSIONS
Deprecated. since version 1.11. Constant moved to CoreProperties
See Also:
Constant Field Values

PARAM_REUSE_RULES_CONFIG

@Deprecated
public static final String PARAM_REUSE_RULES_CONFIG
Deprecated. since version 1.11. Constant moved to CoreProperties
See Also:
Constant Field Values
Constructor Detail

Project

public Project(String key)

Project

public Project(String key,
               String branch,
               String name)
Method Detail

getBranch

public String getBranch()

setBranch

public Project setBranch(String branch)
For internal use only.


setPom

public final Project setPom(org.apache.maven.project.MavenProject pom)
For internal use only.


getPackaging

public String getPackaging()
Returns:
the project's packaging

getName

public String getName()
Specified by:
getName in class Resource
Returns:
the resource name

getLongName

public String getLongName()
Specified by:
getLongName in class Resource
Returns:
the resource long name

getDescription

public String getDescription()
Specified by:
getDescription in class Resource
Returns:
the resource description

setName

public Project setName(String name)
For internal use only.


setDescription

public Project setDescription(String description)
For internal use only.


setPackaging

public Project setPackaging(String packaging)
For internal use only.


isRoot

public boolean isRoot()
Returns:
whether the current project is root project

getRoot

public Project getRoot()

isModule

public boolean isModule()
Returns:
whether the current project is a module

getAnalysisType

public Project.AnalysisType getAnalysisType()
Returns:
the type of analysis of the project

setAnalysisType

public Project setAnalysisType(Project.AnalysisType at)

isLatestAnalysis

public boolean isLatestAnalysis()
whether it's the latest analysis done on this project (displayed in sonar dashboard) or an analysis on a past revision.

Since:
2.0

setLatestAnalysis

public Project setLatestAnalysis(boolean b)
For internal use only.


getLanguage

public Language getLanguage()
Specified by:
getLanguage in class Resource
Returns:
the project language

setLanguage

public Project setLanguage(Language language)

getLanguageKey

public String getLanguageKey()
Returns:
the language key

setLanguageKey

public Project setLanguageKey(String languageKey)
For internal use only.


setAnalysisDate

public Project setAnalysisDate(Date analysisDate)
For internal use only.


setAnalysisVersion

public Project setAnalysisVersion(String analysisVersion)
For internal use only.


getScope

public String getScope()
Specified by:
getScope in class Resource
Returns:
the scope of the current object

getQualifier

public String getQualifier()
Specified by:
getQualifier in class Resource
Returns:
the qualifier of the current object

matchFilePattern

public boolean matchFilePattern(String antPattern)
Description copied from class: Resource
Check resource against an Ant pattern, like mypackag?/*Foo.java. It's used for example to match resource exclusions.

Specified by:
matchFilePattern in class Resource
Parameters:
antPattern - Ant-like pattern (with **, * and ?). It includes file suffixes.
Returns:
true if the resource matches the Ant pattern

getParent

public Project getParent()
Description copied from class: Resource
The parent is used to build the resources tree, for example for relations between classes, packages and projects.

Return null if the parent is the project.

Specified by:
getParent in class Resource

setParent

public Project setParent(Project parent)
For internal use only.


removeFromParent

public void removeFromParent()
For internal use only.


getModules

public List<Project> getModules()
Returns:
the list of modules

getReuseExistingRulesConfig

@Deprecated
public boolean getReuseExistingRulesConfig()
Deprecated. since 2.5. See discussion from http://jira.codehaus.org/browse/SONAR-1873

Returns:
whether to use external source for rules configuration

getAnalysisVersion

public String getAnalysisVersion()
Returns:
the current version of the project

getAnalysisDate

public Date getAnalysisDate()
Returns:
the analysis date, i.e. the date that will be used to store the snapshot

getExclusionPatterns

public String[] getExclusionPatterns()
Patterns of resource exclusion as defined in project settings page.


setExclusionPatterns

public Project setExclusionPatterns(String[] s)
Set exclusion patterns. Configuration is not saved, so this method must be used ONLY IN UNIT TESTS.


getFileSystem

public ProjectFileSystem getFileSystem()
Note: it's better to get a reference on ProjectFileSystem as an IoC dependency (constructor parameter)


setFileSystem

public Project setFileSystem(ProjectFileSystem fs)
Deprecated. since 2.6. See http://jira.codehaus.org/browse/SONAR-2126

For internal use only.


getGroupId

@Deprecated
public String getGroupId()
Deprecated. since 2.5. See http://jira.codehaus.org/browse/SONAR-2011


getArtifactId

@Deprecated
public String getArtifactId()
Deprecated. since 2.5. See http://jira.codehaus.org/browse/SONAR-2011


getPom

@Deprecated
public org.apache.maven.project.MavenProject getPom()
Deprecated. since 2.5. See http://jira.codehaus.org/browse/SONAR-2011 , MavenProject can be retrieved as an IoC dependency

Returns:
the underlying Maven project

getConfiguration

public org.apache.commons.configuration.Configuration getConfiguration()
Returns:
the project configuration

setConfiguration

public final Project setConfiguration(org.apache.commons.configuration.Configuration configuration)
For internal use only.


getProperty

public Object getProperty(String key)

createFromMavenIds

public static Project createFromMavenIds(String groupId,
                                         String artifactId)

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2009-2011 SonarSource. All Rights Reserved.