public class JavaFile extends 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 and Description |
---|
JavaFile(String key)
Creates a source file from its key
|
JavaFile(String key,
boolean unitTest)
Creates any JavaFile from its key
|
JavaFile(String packageName,
String className)
Creates a JavaFile that is not a class of test based on package and file names
|
JavaFile(String packageKey,
String className,
boolean unitTest)
Creates a JavaFile that can be of any type based on package and file names
|
Modifier and Type | Method and Description |
---|---|
static JavaFile |
fromAbsolutePath(String path,
List<File> sourceDirs,
boolean unitTest)
Shortcut to fromIOFile with an abolute path
|
static JavaFile |
fromIOFile(File file,
List<File> sourceDirs,
boolean unitTest)
Creates a JavaFile from a file in the source directories
|
static JavaFile |
fromRelativePath(String relativePath,
boolean unitTest) |
String |
getDescription() |
Language |
getLanguage() |
String |
getLongName() |
String |
getName() |
JavaPackage |
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 |
isUnitTest() |
boolean |
matchFilePattern(String antPattern)
Check resource against an Ant pattern, like mypackag?/*Foo.java.
|
String |
toString() |
equals, getEffectiveKey, getId, getKey, hashCode, isExcluded, setEffectiveKey, setExcluded, setId, setKey
public JavaFile(String packageName, String className)
public JavaFile(String packageKey, String className, boolean unitTest)
unitTest
- whether it is a unit test file or a source filepublic JavaPackage getParent()
Return null if the parent is the project.
public String getDescription()
getDescription
in class Resource
public Language getLanguage()
getLanguage
in class Resource
public String getLongName()
getLongName
in class Resource
public String getQualifier()
Resource
getQualifier
in class Resource
for the list of qualifiers
,
to find out if a resource if a class, a unit test,... from its qualifier
public boolean isUnitTest()
public boolean matchFilePattern(String antPattern)
matchFilePattern
in class Resource
antPattern
- Ant-like pattern (with **, * and ?). It includes file suffixes.public static JavaFile fromRelativePath(String relativePath, boolean unitTest)
public static JavaFile fromIOFile(File file, List<File> sourceDirs, boolean unitTest)
public static JavaFile fromAbsolutePath(String path, List<File> sourceDirs, boolean unitTest)
Copyright © 2009-2014 SonarSource. All Rights Reserved.