Class SqlParserPos

java.lang.Object
org.apache.calcite.sql.parser.SqlParserPos
All Implemented Interfaces:
Serializable

public class SqlParserPos extends Object implements Serializable
SqlParserPos represents the position of a parsed token within SQL statement text.
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final SqlParserPos
    Same as ZERO but always quoted.
    static final SqlParserPos
    SqlParserPos representing line one, character one.
  • Constructor Summary

    Constructors
    Constructor
    Description
    SqlParserPos(int lineNumber, int columnNumber)
    Creates a new parser position.
    SqlParserPos(int startLineNumber, int startColumnNumber, int endLineNumber, int endColumnNumber)
    Creates a new parser range.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    equals(@Nullable Object o)
     
    int
    Returns 1-based starting column number.
    int
    Returns 1-based end column number (same as starting column number if the ParserPos is a point, not a range).
    int
    Returns 1-based end line number (same as starting line number if the ParserPos is a point, not a range).
    int
    Returns 1-based starting line number.
    int
     
    boolean
    Returns whether this SqlParserPos is quoted.
    boolean
     
    Combines this parser position with another to create a position that spans from the first point in the first to the last point in the other.
    plusAll(Collection<? extends @Nullable SqlNode> nodes)
    Combines this parser position with a list of positions.
    plusAll(@Nullable SqlNode[] nodes)
    Combines this parser position with an array of positions to create a position that spans from the first point in the first to the last point in the other.
    boolean
     
    Returns a position spanning the earliest position to the latest.
    sum(List<? extends SqlNode> nodes)
    Combines the parser positions of a list of nodes to create a position which spans from the beginning of the first to the end of the last.
    sum(SqlNode[] nodes)
    Combines the parser positions of an array of nodes to create a position which spans from the beginning of the first to the end of the last.
     
    withQuoting(boolean quoted)
    Returns a SqlParserPos the same as this but quoted.

    Methods inherited from class java.lang.Object

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

    • ZERO

      public static final SqlParserPos ZERO
      SqlParserPos representing line one, character one. Use this if the node doesn't correspond to a position in piece of SQL text.
    • QUOTED_ZERO

      public static final SqlParserPos QUOTED_ZERO
      Same as ZERO but always quoted.
  • Constructor Details

    • SqlParserPos

      public SqlParserPos(int lineNumber, int columnNumber)
      Creates a new parser position.
    • SqlParserPos

      public SqlParserPos(int startLineNumber, int startColumnNumber, int endLineNumber, int endColumnNumber)
      Creates a new parser range.
  • Method Details

    • hashCode

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

      public boolean equals(@Nullable Object o)
      Overrides:
      equals in class Object
    • getLineNum

      public int getLineNum()
      Returns 1-based starting line number.
    • getColumnNum

      public int getColumnNum()
      Returns 1-based starting column number.
    • getEndLineNum

      public int getEndLineNum()
      Returns 1-based end line number (same as starting line number if the ParserPos is a point, not a range).
    • getEndColumnNum

      public int getEndColumnNum()
      Returns 1-based end column number (same as starting column number if the ParserPos is a point, not a range).
    • withQuoting

      public SqlParserPos withQuoting(boolean quoted)
      Returns a SqlParserPos the same as this but quoted.
    • isQuoted

      public boolean isQuoted()
      Returns whether this SqlParserPos is quoted.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • plus

      public SqlParserPos plus(SqlParserPos pos)
      Combines this parser position with another to create a position that spans from the first point in the first to the last point in the other.
    • plusAll

      public SqlParserPos plusAll(@Nullable SqlNode[] nodes)
      Combines this parser position with an array of positions to create a position that spans from the first point in the first to the last point in the other.
    • plusAll

      public SqlParserPos plusAll(Collection<? extends @Nullable SqlNode> nodes)
      Combines this parser position with a list of positions.
    • sum

      public static SqlParserPos sum(SqlNode[] nodes)
      Combines the parser positions of an array of nodes to create a position which spans from the beginning of the first to the end of the last.
    • sum

      public static SqlParserPos sum(List<? extends SqlNode> nodes)
      Combines the parser positions of a list of nodes to create a position which spans from the beginning of the first to the end of the last.
    • sum

      public static SqlParserPos sum(Iterable<SqlParserPos> poses)
      Returns a position spanning the earliest position to the latest. Does not assume that the positions are sorted. Throws if the list is empty.
    • overlaps

      public boolean overlaps(SqlParserPos pos)
    • startsAt

      public boolean startsAt(SqlParserPos pos)