Class Range


  • public class Range
    extends Object
    Represents a range: a start and end position.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      int end
      Ending position of this range.
      String id
      Optional id for this range.
      TextPart part
      Remember the original TextPart in case we need to copy fields, Property or IAnnotation
      int start
      Starting position of this range.
    • Constructor Summary

      Constructors 
      Constructor Description
      Range​(int start, int end)
      Creates a new range with given starting and ending values.
      Range​(int start, int end, String id)
      Creates a new range with given starting and ending values and an id.
    • Field Detail

      • start

        public int start
        Starting position of this range.
      • end

        public int end
        Ending position of this range.
      • id

        public String id
        Optional id for this range.
      • part

        public TextPart part
        Remember the original TextPart in case we need to copy fields, Property or IAnnotation
    • Constructor Detail

      • Range

        public Range​(int start,
                     int end)
        Creates a new range with given starting and ending values.
        Parameters:
        start - the start value of the new range.
        end - the end value of the new range.
      • Range

        public Range​(int start,
                     int end,
                     String id)
        Creates a new range with given starting and ending values and an id.
        Parameters:
        start - the start value of the new range.
        end - the end value of the new range.
        id - the identifier value of the new range.
    • Method Detail

      • contains

        public boolean contains​(int pos)
        Returns true if the range contains a given position within its bounds.
        Parameters:
        pos - the given position.
        Returns:
        true if the given position is inside the range.
      • contains

        public boolean contains​(Range range)
        Returns true if the range contains a given range within its bounds.
        Parameters:
        range - the given range.
        Returns:
        true if the given range is inside the range.
      • intersectsWith

        public boolean intersectsWith​(Range range)
        Returns true if the range intersects with a given range.
        Parameters:
        range - the given range.
        Returns:
        true if the given and this range have at least one common position.
      • toString

        public String toString()
        Gets the string representation of the range with its id (its start and end position, and the id between parenthesis).
        Overrides:
        toString in class Object
        Returns:
        the string representation of the range and its id.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object