@Deprecated public static boolean typeof(final XPathContext context, final String nodeTypeName, final String fullTypeName, final String shortTypeName) { return TypeOfFunction.typeof((Node) ((ElementNode) context.getContextItem()).getUnderlyingNode(), nodeTypeName, fullTypeName, shortTypeName); }
public Expression optimize(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo) throws XPathException { getOperand().optimize(visitor, contextInfo); if (Literal.isConstantOne(getSubscript())) { return FirstItemExpression.makeFirstItemExpression(getBaseExpression()); } return this; }
/** * Get the effective boolean value. In the case of a union expression, this * is reduced to an OR expression, for efficiency */ public boolean effectiveBooleanValue(final XPathContext context) throws XPathException { if (operator == Token.UNION) { // NOTE: this optimization was probably already done statically return getLhsExpression().effectiveBooleanValue(context) || getRhsExpression().effectiveBooleanValue(context); } else { return super.effectiveBooleanValue(context); } }
/** * Iterate over the sequence of values */ /*@NotNull*/ public SequenceIterator<?> iterate(XPathContext context) throws XPathException { SequenceIterator<?> base = getBaseExpression().iterate(context); return new ItemMappingIterator<>(base, getMappingFunction(context), true); }
/** * Get the mapping function used to implement this item check. This mapping function is applied * to each item in the input sequence. * * @param context The dynamic context used to evaluate the mapping function * @return the mapping function. This will be an identity mapping: the output sequence is the same * as the input sequence, unless the dynamic type checking reveals an error. */ public ItemMappingFunction<Item<?>, Item<?>> getMappingFunction(XPathContext context) { return new ItemTypeCheckingFunction(requiredItemType, role, getBaseExpression(), context.getConfiguration()); }
/** * Check to ensure that this expression does not contain any updating subexpressions. * This check is overridden for those expressions that permit updating subexpressions. * * @throws net.sf.saxon.trans.XPathException * if the expression has a non-permitted updateing subexpression */ public void checkForUpdatingSubexpressions() throws XPathException { getSequence().checkForUpdatingSubexpressions(); getAction().checkForUpdatingSubexpressions(); }
/** * Simplify and validate. * @param visitor an expression visitor */ public Expression simplify(ExpressionVisitor visitor) throws XPathException { Atomizer a = new Atomizer(argument[0], visitor.getConfiguration()); ExpressionTool.copyLocationInfo(this, a); return visitor.simplify(a); }
/** * The toString() method for an expression attempts to give a representation of the expression * in an XPath-like form, but there is no guarantee that the syntax will actually be true XPath. * In the case of XSLT instructions, the toString() method gives an abstracted view of the syntax */ @Override public String toString() { return "data(" + getBaseExpression().toString() + ")"; }
private void requestTailCall(XPathContext context, Sequence<?>[] actualArgs) { if (bindingSlot >= 0) { TailCallLoop.TailCallComponent info = new TailCallLoop.TailCallComponent(); Component target = getTargetComponent(context); info.component = target; info.function = (UserFunction) target.getActor(); ((XPathContextMajor) context).requestTailCall(info, actualArgs); } else { TailCallLoop.TailCallFunction info = new TailCallLoop.TailCallFunction(); info.function = function; ((XPathContextMajor) context).requestTailCall(info, actualArgs); } }
/** * Get an iterator that returns the result of atomizing the sequence delivered by the supplied * iterator * @param base the supplied iterator, the input to atomization * @return an iterator that returns atomic values, the result of the atomization */ public static SequenceIterator getAtomizingIterator(SequenceIterator base) { if (base instanceof AxisIterator) { return new AxisAtomizingIterator((AxisIterator)base); } return new MappingIterator(base, AtomizingFunction.getInstance()); }
@Override public Expression optimize(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo) throws XPathException { if (getBaseExpression() instanceof HomogeneityChecker) { return getBaseExpression().optimize(visitor, contextInfo); } return super.optimize(visitor, contextInfo); }
@Override public Expression simplify() throws XPathException { Expression operand = getBaseExpression(); if (operand instanceof Literal && ((Literal) operand).getValue() instanceof AtomicValue) { return operand; } else { return super.simplify(); } }
/** * Return an iteration over the sequence */ /*@NotNull*/ public SequenceIterator<?> iterate(XPathContext context) throws XPathException { IntegerValue av1 = (IntegerValue) getLhsExpression().evaluateItem(context); IntegerValue av2 = (IntegerValue) getRhsExpression().evaluateItem(context); return RangeIterator.makeRangeIterator(av1, av2); }
public Expression typeCheck(ExpressionVisitor visitor, ItemType contextItemType) throws XPathException { Expression oldop = operand; RoleLocator role = new RoleLocator(RoleLocator.UNARY_EXPR, "-", 0); operand = TypeChecker.staticTypeCheck(operand, SequenceType.OPTIONAL_NUMERIC, backwardsCompatible, role, visitor); operand = visitor.typeCheck(operand, contextItemType); if (operand != oldop) { adoptChildExpression(operand); } return this; }
@Override public int getCost() { // Assume the RHS will be evaluated 50% of the time return getLhsExpression().getCost() + getRhsExpression().getCost() / 2; }
/** * Produce a short string identifying the expression for use in error messages * * @return a short string, sufficient to identify the expression */ @Override public String toShortString() { return getLhsExpression().toShortString() + " " + Token.tokens[operator] + " " + comparand; }
public static boolean typeIsExactly(final XPathContext context, final String fullTypeName) { return TypeIsExactlyFunction.typeIsExactly((Node) ((ElementNode) context.getContextItem()).getUnderlyingNode(), fullTypeName); } }
public Expression optimize(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo) throws XPathException { getOperand().optimize(visitor, contextInfo); if (Literal.isConstantOne(getSubscript())) { return FirstItemExpression.makeFirstItemExpression(getBaseExpression()); } return this; }
public static double metric(final XPathContext context, final String metricKeyName) { return MetricFunction.getMetric((Node) ((ElementNode) context.getContextItem()).getUnderlyingNode(), metricKeyName); }
public static boolean typeIs(final XPathContext context, final String fullTypeName) { return TypeIsFunction.typeIs((Node) ((ElementNode) context.getContextItem()).getUnderlyingNode(), fullTypeName); }