Class 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.
    • Method Detail

      • checkMetadata

        public void checkMetadata()
      • inputStream

        public java.io.InputStream inputStream()
                                        throws java.io.IOException
        Specified by:
        inputStream in interface org.sonar.api.batch.fs.IndexedFile
        Specified by:
        inputStream in interface org.sonar.api.batch.fs.InputFile
        Throws:
        java.io.IOException
      • contents

        public java.lang.String contents()
                                  throws java.io.IOException
        Specified by:
        contents in interface org.sonar.api.batch.fs.InputFile
        Throws:
        java.io.IOException
      • 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 interface org.sonar.api.batch.fs.IndexedFile
        Specified by:
        relativePath in interface org.sonar.api.batch.fs.InputFile
        Specified by:
        relativePath in interface org.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 interface org.sonar.api.batch.fs.IndexedFile
        Specified by:
        absolutePath in interface org.sonar.api.batch.fs.InputFile
        Specified by:
        absolutePath in interface org.sonar.api.batch.fs.InputPath
      • file

        public java.io.File file()
        Specified by:
        file in interface org.sonar.api.batch.fs.IndexedFile
        Specified by:
        file in interface org.sonar.api.batch.fs.InputFile
        Specified by:
        file in interface org.sonar.api.batch.fs.InputPath
      • path

        public java.nio.file.Path path()
        Specified by:
        path in interface org.sonar.api.batch.fs.IndexedFile
        Specified by:
        path in interface org.sonar.api.batch.fs.InputFile
        Specified by:
        path in interface org.sonar.api.batch.fs.InputPath
      • language

        @CheckForNull
        public java.lang.String language()
        Specified by:
        language in interface org.sonar.api.batch.fs.IndexedFile
        Specified by:
        language in interface org.sonar.api.batch.fs.InputFile
      • type

        public org.sonar.api.batch.fs.InputFile.Type type()
        Specified by:
        type in interface org.sonar.api.batch.fs.IndexedFile
        Specified by:
        type in interface org.sonar.api.batch.fs.InputFile
      • key

        public java.lang.String key()
        Component key (without branch).
        Specified by:
        key in interface org.sonar.api.batch.fs.InputComponent
      • toString

        public java.lang.String toString()
        Specified by:
        toString in interface org.sonar.api.batch.fs.InputFile
        Overrides:
        toString in class DefaultInputComponent
      • status

        public org.sonar.api.batch.fs.InputFile.Status status()
        Specified by:
        status in interface org.sonar.api.batch.fs.InputFile
      • lines

        public int lines()
        Specified by:
        lines in interface org.sonar.api.batch.fs.InputFile
      • isEmpty

        public boolean isEmpty()
        Specified by:
        isEmpty in interface org.sonar.api.batch.fs.InputFile
      • charset

        public java.nio.charset.Charset charset()
        Specified by:
        charset in interface org.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 interface org.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 interface org.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 interface org.sonar.api.batch.fs.InputFile
      • selectLine

        public org.sonar.api.batch.fs.TextRange selectLine​(int line)
        Specified by:
        selectLine in interface org.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)
      • isFile

        public boolean isFile()
        Specified by:
        isFile in interface org.sonar.api.batch.fs.InputComponent
      • filename

        public java.lang.String filename()
        Specified by:
        filename in interface org.sonar.api.batch.fs.IndexedFile
      • uri

        public java.net.URI uri()
        Specified by:
        uri in interface org.sonar.api.batch.fs.IndexedFile
        Specified by:
        uri in interface org.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()