Class QueryPosition


  • public final class QueryPosition
    extends java.lang.Object
    This object contains the cursor position within the parsed tree and within each of the Expression from the root to the deepest leaf.
    Version:
    2.5
    Author:
    Pascal Filion
    Since:
    2.3
    • Constructor Detail

      • QueryPosition

        public QueryPosition​(int position)
        Creates a new QueryPosition.
        Parameters:
        position - The position of the cursor in the query
    • Method Detail

      • addPosition

        public void addPosition​(Expression expression,
                                int position)
        Adds the position of the cursor within the given Expression
        Parameters:
        expression - An Expression in which the cursor is located
        position - The position of the cursor within the given Expression
      • getExpression

        public Expression getExpression()
        Returns the child Expression where the position of the cursor is.
        Returns:
        The deepest Expression child that was retrieving by traversing the parsed tree up to the position of the cursor.
      • getPosition

        public int getPosition()
        Returns the position of the cursor in the query.
        Returns:
        The position of the cursor in the query
      • getPosition

        public int getPosition​(Expression expression)
        Returns the position of the cursor within the given Expression
        Parameters:
        expression - The Expression for which the position of the cursor is requested
        Returns:
        Either the position of the cursor within the given Expression or -1 if the cursor is not within it
      • setExpression

        public void setExpression​(Expression expression)
        Sets the deepest leaf where the cursor is located.
        Parameters:
        expression - The Expression that is the deepest leaf within the parsed tree
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object