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.
|
void |
addIgnoreIssuesOnLineRanges(java.util.Collection<int[]> lineRanges) |
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.util.Optional<java.util.Set<java.lang.Integer>> |
getExecutableLines() |
java.lang.String |
getModuleRelativePath() |
java.lang.String |
getProjectRelativePath() |
java.lang.String |
hash()
Digest hash of the file.
|
int |
hashCode() |
boolean |
hasNoSonarAt(int line) |
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 |
isExcludedForDuplication() |
boolean |
isFile()
Is the component an
InputFile |
boolean |
isIgnoreAllIssues() |
boolean |
isIgnoreAllIssuesOnLine(java.lang.Integer line) |
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.
|
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() |
void |
noSonarAt(java.util.Set<java.lang.Integer> noSonarLines) |
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 |
setExcludedForDuplication(boolean excludedForDuplication) |
void |
setExecutableLines(java.util.Set<java.lang.Integer> executableLines) |
void |
setIgnoreAllIssues(boolean ignoreAllIssues) |
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) |
hasMeasureFor, scannerId, setHasMeasureForpublic 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
InputFileinputStream in interface IndexedFileinputStream in interface InputFilejava.io.IOExceptionpublic java.lang.String contents()
throws java.io.IOException
InputFileInputFile.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()
public DefaultInputFile setExcludedForDuplication(boolean excludedForDuplication)
public boolean isExcludedForDuplication()
@Deprecated public java.lang.String relativePath()
InputFileglobal 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 IndexedFilerelativePath in interface InputFilerelativePath in interface InputPathInputFile.relativePath(),
InputDir.relativePath()public java.lang.String getModuleRelativePath()
public java.lang.String getProjectRelativePath()
public java.lang.String absolutePath()
InputFilefile().getCanonicalPath() to resolve symbolic link.absolutePath in interface IndexedFileabsolutePath in interface InputFileabsolutePath in interface InputPathInputFile.absolutePath(),
InputDir.absolutePath()public java.io.File file()
InputFileFile. It should not be used to read the file in the filesystem.file in interface IndexedFilefile in interface InputFilefile in interface InputPathInputFile.contents(),
InputFile.inputStream()public java.nio.file.Path path()
InputFilePath.
It should not be used to read the file in the filesystem.path in interface IndexedFilepath in interface InputFilepath in interface InputPathInputFile.contents(),
InputFile.inputStream()@CheckForNull public java.lang.String language()
InputFilelanguage in interface IndexedFilelanguage in interface InputFilepublic InputFile.Type type()
InputFiletype in interface IndexedFiletype in interface InputFilepublic java.lang.String key()
key in interface InputComponentpublic int hashCode()
hashCode in class DefaultInputComponentpublic java.lang.String toString()
InputFiletoString in interface InputFiletoString in class DefaultInputComponentpublic 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()
InputFilepublic java.nio.charset.Charset charset()
InputFilepublic int lastValidOffset()
public java.lang.String hash()
public int nonBlankLines()
public int[] originalLineStartOffsets()
public int[] originalLineEndOffsets()
public TextPointer newPointer(int line, int lineOffset)
InputFileTextPointer in the given file.newPointer in interface InputFileline - Line of the pointer. Start at 1.lineOffset - Offset in the line. Start at 0.public TextRange newRange(TextPointer start, TextPointer end)
InputFileTextRange in the given file.public TextRange newRange(int startLine, int startLineOffset, int endLine, int endLineOffset)
InputFileTextRange 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)
InputFileTextRange in the given file that select the full line.selectLine in interface InputFileline - 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 DefaultInputComponentpublic boolean isFile()
InputComponentInputFileisFile in interface InputComponentpublic java.lang.String filename()
IndexedFilefilename in interface IndexedFilepublic java.net.URI uri()
IndexedFileuri in interface IndexedFileuri in interface InputPathpublic void noSonarAt(java.util.Set<java.lang.Integer> noSonarLines)
public boolean hasNoSonarAt(int line)
public boolean isIgnoreAllIssues()
public void setIgnoreAllIssues(boolean ignoreAllIssues)
public void addIgnoreIssuesOnLineRanges(java.util.Collection<int[]> lineRanges)
public boolean isIgnoreAllIssuesOnLine(@Nullable
java.lang.Integer line)
public void setExecutableLines(java.util.Set<java.lang.Integer> executableLines)
public java.util.Optional<java.util.Set<java.lang.Integer>> getExecutableLines()