org.sonar.api.resources
Class File

java.lang.Object
  extended by org.sonar.api.resources.Resource<Directory>
      extended by org.sonar.api.resources.File

public class File
extends Resource<Directory>

This class is an implementation of a resource of type FILE

Since:
1.10

Field Summary
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
File(Language language, String key)
          Creates a File from its language and its key
File(Language language, String directory, String filename)
          Creates a File from language, directory and filename
File(String key)
          File in project.
File(String directory, String filename)
          Creates a file from its containing directory and name
 
Method Summary
static File fromIOFile(File file, List<File> sourceDirs)
          Creates a File from an io.file and a list of sources directories
static File fromIOFile(File file, Project project)
          Creates a File from its name and a project
 String getDescription()
          
 Language getLanguage()
          
 String getLongName()
          
 String getName()
          
 Directory getParent()
          The parent is used to build the resources tree, for example for relations between classes, packages and projects.
 String getQualifier()
          Returns the qualifier associated to this File.
 String getScope()
           
 boolean matchFilePattern(String antPattern)
          Check resource against an Ant pattern, like mypackag?/*Foo.java.
 void setLanguage(Language language)
          Sets the language of the file
 void setQualifier(String qualifier)
           
 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
Constructor Detail

File

public File(String key)
File in project. Key is the path relative to project source directories. It is not the absolute path and it does not include the path to source directories. Example : new File("org/sonar/foo.sql"). The absolute path may be c:/myproject/src/main/sql/org/sonar/foo.sql. Project root is c:/myproject and source dir is src/main/sql.


File

public File(String directory,
            String filename)
Creates a file from its containing directory and name


File

public File(Language language,
            String key)
Creates a File from its language and its key


File

public File(Language language,
            String directory,
            String filename)
Creates a File from language, directory and filename

Method Detail

getParent

public Directory getParent()
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<Directory>
See Also:
Resource.getParent()

matchFilePattern

public boolean matchFilePattern(String antPattern)
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<Directory>
Parameters:
antPattern - Ant-like pattern (with **, * and ?). It includes file suffixes.
Returns:
true if the resource matches the Ant pattern
See Also:
Resource.matchFilePattern(String)

fromIOFile

public static File fromIOFile(File file,
                              List<File> sourceDirs)
Creates a File from an io.file and a list of sources directories


fromIOFile

public static File fromIOFile(File file,
                              Project project)
Creates a File from its name and a project


getName

public String getName()

Specified by:
getName in class Resource<Directory>
Returns:
the resource name
See Also:
Resource.getName()

getLongName

public String getLongName()

Specified by:
getLongName in class Resource<Directory>
Returns:
the resource long name
See Also:
Resource.getLongName()

getDescription

public String getDescription()

Specified by:
getDescription in class Resource<Directory>
Returns:
the resource description
See Also:
Resource.getDescription()

getLanguage

public Language getLanguage()

Specified by:
getLanguage in class Resource<Directory>
Returns:
the language
See Also:
Resource.getLanguage()

setLanguage

public void setLanguage(Language language)
Sets the language of the file


getScope

public final String getScope()
Specified by:
getScope in class Resource<Directory>
Returns:
SCOPE_ENTITY

getQualifier

public String getQualifier()
Returns the qualifier associated to this File. Should be QUALIFIER_FILE or

Specified by:
getQualifier in class Resource<Directory>
Returns:
QUALIFIER_UNIT_TEST_CLASS

setQualifier

public void setQualifier(String qualifier)

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2009-2011 SonarSource. All Rights Reserved.