Package org.sonar.api.batch.fs.internal
Class DefaultInputFile
- java.lang.Object
-
- org.sonar.api.batch.fs.internal.DefaultInputComponent
-
- org.sonar.api.batch.fs.internal.DefaultInputFile
-
- All Implemented Interfaces:
org.sonar.api.batch.fs.IndexedFile
,org.sonar.api.batch.fs.InputComponent
,org.sonar.api.batch.fs.InputFile
,org.sonar.api.batch.fs.InputPath
public class DefaultInputFile extends DefaultInputComponent implements org.sonar.api.batch.fs.InputFile
- Since:
- 4.2
To create
InputFile
in tests, use TestInputFileBuilder.
-
-
Constructor Summary
Constructors Constructor Description DefaultInputFile(DefaultIndexedFile indexedFile, java.util.function.Consumer<DefaultInputFile> metadataGenerator)
DefaultInputFile(DefaultIndexedFile indexedFile, java.util.function.Consumer<DefaultInputFile> metadataGenerator, java.lang.String contents)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description java.lang.String
absolutePath()
void
addIgnoreIssuesOnLineRanges(java.util.Collection<int[]> lineRanges)
java.nio.charset.Charset
charset()
void
checkMetadata()
java.lang.String
contents()
boolean
equals(java.lang.Object obj)
java.io.File
file()
java.lang.String
filename()
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()
boolean
isEmpty()
boolean
isExcludedForCoverage()
boolean
isExcludedForDuplication()
boolean
isFile()
boolean
isIgnoreAllIssues()
boolean
isIgnoreAllIssuesOnLine(java.lang.Integer line)
boolean
isPublished()
java.lang.String
key()
Component key (without branch).java.lang.String
language()
int
lastValidOffset()
int
lineLength(int line)
int
lines()
org.sonar.api.batch.fs.TextPointer
newPointer(int globalOffset)
org.sonar.api.batch.fs.TextPointer
newPointer(int line, int lineOffset)
org.sonar.api.batch.fs.TextRange
newRange(int startOffset, int endOffset)
Create Range from global offsets.org.sonar.api.batch.fs.TextRange
newRange(int startLine, int startLineOffset, int endLine, int endLineOffset)
org.sonar.api.batch.fs.TextRange
newRange(org.sonar.api.batch.fs.TextPointer start, org.sonar.api.batch.fs.TextPointer end)
int
nonBlankLines()
void
noSonarAt(java.util.Set<java.lang.Integer> noSonarLines)
int[]
originalLineEndOffsets()
int[]
originalLineStartOffsets()
java.nio.file.Path
path()
java.lang.String
relativePath()
Deprecated.since 6.6org.sonar.api.batch.fs.TextRange
selectLine(int 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(org.sonar.api.batch.fs.InputFile.Status status)
org.sonar.api.batch.fs.InputFile.Status
status()
java.lang.String
toString()
org.sonar.api.batch.fs.InputFile.Type
type()
java.net.URI
uri()
void
validate(org.sonar.api.batch.fs.TextRange range)
-
Methods inherited from class org.sonar.api.batch.fs.internal.DefaultInputComponent
hasMeasureFor, scannerId, setHasMeasureFor
-
-
-
-
Constructor Detail
-
DefaultInputFile
public DefaultInputFile(DefaultIndexedFile indexedFile, java.util.function.Consumer<DefaultInputFile> metadataGenerator)
-
DefaultInputFile
public DefaultInputFile(DefaultIndexedFile indexedFile, java.util.function.Consumer<DefaultInputFile> metadataGenerator, @Nullable java.lang.String contents)
-
-
Method Detail
-
checkMetadata
public void checkMetadata()
-
inputStream
public java.io.InputStream inputStream() throws java.io.IOException
- Specified by:
inputStream
in interfaceorg.sonar.api.batch.fs.IndexedFile
- Specified by:
inputStream
in interfaceorg.sonar.api.batch.fs.InputFile
- Throws:
java.io.IOException
-
contents
public java.lang.String contents() throws java.io.IOException
- Specified by:
contents
in interfaceorg.sonar.api.batch.fs.InputFile
- Throws:
java.io.IOException
-
setPublished
public DefaultInputFile setPublished(boolean published)
-
isPublished
public boolean isPublished()
-
setExcludedForCoverage
public DefaultInputFile setExcludedForCoverage(boolean excludedForCoverage)
-
isExcludedForCoverage
public boolean isExcludedForCoverage()
-
setExcludedForDuplication
public DefaultInputFile setExcludedForDuplication(boolean excludedForDuplication)
-
isExcludedForDuplication
public boolean isExcludedForDuplication()
-
relativePath
@Deprecated public java.lang.String relativePath()
Deprecated.since 6.6- Specified by:
relativePath
in interfaceorg.sonar.api.batch.fs.IndexedFile
- Specified by:
relativePath
in interfaceorg.sonar.api.batch.fs.InputFile
- Specified by:
relativePath
in interfaceorg.sonar.api.batch.fs.InputPath
-
getModuleRelativePath
public java.lang.String getModuleRelativePath()
-
getProjectRelativePath
public java.lang.String getProjectRelativePath()
-
absolutePath
public java.lang.String absolutePath()
- Specified by:
absolutePath
in interfaceorg.sonar.api.batch.fs.IndexedFile
- Specified by:
absolutePath
in interfaceorg.sonar.api.batch.fs.InputFile
- Specified by:
absolutePath
in interfaceorg.sonar.api.batch.fs.InputPath
-
file
public java.io.File file()
- Specified by:
file
in interfaceorg.sonar.api.batch.fs.IndexedFile
- Specified by:
file
in interfaceorg.sonar.api.batch.fs.InputFile
- Specified by:
file
in interfaceorg.sonar.api.batch.fs.InputPath
-
path
public java.nio.file.Path path()
- Specified by:
path
in interfaceorg.sonar.api.batch.fs.IndexedFile
- Specified by:
path
in interfaceorg.sonar.api.batch.fs.InputFile
- Specified by:
path
in interfaceorg.sonar.api.batch.fs.InputPath
-
language
@CheckForNull public java.lang.String language()
- Specified by:
language
in interfaceorg.sonar.api.batch.fs.IndexedFile
- Specified by:
language
in interfaceorg.sonar.api.batch.fs.InputFile
-
type
public org.sonar.api.batch.fs.InputFile.Type type()
- Specified by:
type
in interfaceorg.sonar.api.batch.fs.IndexedFile
- Specified by:
type
in interfaceorg.sonar.api.batch.fs.InputFile
-
key
public java.lang.String key()
Component key (without branch).- Specified by:
key
in interfaceorg.sonar.api.batch.fs.InputComponent
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classDefaultInputComponent
-
toString
public java.lang.String toString()
- Specified by:
toString
in interfaceorg.sonar.api.batch.fs.InputFile
- Overrides:
toString
in classDefaultInputComponent
-
status
public org.sonar.api.batch.fs.InputFile.Status status()
- Specified by:
status
in interfaceorg.sonar.api.batch.fs.InputFile
-
lines
public int lines()
- Specified by:
lines
in interfaceorg.sonar.api.batch.fs.InputFile
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmpty
in interfaceorg.sonar.api.batch.fs.InputFile
-
charset
public java.nio.charset.Charset charset()
- Specified by:
charset
in interfaceorg.sonar.api.batch.fs.InputFile
-
lastValidOffset
public int lastValidOffset()
-
hash
public java.lang.String hash()
Digest hash of the file.
-
nonBlankLines
public int nonBlankLines()
-
originalLineStartOffsets
public int[] originalLineStartOffsets()
-
originalLineEndOffsets
public int[] originalLineEndOffsets()
-
newPointer
public org.sonar.api.batch.fs.TextPointer newPointer(int line, int lineOffset)
- Specified by:
newPointer
in interfaceorg.sonar.api.batch.fs.InputFile
-
newRange
public org.sonar.api.batch.fs.TextRange newRange(org.sonar.api.batch.fs.TextPointer start, org.sonar.api.batch.fs.TextPointer end)
- Specified by:
newRange
in interfaceorg.sonar.api.batch.fs.InputFile
-
newRange
public org.sonar.api.batch.fs.TextRange newRange(int startLine, int startLineOffset, int endLine, int endLineOffset)
- Specified by:
newRange
in interfaceorg.sonar.api.batch.fs.InputFile
-
selectLine
public org.sonar.api.batch.fs.TextRange selectLine(int line)
- Specified by:
selectLine
in interfaceorg.sonar.api.batch.fs.InputFile
-
validate
public void validate(org.sonar.api.batch.fs.TextRange range)
-
newRange
public org.sonar.api.batch.fs.TextRange newRange(int startOffset, int endOffset)
Create Range from global offsets. Used for backward compatibility with older API.
-
newPointer
public org.sonar.api.batch.fs.TextPointer newPointer(int globalOffset)
-
setStatus
public DefaultInputFile setStatus(org.sonar.api.batch.fs.InputFile.Status status)
-
setCharset
public DefaultInputFile setCharset(java.nio.charset.Charset charset)
-
lineLength
public int lineLength(int line)
-
setMetadata
public DefaultInputFile setMetadata(Metadata metadata)
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classDefaultInputComponent
-
isFile
public boolean isFile()
- Specified by:
isFile
in interfaceorg.sonar.api.batch.fs.InputComponent
-
filename
public java.lang.String filename()
- Specified by:
filename
in interfaceorg.sonar.api.batch.fs.IndexedFile
-
uri
public java.net.URI uri()
- Specified by:
uri
in interfaceorg.sonar.api.batch.fs.IndexedFile
- Specified by:
uri
in interfaceorg.sonar.api.batch.fs.InputPath
-
noSonarAt
public void noSonarAt(java.util.Set<java.lang.Integer> noSonarLines)
-
hasNoSonarAt
public boolean hasNoSonarAt(int line)
-
isIgnoreAllIssues
public boolean isIgnoreAllIssues()
-
setIgnoreAllIssues
public void setIgnoreAllIssues(boolean ignoreAllIssues)
-
addIgnoreIssuesOnLineRanges
public void addIgnoreIssuesOnLineRanges(java.util.Collection<int[]> lineRanges)
-
isIgnoreAllIssuesOnLine
public boolean isIgnoreAllIssuesOnLine(@Nullable java.lang.Integer line)
-
setExecutableLines
public void setExecutableLines(java.util.Set<java.lang.Integer> executableLines)
-
getExecutableLines
public java.util.Optional<java.util.Set<java.lang.Integer>> getExecutableLines()
-
-