Interface VCSFile.Range

    • Method Detail

      • lengthOf

        static int lengthOf​(java.util.Collection<VCSFile.Range> ranges)
        Calculates the sum of the lengths of the given ranges. Overlapping parts are handled accordingly.
        Parameters:
        ranges - The collection of ranges to calculate the sum of the lengths from. If null, 0 is returned. The collection may contain null values.
        Returns:
        The sum of the lengths of the given ranges.
        Throws:
        java.lang.IllegalArgumentException - If the ranges reference different files.
      • getBegin

        VCSFile.Position getBegin()
        Returns the begin position of this range.
        Returns:
        The begin position of this range.
      • getEnd

        VCSFile.Position getEnd()
        Returns the end position of this range.
        Returns:
        The end position of this range (inclusive).
      • getFile

        VCSFile getFile()
        Returns the referenced file.
        Returns:
        The referenced. file.
      • length

        default int length()
        Returns the length of this range.
        Returns:
        The length of this range (>= 1).
      • readContent

        default java.lang.String readContent()
                                      throws java.io.IOException
        Reads the content of this range.
        Returns:
        The content of this range.
        Throws:
        java.io.IOException - If an error occurred while reading the file content.
      • merge

        default java.util.Optional<VCSFile.Range> merge​(VCSFile.Range range)
                                                 throws java.lang.NullPointerException,
                                                        java.lang.IllegalArgumentException
        Creates a new range that merges the positions of this and the given range. Returns an empty Optional if their positions do not overlap.
        Parameters:
        range - The range to merge.
        Returns:
        A range that merges the overlapping positions of this and the given range. An empty Optional if their positions do not overlap.
        Throws:
        java.lang.NullPointerException - If range is null.
        java.lang.IllegalArgumentException - If range references a different file.
      • apply

        default java.util.Optional<VCSFile.Range> apply​(FileChange fileChange)
                                                 throws java.lang.NullPointerException,
                                                        java.io.IOException
        Delegates fileChange to getBegin() and getEnd() (see VCSFile.Position.apply(FileChange)) and computes the resulting range. Returns an empty Optional if fileChange is of type FileChange.Type.REMOVE, or if getBegin() or getEnd() returns an empty Optional.
        Parameters:
        fileChange - The file change to apply.
        Returns:
        The updated range.
        Throws:
        java.lang.NullPointerException - If fileChange is null.
        java.lang.IllegalArgumentException - If the file referenced by fileChange differs from the file referenced by this range.
        java.io.IOException - If computing the line diff (see FileChange.computeDiff()) fails.
      • mapTo

        default java.util.Optional<VCSFile.Range> mapTo​(VCSFile file)
                                                 throws java.io.IOException
        Returns a range with same begin and end, but located in file. Returns an empty optional, if this range does not exist in file.
        Parameters:
        file - The file to map this range to.
        Returns:
        A range with same begin and end, but located in file.
        Throws:
        java.lang.NullPointerException - If file is null.
        java.io.IOException - If an error occurred while reading the file content.