org.sonar.api.batch.fs
Interface FileSystem

All Superinterfaces:
BatchComponent
All Known Implementing Classes:
DefaultFileSystem

public interface FileSystem
extends BatchComponent

The unit tests needing an instance of FileSystem can use the implementation DefaultFileSystem and the related org.sonar.api.scan.filesystem.internal.DefaultInputFile:

   DefaultFileSystem fs = new DefaultFileSystem();
   fs.add(new DefaultInputFile("src/foo/bar.php"));
 

Since:
4.2

Method Summary
 File baseDir()
          Absolute base directory of module
 Charset encoding()
          Default encoding of input files.
 Iterable<File> files(FilePredicate predicate)
          Files matching the given predicate.
 boolean hasFiles(FilePredicate predicate)
          Returns true if at least one InputFile matches the given predicate.
 InputFile inputFile(FilePredicate predicate)
          Returns the single element matching the predicate.
 Iterable<InputFile> inputFiles(FilePredicate predicate)
          Input files matching the given attributes.
 Set<String> languages()
          Languages detected in all files, whatever their type (main or test)
 File workDir()
          Absolute work directory.
 

Method Detail

baseDir

File baseDir()
Absolute base directory of module


encoding

Charset encoding()
Default encoding of input files. If it's not defined, then the platform default encoding is returned


workDir

File workDir()
Absolute work directory. It can be used to store third-party analysis reports.

The work directory can be located outside baseDir().


inputFile

@CheckForNull
InputFile inputFile(FilePredicate predicate)
Returns the single element matching the predicate. If more than one elements match the predicate, then IllegalArgumentException is thrown. Returns null if no files match.

See Also:
FilePredicates

inputFiles

Iterable<InputFile> inputFiles(FilePredicate predicate)
Input files matching the given attributes. Return all the files if the parameter attributes 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))

See Also:
FilePredicates

hasFiles

boolean hasFiles(FilePredicate predicate)
Returns true if at least one InputFile matches the given predicate. This method can be faster than checking if #inputFiles(org.sonar.api.batch.fs.FilePredicate...) has elements.

See Also:
FilePredicates

files

Iterable<File> files(FilePredicate predicate)
Files matching the given predicate.

See Also:
FilePredicates

languages

Set<String> languages()
Languages detected in all files, whatever their type (main or test)



Copyright © 2009-2014 SonarSource. All Rights Reserved.