Class Position


  • @Immutable
    public final class Position
    extends Object
    A class that represents the position of a particular character in terms of the lines and columns of a character sequence.
    Author:
    Randall Hauch
    • Field Detail

      • EMPTY_CONTENT_POSITION

        public static final Position EMPTY_CONTENT_POSITION
        The position is used when there is no content.
      • line

        private final int line
      • column

        private final int column
      • indexInContent

        private final int indexInContent
    • Constructor Detail

      • Position

        public Position​(int indexInContent,
                        int line,
                        int column)
    • Method Detail

      • index

        public int index()
        Get the 0-based index of this position in the content character array.
        Returns:
        the index; never negative except for the first position in an empty content.
      • column

        public int column()
        Get the 1-based column number of the character.
        Returns:
        the column number; always positive
      • line

        public int line()
        Get the 1-based line number of the character.
        Returns:
        the line number; always positive
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • add

        public Position add​(Position position)
        Return a new position that is the addition of this position and that supplied.
        Parameters:
        position - the position to add to this object; may not be null
        Returns:
        the combined position