Class ParseExpr

    • Field Detail

      • exprType

        public final ExprType exprType
        Expression type.
      • info

        protected InputInfo info
        Input information.
    • Constructor Detail

      • ParseExpr

        protected ParseExpr​(InputInfo info,
                            SeqType seqType)
        Constructor.
        Parameters:
        info - input info (can be null
        seqType - sequence type
    • Method Detail

      • iter

        public Iter iter​(QueryContext qc)
                  throws QueryException
        Description copied from class: Expr
        Evaluates the expression and returns an iterator on the resulting items. The implementation of this method is optional.
        Specified by:
        iter in class Expr
        Parameters:
        qc - query context
        Returns:
        iterator
        Throws:
        QueryException - query exception
      • atomValue

        public final Value atomValue​(QueryContext qc,
                                     InputInfo ii)
                              throws QueryException
        Description copied from class: Expr
        Evaluates the expression and returns the atomized items.
        Specified by:
        atomValue in class Expr
        Parameters:
        qc - query context
        ii - input info (only required by Seq instances, which have no input info)
        Returns:
        atomized item
        Throws:
        QueryException - query exception
      • ebv

        public final Item ebv​(QueryContext qc,
                              InputInfo ii)
                       throws QueryException
        Description copied from class: Expr

        Checks if the effective boolean value can be computed for this expression:

        • If it yields an empty sequence, Bln.FALSE will be returned.
        • If it yields a single item, this item will be returned.
        • If it yields nodes, the first node will be returned.
        • Otherwise, an error will be raised.

        A single numeric item may later be evaluated as positional predicate.

        Specified by:
        ebv in class Expr
        Parameters:
        qc - query context
        ii - input info (required for Seq instances, which have no input info)
        Returns:
        item
        Throws:
        QueryException - query exception
      • test

        public final Item test​(QueryContext qc,
                               InputInfo ii)
                        throws QueryException
        Description copied from class: Expr
        Performs a predicate test and returns the item if the test was successful. The returned item is required for full-text scoring.
        Specified by:
        test in class Expr
        Parameters:
        qc - query context
        ii - input info (required for Seq instances, which have no input info)
        Returns:
        item or null
        Throws:
        QueryException - query exception
      • seqType

        public final SeqType seqType()
        Description copied from class: Expr
        Returns the static type of the resulting value.
        Specified by:
        seqType in class Expr
        Returns:
        result of check
      • size

        public final long size()
        Description copied from class: Expr
        Returns the result size, or -1 if the size is unknown.
        Specified by:
        size in class Expr
        Returns:
        result of check
      • data

        public Data data()
        Description copied from class: Expr
        Returns the data reference bound to this expression. This method is currently overwritten by DBNode, DBNodeSeq, AxisPath and VarRef.
        Overrides:
        data in class Expr
        Returns:
        data reference (can be null)
      • refineType

        public final void refineType​(Expr expr)
        Description copied from class: Expr
        Refines the expression type.
        Specified by:
        refineType in class Expr
        Parameters:
        expr - original expression
      • info

        public InputInfo info()
        Description copied from class: ExprInfo
        Returns the input info of an expression.
        Overrides:
        info in class ExprInfo
        Returns:
        info or null
      • copyType

        public final <T extends Expr> T copyType​(T expr)
        Assigns this expression's type to the specified expression.
        Type Parameters:
        T - expression type
        Parameters:
        expr - expression to be modified
        Returns:
        specified expression
      • adoptType

        public final ParseExpr adoptType​(Expr expr)
        Assigns the type from the specified expression.
        Parameters:
        expr - expression
        Returns:
        self reference
      • checkUp

        protected final <T extends XQFunctionExpr> T checkUp​(T expr,
                                                             boolean updating,
                                                             StaticContext sc)
                                                      throws QueryException
        Ensures that the specified function expression is (not) updating. Otherwise, throws an exception.
        Type Parameters:
        T - expression type
        Parameters:
        expr - expression (may be null)
        updating - indicates if expression is expected to be updating
        sc - static context
        Returns:
        specified expression
        Throws:
        QueryException - query exception
      • checkNoUp

        protected final void checkNoUp​(Expr expr)
                                throws QueryException
        Ensures that the specified expression performs no updates. Otherwise, throws an exception.
        Parameters:
        expr - expression (may be null)
        Throws:
        QueryException - query exception
      • checkNoneUp

        protected final void checkNoneUp​(Expr... exprs)
                                  throws QueryException
        Ensures that none of the specified expressions performs an update. Otherwise, throws an exception.
        Parameters:
        exprs - expressions (may be null)
        Throws:
        QueryException - query exception
      • checkAllUp

        protected final void checkAllUp​(Expr... exprs)
                                 throws QueryException
        Ensures that all specified expressions are vacuous or either updating or non-updating. Otherwise, throws an exception.
        Parameters:
        exprs - expressions to be checked
        Throws:
        QueryException - query exception
      • ctxValue

        protected final Value ctxValue​(QueryContext qc)
                                throws QueryException
        Returns the current context value or throws an exception if the context value is not set.
        Parameters:
        qc - query context
        Returns:
        context value
        Throws:
        QueryException - query exception
      • toToken

        protected final byte[] toToken​(Expr expr,
                                       QueryContext qc)
                                throws QueryException
        Evaluates an expression to a token.
        Parameters:
        expr - expression
        qc - query context
        Returns:
        token
        Throws:
        QueryException - query exception
      • toZeroToken

        protected final byte[] toZeroToken​(Expr expr,
                                           QueryContext qc)
                                    throws QueryException
        Evaluates an expression to a token.
        Parameters:
        expr - expression
        qc - query context
        Returns:
        token (zero-length if result is an empty sequence)
        Throws:
        QueryException - query exception
      • toTokenOrNull

        protected final byte[] toTokenOrNull​(Expr expr,
                                             QueryContext qc)
                                      throws QueryException
        Evaluates an expression to a token.
        Parameters:
        expr - expression
        qc - query context
        Returns:
        token, or null if the expression yields an empty sequence
        Throws:
        QueryException - query exception
      • toToken

        protected final byte[] toToken​(Item item)
                                throws QueryException
        Converts an item to a token.
        Parameters:
        item - item to be converted
        Returns:
        token
        Throws:
        QueryException - query exception
      • toString

        protected final String toString​(Item item)
                                 throws QueryException
        Evaluates an expression to a string.
        Parameters:
        item - item to be converted
        Returns:
        string
        Throws:
        QueryException - query exception
      • toStringOrNull

        protected final String toStringOrNull​(Expr expr,
                                              QueryContext qc)
                                       throws QueryException
        Evaluates an expression to a string.
        Parameters:
        expr - expression
        qc - query context
        Returns:
        string, or null if the expression yields an empty sequence
        Throws:
        QueryException - query exception
      • toBoolean

        protected final boolean toBoolean​(Expr expr,
                                          QueryContext qc)
                                   throws QueryException
        Evaluates an expression to a boolean.
        Parameters:
        expr - expression
        qc - query context
        Returns:
        boolean
        Throws:
        QueryException - query exception
      • toBoolean

        protected final boolean toBoolean​(Item item)
                                   throws QueryException
        Converts an item to a boolean.
        Parameters:
        item - item to be converted
        Returns:
        boolean
        Throws:
        QueryException - query exception
      • toDouble

        protected final double toDouble​(Expr expr,
                                        QueryContext qc)
                                 throws QueryException
        Evaluates an expression to a double number.
        Parameters:
        expr - expression
        qc - query context
        Returns:
        double
        Throws:
        QueryException - query exception
      • toDouble

        protected final double toDouble​(Item item)
                                 throws QueryException
        Converts an item to a double number.
        Parameters:
        item - item
        Returns:
        double
        Throws:
        QueryException - query exception
      • toNumberOrNull

        protected final ANum toNumberOrNull​(Expr expr,
                                            QueryContext qc)
                                     throws QueryException
        Evaluates an expression to a number.
        Parameters:
        expr - expression
        qc - query context
        Returns:
        number, or null if the expression yields an empty sequence
        Throws:
        QueryException - query exception
      • toNumber

        protected final ANum toNumber​(Item item)
                               throws QueryException
        Converts an item to a number.
        Parameters:
        item - item to be converted
        Returns:
        number
        Throws:
        QueryException - query exception
      • toFloat

        protected final float toFloat​(Expr expr,
                                      QueryContext qc)
                               throws QueryException
        Evaluates an expression to a float number.
        Parameters:
        expr - expression
        qc - query context
        Returns:
        float
        Throws:
        QueryException - query exception
      • toLong

        protected final long toLong​(Expr expr,
                                    QueryContext qc)
                             throws QueryException
        Evaluates an expression to a long number.
        Parameters:
        expr - expression
        qc - query context
        Returns:
        integer value
        Throws:
        QueryException - query exception
      • toLong

        protected final long toLong​(Item item)
                             throws QueryException
        Converts an item to an integer number.
        Parameters:
        item - item to be converted
        Returns:
        number
        Throws:
        QueryException - query exception
      • toNodeOrNull

        protected final ANode toNodeOrNull​(Expr expr,
                                           QueryContext qc)
                                    throws QueryException
        Evaluates an expression to a node.
        Parameters:
        expr - expression
        qc - query context
        Returns:
        node, or null if the expression yields an empty sequence
        Throws:
        QueryException - query exception
      • toNode

        protected final ANode toNode​(Item item)
                              throws QueryException
        Converts an item to a node.
        Parameters:
        item - item to be converted
        Returns:
        node
        Throws:
        QueryException - query exception
      • toItem

        protected final Item toItem​(Expr expr,
                                    QueryContext qc,
                                    Type type)
                             throws QueryException
        Evaluates an expression to an item of the given type.
        Parameters:
        expr - expression
        qc - query context
        type - expected type
        Returns:
        item
        Throws:
        QueryException - query exception
      • toAtomItem

        protected final Item toAtomItem​(Expr expr,
                                        QueryContext qc)
                                 throws QueryException
        Evaluates an expression to an atomized item of the given type.
        Parameters:
        expr - expression
        qc - query context
        Returns:
        atomized item
        Throws:
        QueryException - query exception
      • toBin

        protected final Bin toBin​(Expr expr,
                                  QueryContext qc)
                           throws QueryException
        Evaluates an expression to a binary item.
        Parameters:
        expr - expression
        qc - query context
        Returns:
        binary item
        Throws:
        QueryException - query exception
      • toBin

        protected final Bin toBin​(Item item)
                           throws QueryException
        Converts an item to a binary item.
        Parameters:
        item - item to be converted
        Returns:
        binary item
        Throws:
        QueryException - query exception
      • toBytes

        protected final byte[] toBytes​(Expr expr,
                                       QueryContext qc)
                                throws QueryException
        Evaluates an expression (token, binary item) to a byte array.
        Parameters:
        expr - expression
        qc - query context
        Returns:
        byte array
        Throws:
        QueryException - query exception
      • toB64

        protected final B64 toB64​(Expr expr,
                                  QueryContext qc,
                                  boolean empty)
                           throws QueryException
        Evaluates an expression to a Base64 item.
        Parameters:
        empty - allow empty result
        expr - expression
        qc - query context
        Returns:
        Base64 item
        Throws:
        QueryException - query exception
      • toB64

        protected final B64 toB64​(Item item,
                                  boolean empty)
                           throws QueryException
        Converts an item to a base64 item.
        Parameters:
        empty - return null if the given item is empty
        item - item
        Returns:
        Base64 item or null
        Throws:
        QueryException - query exception
      • toBytes

        protected final byte[] toBytes​(Item item)
                                throws QueryException
        Converts an item (token, binary item) to a byte array.
        Parameters:
        item - item to be converted
        Returns:
        byte array
        Throws:
        QueryException - query exception
      • toQNm

        protected final QNm toQNm​(Expr expr,
                                  boolean empty,
                                  QueryContext qc)
                           throws QueryException
        Evaluates an expression to a QName.
        Parameters:
        expr - expression
        empty - return null if the given item is empty
        qc - query context
        Returns:
        QName or null
        Throws:
        QueryException - query exception
      • toQNm

        protected final QNm toQNm​(Item item,
                                  boolean empty)
                           throws QueryException
        Converts an item to a QName.
        Parameters:
        item - item
        empty - return null if the given item is empty
        Returns:
        QName or null
        Throws:
        QueryException - query exception
      • toFunction

        protected final FItem toFunction​(Expr expr,
                                         QueryContext qc)
                                  throws QueryException
        Evaluates an expression to a function item.
        Parameters:
        expr - expression
        qc - query context
        Returns:
        function item
        Throws:
        QueryException - query exception
      • toMap

        protected final XQMap toMap​(Item item)
                             throws QueryException
        Converts an item to a map.
        Parameters:
        item - item to check
        Returns:
        map
        Throws:
        QueryException - query exception
      • toArray

        protected final XQArray toArray​(Item item)
                                 throws QueryException
        Converts an item to an array.
        Parameters:
        item - item to check
        Returns:
        the array
        Throws:
        QueryException - if the item is not an array
      • checkType

        protected final Item checkType​(Expr expr,
                                       AtomType type,
                                       QueryContext qc)
                                throws QueryException
        Evaluates an expression and returns an item if it has the specified type.
        Parameters:
        expr - expression
        type - expected type
        qc - query context
        Returns:
        item
        Throws:
        QueryException - query exception
      • checkType

        protected final Item checkType​(Item item,
                                       Type type)
                                throws QueryException
        Returns an item if it has the specified type.
        Parameters:
        item - item
        type - expected type
        Returns:
        item
        Throws:
        QueryException - query exception
      • checkNoEmpty

        protected final Item checkNoEmpty​(Item item)
                                   throws QueryException
        Returns an item if it is not empty.
        Parameters:
        item - item
        Returns:
        specified item
        Throws:
        QueryException - query exception
      • checkNoEmpty

        protected final Item checkNoEmpty​(Item item,
                                          Type type)
                                   throws QueryException
        Returns an item if it is not empty.
        Parameters:
        item - item
        type - expected type
        Returns:
        specified item
        Throws:
        QueryException - query exception