org.sonar.api.resources
Class Directory

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

public class Directory
extends Resource

Since:
1.10
See Also:
Serialized Form

Field Summary
static String ROOT
           
static String SEPARATOR
           
 
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
Directory(String relativePathFromSourceDir)
          Deprecated. since 4.2 use fromIOFile(java.io.File, Project)
Directory(String relativePathFromSourceDir, Language language)
          Deprecated. since 4.2 use fromIOFile(java.io.File, Project)
 
Method Summary
static Directory create(String relativePathFromBaseDir)
          Create a Directory that is partially initialized.
static Directory create(String relativePathFromBaseDir, String relativePathFromSourceDir)
          Create a directory that is fully initialized.
static Directory fromIOFile(File dir, Project module)
          Creates a Directory from an absolute File and a module.
 String getDescription()
           
 Language getLanguage()
           
 String getLongName()
           
 String getName()
           
 Resource getParent()
          The parent is used to build the resources tree, for example for relations between classes, packages and projects.
 String getQualifier()
          The qualifier tells the type of the resource.
 String getScope()
           
 boolean matchFilePattern(String antPattern)
          Check resource against an Ant pattern, like mypackag?/*Foo.java.
static String parseKey(String key)
           
 String toString()
           
 
Methods inherited from class org.sonar.api.resources.Resource
equals, getDeprecatedKey, getEffectiveKey, getId, getKey, getPath, hashCode, isExcluded, normalize, setDeprecatedKey, setEffectiveKey, setExcluded, setId, setKey, setPath
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

SEPARATOR

public static final String SEPARATOR
See Also:
Constant Field Values

ROOT

public static final String ROOT
See Also:
Constant Field Values
Constructor Detail

Directory

@Deprecated
public Directory(String relativePathFromSourceDir)
Deprecated. since 4.2 use fromIOFile(java.io.File, Project)


Directory

@Deprecated
public Directory(String relativePathFromSourceDir,
                            Language language)
Deprecated. since 4.2 use fromIOFile(java.io.File, Project)

Method Detail

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

getLanguage

public Language getLanguage()
Specified by:
getLanguage in class Resource
Returns:
the language of the resource. Only Files have a non null value.

getScope

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

getQualifier

public String getQualifier()
Description copied from class: Resource
The qualifier tells the type of the resource. For example, it can be a File, a Class, a Project, a Unit Test...

Specified by:
getQualifier in class Resource
Returns:
the qualifier
See Also:
for the list of qualifiers, to find out if a resource if a class, a unit test,... from its qualifier

getParent

public Resource 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

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

parseKey

public static String parseKey(String key)

fromIOFile

@CheckForNull
public static Directory fromIOFile(File dir,
                                                Project module)
Creates a Directory from an absolute File and a module. The returned Directory can be then passed for example to SensorContext.saveMeasure(Resource, org.sonar.api.measures.Measure).

Parameters:
dir - absolute path to a directory
module -
Returns:
null if the directory is not under module basedir.
Since:
4.2

create

public static Directory create(String relativePathFromBaseDir)
Create a Directory that is partially initialized. But that's enough to call for example SensorContext.saveMeasure(Resource, org.sonar.api.measures.Measure) when resources are already indexed. Internal use only.


create

public static Directory create(String relativePathFromBaseDir,
                               String relativePathFromSourceDir)
Create a directory that is fully initialized. Use for indexing resources. Internal use only.

Since:
4.2

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2009-2014 SonarSource. All Rights Reserved.