Package org.sonar.api.batch.fs.internal
Class DefaultIndexedFile
- java.lang.Object
-
- org.sonar.api.batch.fs.internal.DefaultInputComponent
-
- org.sonar.api.batch.fs.internal.DefaultIndexedFile
-
- All Implemented Interfaces:
IndexedFile,InputComponent,InputPath
@Immutable public class DefaultIndexedFile extends DefaultInputComponent implements IndexedFile
- Since:
- 6.3
-
-
Constructor Summary
Constructors Constructor Description DefaultIndexedFile(java.lang.String projectKey, java.nio.file.Path baseDir, java.lang.String relativePath, java.lang.String language)Testing purposes only!DefaultIndexedFile(java.nio.file.Path absolutePath, java.lang.String projectKey, java.lang.String projectRelativePath, java.lang.String moduleRelativePath, InputFile.Type type, java.lang.String language, int batchId, SensorStrategy sensorStrategy)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringabsolutePath()Normalized absolute path.booleanequals(java.lang.Object o)java.io.Filefile()The underlying absoluteFile.java.lang.Stringfilename()Filename for this file (inclusing extension).java.lang.StringgetModuleRelativePath()java.lang.StringgetProjectRelativePath()inthashCode()java.io.InputStreaminputStream()Creates a stream of the file's contents.booleanisFile()Is the component anInputFilejava.lang.Stringkey()Component key (without branch).java.lang.Stringlanguage()Language, for example "java" or "php".java.nio.file.Pathpath()The underlying absolutePath.java.lang.StringrelativePath()Path relative to module base directory.java.lang.StringtoString()InputFile.Typetype()Does it contain main or test code ?java.net.URIuri()Identifier of the file.-
Methods inherited from class org.sonar.api.batch.fs.internal.DefaultInputComponent
hasMeasureFor, scannerId, setHasMeasureFor
-
-
-
-
Constructor Detail
-
DefaultIndexedFile
public DefaultIndexedFile(java.lang.String projectKey, java.nio.file.Path baseDir, java.lang.String relativePath, @Nullable java.lang.String language)Testing purposes only!
-
DefaultIndexedFile
public DefaultIndexedFile(java.nio.file.Path absolutePath, java.lang.String projectKey, java.lang.String projectRelativePath, java.lang.String moduleRelativePath, InputFile.Type type, @Nullable java.lang.String language, int batchId, SensorStrategy sensorStrategy)
-
-
Method Detail
-
relativePath
public java.lang.String relativePath()
Description copied from interface:IndexedFilePath relative to module base directory. Path is unique and identifies file within given. File separator is the forward slash ('/'), even on Microsoft Windows.FileSystem
Returnssrc/main/java/com/Foo.javaif module base dir is/path/to/moduleand if file is/path/to/module/src/main/java/com/Foo.java.
Relative path is not null and is normalized ('foo/../foo' is replaced by 'foo').- Specified by:
relativePathin interfaceIndexedFile- Specified by:
relativePathin interfaceInputPath- See Also:
InputFile.relativePath(),InputDir.relativePath()
-
getModuleRelativePath
public java.lang.String getModuleRelativePath()
-
getProjectRelativePath
public java.lang.String getProjectRelativePath()
-
absolutePath
public java.lang.String absolutePath()
Description copied from interface:IndexedFileNormalized absolute path. File separator is forward slash ('/'), even on Microsoft Windows.
This is not canonical path. Symbolic links are not resolved. For example if /project/src links to /tmp/src and basedir is /project, then this method returns /project/src/index.php. Usefile().getCanonicalPath()to resolve symbolic link.- Specified by:
absolutePathin interfaceIndexedFile- Specified by:
absolutePathin interfaceInputPath- See Also:
InputFile.absolutePath(),InputDir.absolutePath()
-
file
public java.io.File file()
Description copied from interface:IndexedFileThe underlying absoluteFile. It should not be used to read the file in the filesystem.- Specified by:
filein interfaceIndexedFile- Specified by:
filein interfaceInputPath- See Also:
#contents(),IndexedFile.inputStream()
-
path
public java.nio.file.Path path()
Description copied from interface:IndexedFileThe underlying absolutePath. It should not be used to read the file in the filesystem.- Specified by:
pathin interfaceIndexedFile- Specified by:
pathin interfaceInputPath- See Also:
#contents(),IndexedFile.inputStream()
-
inputStream
public java.io.InputStream inputStream() throws java.io.IOExceptionDescription copied from interface:IndexedFileCreates a stream of the file's contents. Depending on the runtime context, the source might be a file in a physical or virtual filesystem. Typically, it won't be buffered. The stream must be closed by the caller.- Specified by:
inputStreamin interfaceIndexedFile- Throws:
java.io.IOException
-
language
@CheckForNull public java.lang.String language()
Description copied from interface:IndexedFileLanguage, for example "java" or "php". Can be null if indexation of all files is enabled and no language claims to support the file.- Specified by:
languagein interfaceIndexedFile
-
type
public InputFile.Type type()
Description copied from interface:IndexedFileDoes it contain main or test code ?- Specified by:
typein interfaceIndexedFile
-
key
public java.lang.String key()
Component key (without branch).- Specified by:
keyin interfaceInputComponent
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classDefaultInputComponent
-
hashCode
public int hashCode()
- Overrides:
hashCodein classDefaultInputComponent
-
toString
public java.lang.String toString()
- Overrides:
toStringin classDefaultInputComponent
-
isFile
public boolean isFile()
Description copied from interface:InputComponentIs the component anInputFile- Specified by:
isFilein interfaceInputComponent
-
filename
public java.lang.String filename()
Description copied from interface:IndexedFileFilename for this file (inclusing extension). For example: MyClass.java.- Specified by:
filenamein interfaceIndexedFile
-
uri
public java.net.URI uri()
Description copied from interface:IndexedFileIdentifier of the file. The only guarantee is that it is unique in the project. You should not assume it is a file:// URI.- Specified by:
uriin interfaceIndexedFile- Specified by:
uriin interfaceInputPath
-
-