Class Position

java.lang.Object
io.debezium.text.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 Summary

    Fields
    Modifier and Type
    Field
    Description
    private final int
     
    static final Position
    The position is used when there is no content.
    private final int
     
    private final int
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Position(int indexInContent, int line, int column)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    add(Position position)
    Return a new position that is the addition of this position and that supplied.
    int
    Get the 1-based column number of the character.
    boolean
     
    int
     
    int
    Get the 0-based index of this position in the content character array.
    int
    Get the 1-based line number of the character.
     

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • 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 Details

    • Position

      public Position(int indexInContent, int line, int column)
  • Method Details

    • 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
    • equals

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

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

      public String toString()
      Overrides:
      toString 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