/** * 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); }
/** * 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); }
/** * Copy an expression. This makes a deep copy. * * @return the copy of the original expression * @param rebindings */ /*@NotNull*/ public Expression copy(RebindingMap rebindings) { RangeExpression exp = new RangeExpression(getLhsExpression().copy(rebindings), getRhsExpression().copy(rebindings)); ExpressionTool.copyLocationInfo(this, exp); return exp; }
/** * Copy an expression. This makes a deep copy. * * @return the copy of the original expression * @param rebindings */ /*@NotNull*/ public Expression copy(RebindingMap rebindings) { RangeExpression exp = new RangeExpression(getLhsExpression().copy(rebindings), getRhsExpression().copy(rebindings)); ExpressionTool.copyLocationInfo(this, exp); return exp; }
/** * Diagnostic print of expression structure. The abstract expression tree * is written to the supplied output destination. * * @param out the output destination for the displayed expression tree */ @Override public void export(ExpressionPresenter out) throws XPathException { out.startElement("to", this); getLhsExpression().export(out); getRhsExpression().export(out); out.endElement(); }
/** * Diagnostic print of expression structure. The abstract expression tree * is written to the supplied output destination. * * @param out the output destination for the displayed expression tree */ @Override public void export(ExpressionPresenter out) throws XPathException { out.startElement("to", this); getLhsExpression().export(out); getRhsExpression().export(out); out.endElement(); }
private Expression makeConstantRange() throws XPathException { if (getLhsExpression() instanceof Literal && getRhsExpression() instanceof Literal) { GroundedValue v0 = ((Literal) getLhsExpression()).getValue(); GroundedValue v1 = ((Literal) getRhsExpression()).getValue(); if (v0 instanceof Int64Value && v1 instanceof Int64Value) { long i0 = ((Int64Value) v0).longValue(); long i1 = ((Int64Value) v1).longValue(); Literal result; if (i0 > i1) { result = Literal.makeEmptySequence(); } else if (i0 == i1) { result = Literal.makeLiteral(Int64Value.makeIntegerValue(i0), this); } else { if (i1 - i0 > Integer.MAX_VALUE) { throw new XPathException("Maximum length of sequence in Saxon is " + Integer.MAX_VALUE, "XPDY0130"); } result = Literal.makeLiteral(new IntegerRange(i0, i1), this); } ExpressionTool.copyLocationInfo(this, result); return result; } } return this; }
private Expression makeConstantRange() throws XPathException { if (getLhsExpression() instanceof Literal && getRhsExpression() instanceof Literal) { GroundedValue v0 = ((Literal) getLhsExpression()).getValue(); GroundedValue v1 = ((Literal) getRhsExpression()).getValue(); if (v0 instanceof Int64Value && v1 instanceof Int64Value) { long i0 = ((Int64Value) v0).longValue(); long i1 = ((Int64Value) v1).longValue(); Literal result; if (i0 > i1) { result = Literal.makeEmptySequence(); } else if (i0 == i1) { result = Literal.makeLiteral(Int64Value.makeIntegerValue(i0), this); } else { if (i1 - i0 > Integer.MAX_VALUE) { throw new XPathException("Maximum length of sequence in Saxon is " + Integer.MAX_VALUE, "XPDY0130"); } result = Literal.makeLiteral(new IntegerRange(i0, i1), this); } ExpressionTool.copyLocationInfo(this, result); return result; } } return this; }
/** * Type-check the expression */ /*@NotNull*/ public Expression typeCheck(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo) throws XPathException { getLhs().typeCheck(visitor, contextInfo); getRhs().typeCheck(visitor, contextInfo); boolean backCompat = visitor.getStaticContext().isInBackwardsCompatibleMode(); TypeChecker tc = visitor.getConfiguration().getTypeChecker(backCompat); RoleDiagnostic role0 = new RoleDiagnostic(RoleDiagnostic.BINARY_EXPR, "to", 0); setLhsExpression(tc.staticTypeCheck( getLhsExpression(), SequenceType.OPTIONAL_INTEGER, role0, visitor)); RoleDiagnostic role1 = new RoleDiagnostic(RoleDiagnostic.BINARY_EXPR, "to", 1); setRhsExpression(tc.staticTypeCheck( getRhsExpression(), SequenceType.OPTIONAL_INTEGER, role1, visitor)); return makeConstantRange(); }
/** * Type-check the expression */ /*@NotNull*/ public Expression typeCheck(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo) throws XPathException { getLhs().typeCheck(visitor, contextInfo); getRhs().typeCheck(visitor, contextInfo); boolean backCompat = visitor.getStaticContext().isInBackwardsCompatibleMode(); TypeChecker tc = visitor.getConfiguration().getTypeChecker(backCompat); RoleDiagnostic role0 = new RoleDiagnostic(RoleDiagnostic.BINARY_EXPR, "to", 0); setLhsExpression(tc.staticTypeCheck( getLhsExpression(), SequenceType.OPTIONAL_INTEGER, role0, visitor)); RoleDiagnostic role1 = new RoleDiagnostic(RoleDiagnostic.BINARY_EXPR, "to", 1); setRhsExpression(tc.staticTypeCheck( getRhsExpression(), SequenceType.OPTIONAL_INTEGER, role1, visitor)); return makeConstantRange(); }
Expression max = ((RangeExpression) getLhsExpression()).getRhsExpression(); IntegerRangeTest ir = new IntegerRangeTest(getRhsExpression(), min, max); ExpressionTool.copyLocationInfo(this, ir); Expression max = ((RangeExpression) getRhsExpression()).getRhsExpression(); IntegerRangeTest ir = new IntegerRangeTest(getLhsExpression(), min, max); ExpressionTool.copyLocationInfo(this, ir);
Expression max = ((RangeExpression) getLhsExpression()).getRhsExpression(); IntegerRangeTest ir = new IntegerRangeTest(getRhsExpression(), min, max); ExpressionTool.copyLocationInfo(this, ir); Expression max = ((RangeExpression) getRhsExpression()).getRhsExpression(); IntegerRangeTest ir = new IntegerRangeTest(getLhsExpression(), min, max); ExpressionTool.copyLocationInfo(this, ir);