Class HierarchicalQueryClause

  • All Implemented Interfaces:
    Expression

    public final class HierarchicalQueryClause
    extends AbstractExpression
    If a table contains hierarchical data, then rows can be selected in a hierarchical order using the hierarchical query clause.

    START WITH specifies the root row(s) of the hierarchy.

    CONNECT BY specifies the relationship between parent rows and child rows of the hierarchy.

    BNF: hierarchical_query_clause ::= [start_with_clause] connectby_clause [order_siblings_by_clause]

    Version:
    2.5
    See Also:
    StartWithClause, ConnectByClause, OrderSiblingsByClause
    Author:
    Pascal Filion
    Since:
    2.5
    • Constructor Detail

      • HierarchicalQueryClause

        public HierarchicalQueryClause​(AbstractExpression parent)
        Creates a new HierarchicalQueryClause.
        Parameters:
        parent - The parent of this expression
    • Method Detail

      • getConnectByClause

        public Expression getConnectByClause()
        Returns the Expression representing the CONNECT BY clause.
        Returns:
        The expression representing the CONNECT BY clause
      • getOrderSiblingsByClause

        public Expression getOrderSiblingsByClause()
        Returns the Expression representing the ORDER SIBLINGS BY clause.
        Returns:
        The expression representing the ORDER SIBLINGS BY clause
      • getStartWithClause

        public Expression getStartWithClause()
        Returns the Expression representing the START WITH clause.
        Returns:
        The expression representing the START WITH clause
      • hasConnectByClause

        public boolean hasConnectByClause()
        Determines whether the CONNECT BY clause is defined.
        Returns:
        true if the query that got parsed had the CONNECT BY clause
      • hasOrderSiblingsByClause

        public boolean hasOrderSiblingsByClause()
        Determines whether the ORDER SIBLINGS BY clause is defined.
        Returns:
        true if the query that got parsed had the ORDER SIBLINGS BY clause
      • hasSpaceAfterConnectByClause

        public boolean hasSpaceAfterConnectByClause()
        Determines whether a whitespace was found after the CONNECT BY clause. In some cases, the space is owned by a child of the hierarchical query clause.
        Returns:
        true if there was a whitespace after the CONNECT BY clause and owned by this expression; false otherwise
      • hasSpaceAfterStartWithClause

        public boolean hasSpaceAfterStartWithClause()
        Determines whether a whitespace was found after the START WITH clause. In some cases, the space is owned by a child of the hierarchical query clause.
        Returns:
        true if there was a whitespace after the START WITH clause and owned by this expression; false otherwise
      • hasStartWithClause

        public boolean hasStartWithClause()
        Determines whether the START WITH clause is defined.
        Returns:
        true if the query that got parsed had the START WITH clause
      • parse

        protected void parse​(WordParser wordParser,
                             boolean tolerant)
        Parses the query by starting at the current position, which is part of the given WordParser.
        Specified by:
        parse in class AbstractExpression
        Parameters:
        wordParser - The text to parse based on the current position of the cursor
        tolerant - Determines whether the parsing system should be tolerant, meaning if it should try to parse invalid or incomplete queries
      • toParsedText

        protected void toParsedText​(java.lang.StringBuilder writer,
                                    boolean actual)
        Generates a string representation of this Expression, including its children, if it has any.
        Specified by:
        toParsedText in class AbstractExpression
        Parameters:
        writer - The buffer used to append this Expression's string representation
        actual - Determines whether the string representation should represent what was parsed, i.e. include any "virtual" whitespace (such as ending whitespace) and the actual case of the JPQL identifiers