public class DefaultFileSystem extends java.lang.Object implements FileSystem
| Modifier and Type | Class and Description |
|---|---|
static class |
DefaultFileSystem.Cache |
FileSystem.Index| Modifier and Type | Field and Description |
|---|---|
protected FilePredicates |
predicates |
| Modifier | Constructor and Description |
|---|---|
|
DefaultFileSystem(java.io.File baseDir)
Only for testing
|
|
DefaultFileSystem(java.nio.file.Path baseDir)
Only for testing
|
protected |
DefaultFileSystem(java.nio.file.Path baseDir,
DefaultFileSystem.Cache cache) |
| Modifier and Type | Method and Description |
|---|---|
DefaultFileSystem |
add(InputFile inputFile) |
java.io.File |
baseDir()
Absolute base directory of module.
|
java.nio.file.Path |
baseDirPath() |
java.nio.charset.Charset |
encoding()
Default encoding of files in this project.
|
java.lang.Iterable<java.io.File> |
files(FilePredicate predicate)
Files matching the given predicate.
|
boolean |
hasFiles(FilePredicate predicate)
Returns true if at least one
InputFile matches
the given predicate. |
InputDir |
inputDir(java.io.File dir)
Returns
InputDir matching the current File. |
InputFile |
inputFile(FilePredicate predicate)
Returns the single element matching the predicate.
|
java.lang.Iterable<InputFile> |
inputFiles() |
java.lang.Iterable<InputFile> |
inputFiles(FilePredicate predicate)
Input files matching the given attributes.
|
java.util.SortedSet<java.lang.String> |
languages()
Languages detected in all files, whatever their type (main or test)
|
FilePredicates |
predicates()
Factory of
FilePredicate |
java.io.File |
resolvePath(java.lang.String path)
Utility method mainly used to resolve location of reports.
|
DefaultFileSystem |
setEncoding(java.nio.charset.Charset e) |
DefaultFileSystem |
setWorkDir(java.nio.file.Path d) |
java.io.File |
workDir()
Absolute work directory.
|
protected final FilePredicates predicates
public DefaultFileSystem(java.nio.file.Path baseDir)
public DefaultFileSystem(java.io.File baseDir)
protected DefaultFileSystem(java.nio.file.Path baseDir,
DefaultFileSystem.Cache cache)
public java.nio.file.Path baseDirPath()
public java.io.File baseDir()
FileSystembaseDir in interface FileSystempublic DefaultFileSystem setEncoding(java.nio.charset.Charset e)
public java.nio.charset.Charset encoding()
FileSystemInputFile it is preferable to use InputFile.charset()encoding in interface FileSystempublic DefaultFileSystem setWorkDir(java.nio.file.Path d)
public java.io.File workDir()
FileSystemFileSystem.baseDir().workDir in interface FileSystempublic InputFile inputFile(FilePredicate predicate)
FileSystemIllegalArgumentException is thrown. Returns null
if no files match.
How to use :
InputFile file = fs.inputFile(fs.predicates().hasRelativePath("src/Foo.php"));
inputFile in interface FileSystemFileSystem.predicates()public java.lang.Iterable<InputFile> inputFiles()
public java.lang.Iterable<InputFile> inputFiles(FilePredicate predicate)
FileSystemattributes is empty.
Important - result is an Iterable to benefit from streaming and decreasing
memory consumption. It should be iterated only once, else copy it into a list :
com.google.common.collect.Lists.newArrayList(inputFiles(predicate))
How to use :
FilePredicates p = fs.predicates();
Iterable<InputFile> files = fs.inputFiles(p.and(p.hasLanguage("java"), p.hasType(InputFile.Type.MAIN)));
inputFiles in interface FileSystemFileSystem.predicates()public boolean hasFiles(FilePredicate predicate)
FileSystemInputFile matches
the given predicate. This method can be faster than checking if FileSystem.inputFiles(org.sonar.api.batch.fs.FilePredicate)
has elements.hasFiles in interface FileSystemFileSystem.predicates()public java.lang.Iterable<java.io.File> files(FilePredicate predicate)
FileSystemfiles in interface FileSystemFileSystem.predicates()public InputDir inputDir(java.io.File dir)
FileSystemInputDir matching the current File.inputDir in interface FileSystempublic DefaultFileSystem add(InputFile inputFile)
public java.util.SortedSet<java.lang.String> languages()
FileSystemlanguages in interface FileSystempublic FilePredicates predicates()
FileSystemFilePredicatepredicates in interface FileSystempublic java.io.File resolvePath(java.lang.String path)
FileSystemresolvePath in interface FileSystem