Class DefaultInputFile

    • Method Detail

      • checkMetadata

        public void checkMetadata()
      • inputStream

        public java.io.InputStream inputStream()
                                        throws java.io.IOException
        Description copied from interface: InputFile
        Creates a stream of the file's contents. Depending on the runtime context, the source might be a file in a physical or virtual filesystem. Typically, it won't be buffered. The stream must be closed by the caller. Since 6.4 BOM is automatically filtered out.
        Specified by:
        inputStream in interface IndexedFile
        Specified by:
        inputStream in interface InputFile
        Throws:
        java.io.IOException
      • contents

        public java.lang.String contents()
                                  throws java.io.IOException
        Description copied from interface: InputFile
        Fetches the entire contents of the file, decoding with the InputFile.charset(). Since 6.4 BOM is automatically filtered out.
        Specified by:
        contents in interface 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
        Description copied from interface: InputFile
        Relative path to module (for normal Sensors) or project (for global Sensors) base directory. File separator is the forward slash ('/'), even on Microsoft Windows.
        Returns 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.
        Relative path is not null and is normalized ('foo/../foo' is replaced by 'foo').
        Specified by:
        relativePath in interface IndexedFile
        Specified by:
        relativePath in interface InputFile
        Specified by:
        relativePath in interface InputPath
        See Also:
        InputFile.relativePath(), InputDir.relativePath()
      • getModuleRelativePath

        public java.lang.String getModuleRelativePath()
      • getProjectRelativePath

        public java.lang.String getProjectRelativePath()
      • absolutePath

        public java.lang.String absolutePath()
        Description copied from interface: InputFile
        Normalized absolute path. File separator is forward slash ('/'), even on Microsoft Windows.
        This is not canonical path. Symbolic links are not resolved. For example if /project/src links to /tmp/src and basedir is /project, then this method returns /project/src/index.php. Use file().getCanonicalPath() to resolve symbolic link.
        Specified by:
        absolutePath in interface IndexedFile
        Specified by:
        absolutePath in interface InputFile
        Specified by:
        absolutePath in interface InputPath
        See Also:
        InputFile.absolutePath(), InputDir.absolutePath()
      • language

        @CheckForNull
        public java.lang.String language()
        Description copied from interface: InputFile
        Language, for example "java" or "php". Can be null if indexation of all files is enabled and no language claims to support the file.
        Specified by:
        language in interface IndexedFile
        Specified by:
        language in interface InputFile
      • key

        public java.lang.String key()
        Component key (without branch).
        Specified by:
        key in interface InputComponent
      • lines

        public int lines()
        Description copied from interface: InputFile
        Number of physical lines. This method supports all end-of-line characters. Formula is (number of line break + 1).

        Returns 1 if the file is empty.
        Returns 2 for foo\nbar.
        Returns 3 for foo\nbar\n.

        Specified by:
        lines in interface InputFile
      • isEmpty

        public boolean isEmpty()
        Description copied from interface: InputFile
        Check if the file content is empty (ignore potential BOM).
        Specified by:
        isEmpty in interface InputFile
      • charset

        public java.nio.charset.Charset charset()
        Description copied from interface: InputFile
        Charset to be used to decode this specific file.
        Specified by:
        charset in interface 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 TextPointer newPointer​(int line,
                                      int lineOffset)
        Description copied from interface: InputFile
        Returns a TextPointer in the given file.
        Specified by:
        newPointer in interface InputFile
        Parameters:
        line - Line of the pointer. Start at 1.
        lineOffset - Offset in the line. Start at 0.
      • newRange

        public TextRange newRange​(int startLine,
                                  int startLineOffset,
                                  int endLine,
                                  int endLineOffset)
        Description copied from interface: InputFile
        Returns a TextRange in the given file.
        • newRange(1, 0, 1, 1) selects the first character at line 1
        • newRange(1, 0, 1, 10) selects the 10 first characters at line 1
        Specified by:
        newRange in interface InputFile
      • selectLine

        public TextRange selectLine​(int line)
        Description copied from interface: InputFile
        Returns a TextRange in the given file that select the full line.
        Specified by:
        selectLine in interface InputFile
        Parameters:
        line - Start at 1.
      • validate

        public void validate​(TextRange range)
      • newRange

        public TextRange newRange​(int startOffset,
                                  int endOffset)
        Create Range from global offsets. Used for backward compatibility with older API.
      • newPointer

        public TextPointer newPointer​(int globalOffset)
      • setCharset

        public DefaultInputFile setCharset​(java.nio.charset.Charset charset)
      • filename

        public java.lang.String filename()
        Description copied from interface: IndexedFile
        Filename for this file (inclusing extension). For example: MyClass.java.
        Specified by:
        filename in interface IndexedFile
      • uri

        public java.net.URI uri()
        Description copied from interface: IndexedFile
        Identifier of the file. The only guarantee is that it is unique in the project. You should not assume it is a file:// URI.
        Specified by:
        uri in interface IndexedFile
        Specified by:
        uri in interface 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()