public class DefaultInputFile extends DefaultInputComponent implements InputFile
InputFile
in tests, use TestInputFileBuilder
.InputFile.Status, InputFile.Type
Constructor and Description |
---|
DefaultInputFile(DefaultIndexedFile indexedFile,
java.util.function.Consumer<DefaultInputFile> metadataGenerator) |
DefaultInputFile(DefaultIndexedFile indexedFile,
java.util.function.Consumer<DefaultInputFile> metadataGenerator,
java.lang.String contents) |
Modifier and Type | Method and Description |
---|---|
java.lang.String |
absolutePath()
Normalized absolute path.
|
java.nio.charset.Charset |
charset()
Charset to be used to decode this specific file.
|
void |
checkMetadata() |
java.lang.String |
contents()
Fetches the entire contents of the file, decoding with the
InputFile.charset() . |
boolean |
equals(java.lang.Object obj) |
java.io.File |
file()
The underlying absolute
File . |
java.lang.String |
filename()
Filename for this file (inclusing extension).
|
java.lang.String |
getModuleRelativePath() |
java.lang.String |
getProjectRelativePath() |
java.lang.String |
hash()
Digest hash of the file.
|
int |
hashCode() |
java.io.InputStream |
inputStream()
Creates a stream of the file's contents.
|
boolean |
isEmpty()
Check if the file content is empty (ignore potential BOM).
|
boolean |
isExcludedForCoverage() |
boolean |
isFile()
Is the component an
InputFile |
boolean |
isPublished() |
java.lang.String |
key()
Component key (without branch).
|
java.lang.String |
language()
Language, for example "java" or "php".
|
int |
lastValidOffset() |
int |
lines()
Number of physical lines.
|
java.lang.String |
moduleKey() |
TextPointer |
newPointer(int globalOffset) |
TextPointer |
newPointer(int line,
int lineOffset)
Returns a
TextPointer in the given file. |
TextRange |
newRange(int startOffset,
int endOffset)
Create Range from global offsets.
|
TextRange |
newRange(int startLine,
int startLineOffset,
int endLine,
int endLineOffset)
Returns a
TextRange in the given file. |
TextRange |
newRange(TextPointer start,
TextPointer end)
Returns a
TextRange in the given file. |
int |
nonBlankLines() |
int[] |
originalLineEndOffsets() |
int[] |
originalLineStartOffsets() |
java.nio.file.Path |
path()
The underlying absolute
Path . |
java.lang.String |
relativePath()
Deprecated.
since 6.6
|
TextRange |
selectLine(int line)
Returns a
TextRange in the given file that select the full line. |
DefaultInputFile |
setCharset(java.nio.charset.Charset charset) |
DefaultInputFile |
setExcludedForCoverage(boolean excludedForCoverage) |
DefaultInputFile |
setMetadata(Metadata metadata) |
DefaultInputFile |
setPublished(boolean published) |
DefaultInputFile |
setStatus(InputFile.Status status) |
InputFile.Status |
status()
|
java.lang.String |
toString()
Return a string to identify this file (suitable for logs).
|
InputFile.Type |
type()
Does it contain main or test code ?
|
java.net.URI |
uri()
Identifier of the file.
|
void |
validate(TextRange range) |
batchId
public DefaultInputFile(DefaultIndexedFile indexedFile, java.util.function.Consumer<DefaultInputFile> metadataGenerator)
public DefaultInputFile(DefaultIndexedFile indexedFile, java.util.function.Consumer<DefaultInputFile> metadataGenerator, @Nullable java.lang.String contents)
public void checkMetadata()
public java.io.InputStream inputStream() throws java.io.IOException
InputFile
inputStream
in interface IndexedFile
inputStream
in interface InputFile
java.io.IOException
public java.lang.String contents() throws java.io.IOException
InputFile
InputFile.charset()
.
Since 6.4 BOM is automatically filtered out.public DefaultInputFile setPublished(boolean published)
public boolean isPublished()
public DefaultInputFile setExcludedForCoverage(boolean excludedForCoverage)
public boolean isExcludedForCoverage()
@Deprecated public java.lang.String relativePath()
InputFile
global
Sensors) base directory.
File separator is the forward
slash ('/'), even on Microsoft Windows.
src/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
.
relativePath
in interface IndexedFile
relativePath
in interface InputFile
relativePath
in interface InputPath
InputFile.relativePath()
,
InputDir.relativePath()
public java.lang.String getModuleRelativePath()
public java.lang.String getProjectRelativePath()
public java.lang.String absolutePath()
InputFile
file().getCanonicalPath()
to resolve symbolic link.absolutePath
in interface IndexedFile
absolutePath
in interface InputFile
absolutePath
in interface InputPath
InputFile.absolutePath()
,
InputDir.absolutePath()
public java.io.File file()
InputFile
File
. It should not be used to read the file in the filesystem.file
in interface IndexedFile
file
in interface InputFile
file
in interface InputPath
InputFile.contents()
,
InputFile.inputStream()
public java.nio.file.Path path()
InputFile
Path
.
It should not be used to read the file in the filesystem.path
in interface IndexedFile
path
in interface InputFile
path
in interface InputPath
InputFile.contents()
,
InputFile.inputStream()
@CheckForNull public java.lang.String language()
InputFile
language
in interface IndexedFile
language
in interface InputFile
public InputFile.Type type()
InputFile
type
in interface IndexedFile
type
in interface InputFile
public java.lang.String key()
key
in interface InputComponent
public java.lang.String moduleKey()
public int hashCode()
hashCode
in class DefaultInputComponent
public java.lang.String toString()
InputFile
toString
in interface InputFile
toString
in class DefaultInputComponent
public InputFile.Status status()
public int lines()
InputFile
Returns 1 if the file is empty.
Returns 2 for foo\nbar.
Returns 3 for foo\nbar\n.
public boolean isEmpty()
InputFile
public java.nio.charset.Charset charset()
InputFile
public int lastValidOffset()
public java.lang.String hash()
public int nonBlankLines()
public int[] originalLineStartOffsets()
public int[] originalLineEndOffsets()
public TextPointer newPointer(int line, int lineOffset)
InputFile
TextPointer
in the given file.newPointer
in interface InputFile
line
- Line of the pointer. Start at 1.lineOffset
- Offset in the line. Start at 0.public TextRange newRange(TextPointer start, TextPointer end)
InputFile
TextRange
in the given file.public TextRange newRange(int startLine, int startLineOffset, int endLine, int endLineOffset)
InputFile
TextRange
in the given file.
newRange(1, 0, 1, 1)
selects the first character at line 1newRange(1, 0, 1, 10)
selects the 10 first characters at line 1public TextRange selectLine(int line)
InputFile
TextRange
in the given file that select the full line.selectLine
in interface InputFile
line
- Start at 1.public void validate(TextRange range)
public TextRange newRange(int startOffset, int endOffset)
public TextPointer newPointer(int globalOffset)
public DefaultInputFile setStatus(InputFile.Status status)
public DefaultInputFile setCharset(java.nio.charset.Charset charset)
public DefaultInputFile setMetadata(Metadata metadata)
public boolean equals(java.lang.Object obj)
equals
in class DefaultInputComponent
public boolean isFile()
InputComponent
InputFile
isFile
in interface InputComponent
public java.lang.String filename()
IndexedFile
filename
in interface IndexedFile
public java.net.URI uri()
IndexedFile
uri
in interface IndexedFile
uri
in interface InputPath