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.String
absolutePath()
Normalized absolute path.boolean
equals(java.lang.Object o)
java.io.File
file()
The underlying absoluteFile
.java.lang.String
filename()
Filename for this file (inclusing extension).java.lang.String
getModuleRelativePath()
java.lang.String
getProjectRelativePath()
int
hashCode()
java.io.InputStream
inputStream()
Creates a stream of the file's contents.boolean
isFile()
Is the component anInputFile
java.lang.String
key()
Component key (without branch).java.lang.String
language()
Language, for example "java" or "php".java.nio.file.Path
path()
The underlying absolutePath
.java.lang.String
relativePath()
Path relative to module base directory.java.lang.String
toString()
InputFile.Type
type()
Does it contain main or test code ?java.net.URI
uri()
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:IndexedFile
Path 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.java
if module base dir is/path/to/module
and 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:
relativePath
in interfaceIndexedFile
- Specified by:
relativePath
in 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:IndexedFile
Normalized 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:
absolutePath
in interfaceIndexedFile
- Specified by:
absolutePath
in interfaceInputPath
- See Also:
InputFile.absolutePath()
,InputDir.absolutePath()
-
file
public java.io.File file()
Description copied from interface:IndexedFile
The underlying absoluteFile
. It should not be used to read the file in the filesystem.- Specified by:
file
in interfaceIndexedFile
- Specified by:
file
in interfaceInputPath
- See Also:
#contents()
,IndexedFile.inputStream()
-
path
public java.nio.file.Path path()
Description copied from interface:IndexedFile
The underlying absolutePath
. It should not be used to read the file in the filesystem.- Specified by:
path
in interfaceIndexedFile
- Specified by:
path
in interfaceInputPath
- See Also:
#contents()
,IndexedFile.inputStream()
-
inputStream
public java.io.InputStream inputStream() throws java.io.IOException
Description copied from interface:IndexedFile
Creates 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:
inputStream
in interfaceIndexedFile
- Throws:
java.io.IOException
-
language
@CheckForNull public java.lang.String language()
Description copied from interface:IndexedFile
Language, 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:
language
in interfaceIndexedFile
-
type
public InputFile.Type type()
Description copied from interface:IndexedFile
Does it contain main or test code ?- Specified by:
type
in interfaceIndexedFile
-
key
public java.lang.String key()
Component key (without branch).- Specified by:
key
in interfaceInputComponent
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classDefaultInputComponent
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classDefaultInputComponent
-
toString
public java.lang.String toString()
- Overrides:
toString
in classDefaultInputComponent
-
isFile
public boolean isFile()
Description copied from interface:InputComponent
Is the component anInputFile
- Specified by:
isFile
in interfaceInputComponent
-
filename
public java.lang.String filename()
Description copied from interface:IndexedFile
Filename for this file (inclusing extension). For example: MyClass.java.- Specified by:
filename
in interfaceIndexedFile
-
uri
public java.net.URI uri()
Description copied from interface:IndexedFile
Identifier 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:
uri
in interfaceIndexedFile
- Specified by:
uri
in interfaceInputPath
-
-