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 Details

  • Method Details

    • checkMetadata

      public void checkMetadata()
    • inputStream

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

      public boolean isMarkedAsUnchanged()
    • setMarkedAsUnchanged

      public DefaultInputComponent setMarkedAsUnchanged(boolean markedAsUnchanged)
    • contents

      public String contents() throws IOException
      Specified by:
      contents in interface org.sonar.api.batch.fs.InputFile
      Throws:
      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 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 String getModuleRelativePath()
    • getProjectRelativePath

      public String getProjectRelativePath()
    • absolutePath

      public 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
    • oldRelativePath

      @CheckForNull public String oldRelativePath()
    • file

      public 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 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 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 String key()
      Component key (without branch).
      Specified by:
      key in interface org.sonar.api.batch.fs.InputComponent
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class DefaultInputComponent
    • toString

      public 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
    • isStatusSet

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

      public int lastValidOffset()
    • md5Hash

      public String md5Hash()
      Digest hash of the file.
      Specified by:
      md5Hash in interface org.sonar.api.batch.fs.InputFile
    • 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(Charset charset)
    • lineLength

      public int lineLength(int line)
    • setMetadata

      public DefaultInputFile setMetadata(Metadata metadata)
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class DefaultInputComponent
    • isFile

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

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

      public 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(Set<Integer> noSonarLines)
    • hasNoSonarAt

      public boolean hasNoSonarAt(int line)
    • isIgnoreAllIssues

      public boolean isIgnoreAllIssues()
    • setIgnoreAllIssues

      public void setIgnoreAllIssues(boolean ignoreAllIssues)
    • addIgnoreIssuesOnLineRanges

      public void addIgnoreIssuesOnLineRanges(Collection<int[]> lineRanges)
    • isIgnoreAllIssuesOnLine

      public boolean isIgnoreAllIssuesOnLine(@Nullable Integer line)
    • setExecutableLines

      public void setExecutableLines(Set<Integer> executableLines)
    • getExecutableLines

      public Optional<Set<Integer>> getExecutableLines()