protected Expression preEvaluateIfConstant(ExpressionVisitor visitor) throws XPathException { boolean fixed = true; for (Operand o : operands()) { if (!(o.getChildExpression() instanceof Literal)) { fixed = false; } } if (fixed) { try { return preEvaluate(visitor); } catch (NoDynamicContextException err) { // Early evaluation failed, typically because the implicit timezone is not yet known. // Try again later at run-time. return this; } } else { return this; } }
protected Expression preEvaluateIfConstant(ExpressionVisitor visitor) throws XPathException { boolean fixed = true; for (Operand o : operands()) { if (!(o.getChildExpression() instanceof Literal)) { fixed = false; } } if (fixed) { try { return preEvaluate(visitor); } catch (NoDynamicContextException err) { // Early evaluation failed, typically because the implicit timezone is not yet known. // Try again later at run-time. return this; } } else { return this; } }
/** * Perform optimisation of an expression and its subexpressions. * <p>This method is called after all references to functions and variables have been resolved * to the declaration of the function or variable, and after all type checking has been done.</p> * * @param visitor an expression visitor * @param contextItemType the static type of "." at the point where this expression is invoked. * The parameter is set to null if it is known statically that the context item will be undefined. * If the type of the context item is not known statically, the argument is set to * {@link net.sf.saxon.type.Type#ITEM_TYPE} * @return the original expression, rewritten if appropriate to optimize execution * @throws XPathException if an error is discovered during this phase * (typically a type error) */ /*@NotNull*/ public Expression optimize(ExpressionVisitor visitor, ContextItemStaticInfo contextItemType) throws XPathException { optimizeChildren(visitor, contextItemType); boolean fixed = true; for (Operand o : operands()) { if (!(o.getChildExpression() instanceof Literal)) { fixed = false; break; } } return fixed ? preEvaluate(visitor) : this; }
/** * Perform optimisation of an expression and its subexpressions. * <p>This method is called after all references to functions and variables have been resolved * to the declaration of the function or variable, and after all type checking has been done.</p> * * @param visitor an expression visitor * @param contextItemType the static type of "." at the point where this expression is invoked. * The parameter is set to null if it is known statically that the context item will be undefined. * If the type of the context item is not known statically, the argument is set to * {@link net.sf.saxon.type.Type#ITEM_TYPE} * @return the original expression, rewritten if appropriate to optimize execution * @throws XPathException if an error is discovered during this phase * (typically a type error) */ /*@NotNull*/ public Expression optimize(ExpressionVisitor visitor, ContextItemStaticInfo contextItemType) throws XPathException { optimizeChildren(visitor, contextItemType); boolean fixed = true; for (Operand o : operands()) { if (!(o.getChildExpression() instanceof Literal)) { fixed = false; break; } } return fixed ? preEvaluate(visitor) : this; }
/** * Type-check the expression. This also calls preEvaluate() to evaluate the function * if all the arguments are constant; functions that do not require this behavior * can override the preEvaluate method. */ public Expression typeCheck(ExpressionVisitor visitor, ItemType contextItemType) throws XPathException { boolean fixed = true; for (int i=0; i<argument.length; i++) { Expression exp = visitor.typeCheck(argument[i], contextItemType); if (exp != argument[i]) { adoptChildExpression(exp); argument[i] = exp; } if (!(argument[i] instanceof Literal)) { fixed = false; } } checkArguments(visitor); if (fixed) { try { return preEvaluate(visitor); } catch (NoDynamicContextException err) { // Early evaluation failed, typically because the implicit timezone is not yet known. // Try again later at run-time. return this; } } else { return this; } }
/** * Type-check the expression. This also calls preEvaluate() to evaluate the function * if all the arguments are constant; functions that do not require this behavior * can override the preEvaluate method. */ public Expression typeCheck(ExpressionVisitor visitor, ItemType contextItemType) throws XPathException { boolean fixed = true; for (int i=0; i<argument.length; i++) { Expression exp = visitor.typeCheck(argument[i], contextItemType); if (exp != argument[i]) { adoptChildExpression(exp); argument[i] = exp; } if (!(argument[i] instanceof Literal)) { fixed = false; } } checkArguments(visitor); if (fixed) { try { return preEvaluate(visitor); } catch (NoDynamicContextException err) { // Early evaluation failed, typically because the implicit timezone is not yet known. // Try again later at run-time. return this; } } else { return this; } }
/** * Type-check the expression. This also calls preEvaluate() to evaluate the function * if all the arguments are constant; functions that do not require this behavior * can override the preEvaluate method. */ public Expression typeCheck(ExpressionVisitor visitor, ItemType contextItemType) throws XPathException { boolean fixed = true; for (int i=0; i<argument.length; i++) { Expression exp = visitor.typeCheck(argument[i], contextItemType); if (exp != argument[i]) { adoptChildExpression(exp); argument[i] = exp; } if (!(argument[i] instanceof Literal)) { fixed = false; } } checkArguments(visitor); if (fixed) { try { return preEvaluate(visitor); } catch (NoDynamicContextException err) { // Early evaluation failed, typically because the implicit timezone is not yet known. // Try again later at run-time. return this; } } else { return this; } }
return preEvaluate(visitor); } else { return this;
return preEvaluate(visitor); } else { return this;
return preEvaluate(visitor); } else { return this;