org.sonar.api.resources
Class Project

java.lang.Object
  extended by org.sonar.api.resources.Project
All Implemented Interfaces:
Resource

public class Project
extends Object
implements Resource

A class that manipulates Projects in the Sonar way, i.e. mixing MavenProjects with the way it should be analyzed

Since:
1.10

Nested Class Summary
static class Project.AnalysisType
          Enumerates the type of possible analysis
 
Field Summary
static String PARAM_BRANCH
          Deprecated. since version 1.11. Constant moved to CoreProperties
static String PARAM_DATE
          Deprecated. since version 1.11. Constant moved to CoreProperties
static String PARAM_DEPRECATED_BRANCH
          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
 
Fields inherited from interface org.sonar.api.resources.Resource
QUALIFIER_CLASS, QUALIFIER_DIRECTORY, QUALIFIER_FILE, QUALIFIER_MODULE, QUALIFIER_PACKAGE, QUALIFIER_PROJECT, QUALIFIER_PROJECT_BRANCH, QUALIFIER_PROJECT_TRUNK, QUALIFIER_SUBVIEW, QUALIFIER_UNIT_TEST_CLASS, QUALIFIER_VIEW, SCOPE_DIRECTORY, SCOPE_ENTITY, SCOPE_FILE, SCOPE_PROJECT, SCOPE_SET, SCOPE_SPACE
 
Constructor Summary
Project(org.apache.maven.project.MavenProject mavenProject)
          Creates a Project from a MavenProject (pom)
Project(org.apache.maven.project.MavenProject pom, org.apache.commons.configuration.Configuration configuration)
          Creates a project from MavenProject and a configuration
Project(String key, String name, String packaging, org.apache.commons.configuration.Configuration conf)
          Creates a Project from key, name, packaging and configuration
 
Method Summary
 boolean equals(Object o)
           
 Date getAnalysisDate()
           
 Project.AnalysisType getAnalysisType()
           
 String getAnalysisVersion()
           
 String getArtifactId()
          Deprecated. since 1.12. Avoid coupling with Maven concepts.
 org.apache.commons.configuration.Configuration getConfiguration()
           
 String getDescription()
           
 String[] getExclusionPatterns()
          Patterns of resource exclusion as defined in project settings page.
 ProjectFileSystem getFileSystem()
           
 String getGroupId()
          Deprecated. since 1.12. Avoid coupling with Maven concepts.
 Integer getId()
          Internal use
 String getKey()
          Project key is "groupId:artifactId[:branch]".
 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()
           
 Object getProperty(String key)
           
 String getQualifier()
           
 boolean getReuseExistingRulesConfig()
           
 Project getRoot()
           
 String getScope()
           
 Snapshot getSnapshot()
          Internal use
 int hashCode()
           
 boolean isModule()
           
 boolean isRoot()
           
 boolean isSonarLightMode()
          Deprecated. 
 boolean matchFilePattern(String antPattern)
          Check resource against an Ant pattern, like mypackag?/*Foo.java.
 Project setConfiguration(org.apache.commons.configuration.Configuration configuration)
          Sets the configuration
 Project setDatabaseSettings(Integer projectId, Snapshot snapshot)
          Internal use
 void setExclusionPatterns(String[] patterns)
          Set exclusion patterns.
 Project setLanguages(Languages languages)
          Sets the project languaage
 void setParent(Project parent)
          Sets a parent to the current object
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

PARAM_DEPRECATED_BRANCH

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

PARAM_BRANCH

@Deprecated
public static final String PARAM_BRANCH
Deprecated. since version 1.11. Constant moved to CoreProperties
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(org.apache.maven.project.MavenProject mavenProject)
Creates a Project from a MavenProject (pom)


Project

public Project(org.apache.maven.project.MavenProject pom,
               org.apache.commons.configuration.Configuration configuration)
Creates a project from MavenProject and a configuration


Project

public Project(String key,
               String name,
               String packaging,
               org.apache.commons.configuration.Configuration conf)
Creates a Project from key, name, packaging and configuration

Method Detail

getSnapshot

public Snapshot getSnapshot()
Internal use


getId

public Integer getId()
Internal use


setDatabaseSettings

public Project setDatabaseSettings(Integer projectId,
                                   Snapshot snapshot)
Internal use


setLanguages

public Project setLanguages(Languages languages)
Sets the project languaage

Returns:
the current object

getRoot

public Project getRoot()
Returns:
the project's root project

getPackaging

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

isRoot

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

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

getGroupId

@Deprecated
public String getGroupId()
Deprecated. since 1.12. Avoid coupling with Maven concepts.


getArtifactId

@Deprecated
public String getArtifactId()
Deprecated. since 1.12. Avoid coupling with Maven concepts.


getName

public String getName()
Specified by:
getName in interface Resource
Returns:
project's name

getLongName

public String getLongName()
Specified by:
getLongName in interface Resource
Returns:
project's long name

getDescription

public String getDescription()
Specified by:
getDescription in interface Resource
Returns:
project's description

getLanguage

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

getLanguageKey

public String getLanguageKey()
Returns:
the language key

getScope

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

getQualifier

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

matchFilePattern

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

Specified by:
matchFilePattern in interface 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 interface: 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 interface Resource
Returns:
the current object's parent

setParent

public void setParent(Project parent)
Sets a parent to the current object


getModules

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

getReuseExistingRulesConfig

public boolean getReuseExistingRulesConfig()
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

getKey

public String getKey()
Project key is "groupId:artifactId[:branch]". Examples : org.struts:struts-core and org.codehaus.sonar:sonar:1.10

Specified by:
getKey in interface Resource
Returns:
the resource key

getExclusionPatterns

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


setExclusionPatterns

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


getFileSystem

public ProjectFileSystem getFileSystem()

getPom

public org.apache.maven.project.MavenProject getPom()
Returns:
the underlying maven project

isSonarLightMode

@Deprecated
public boolean isSonarLightMode()
Deprecated. 


getConfiguration

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

setConfiguration

public Project setConfiguration(org.apache.commons.configuration.Configuration configuration)
Sets the configuration

Returns:
the current object

getProperty

public Object getProperty(String key)

equals

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

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2009 SonarSource SA. All Rights Reserved.