Package xbird.xquery.dm.value

Examples of xbird.xquery.dm.value.Item


        return value.roundHalfToEven(scale);
    }

    public Sequence eval(Sequence<? extends Item> contextSeq, ValueSequence argv, DynamicContext dynEnv)
            throws XQueryException {
        Item arg = argv.getItem(0);
        Iterator<? extends Item> argItor = arg.iterator();
        if(!argItor.hasNext()) {
            return ValueSequence.EMPTY_SEQUENCE;
        }
        Item firstItem = argItor.next();
        if(firstItem instanceof UntypedAtomicValue) {
            firstItem = ((UntypedAtomicValue) firstItem).castAs(DoubleType.DOUBLE, dynEnv);
        }
        if(firstItem instanceof XNumber) {
            XNumber num = (XNumber) firstItem;
            final int scale;
            final int args = argv.size();
            if(args > 1) {
                Item precision = argv.getItem(1);
                if(!(precision instanceof XInteger)) {
                    throw new DynamicError("err:FORG0006", "second argument type for precision is invalid: "
                            + precision.getType());
                }
                scale = ((XInteger) precision).getNumber().intValue();
            } else {
                scale = 0;
            }
View Full Code Here


                if(curidx > _to || !srcItor.hasNext()) {
                    srcItor.closeQuietly();
                    focus.setReachedEnd(true);
                    return false;
                }
                Item it = srcItor.next();
                if(curidx >= _from) {
                    focus.setContextItem(it);
                    return true;
                }
            }
View Full Code Here

    }

    public Sequence eval(Sequence<? extends Item> contextSeq, ValueSequence argv, DynamicContext dynEnv) throws XQueryException {
        assert (argv != null && argv.size() == 1) : "argument must be one, but was "
                + argv.size();
        Item firstItem = argv.getItem(0);
        if(firstItem.isEmpty()) {
            return ValueSequence.EMPTY_SEQUENCE;
        }
        final String query = firstItem.stringValue();
        final Sequence res = evaluateQuery(query, dynEnv);
        return res;
    }
View Full Code Here

            if(focus.reachedEnd()) {
                return false;
            }
            Iterator<? extends Item> itor = focus.getBaseFocus();
            while(itor.hasNext()) {
                final Item it = itor.next();
                if(!itor.hasNext()) {
                    focus.setContextItem(it);
                    focus.setReachedEnd(true);
                    return true;
                }
View Full Code Here

        }

        public boolean next(IFocus focus) throws XQueryException {
            final Iterator<? extends Item> itor = focus.getBaseFocus();
            while(itor.hasNext()) {
                final Item it = itor.next();
                final Sequence cond = predicate.eval(it, _dynEnv);
                if(!cond.isEmpty()) {
                    focus.setContextItem(it);
                    focus.setReachedEnd(true);
                    return true;
View Full Code Here

        public boolean next(IFocus focus) throws XQueryException {
            final DynamicContext dynEnv = _dynEnv;
            Iterator<? extends Item> itor = focus.getBaseFocus();
            while(itor.hasNext()) {
                int curidx = focus.incrPosition();
                Item it = itor.next();
                focus.setContextItem(it);

                // REVIEWME workaround for fn:last()
                dynEnv.pushSequence(_delegate);
View Full Code Here

        return this;
    }

    public Sequence<? extends Item> eval(Sequence<? extends Item> contextSeq, DynamicContext dynEnv)
            throws XQueryException {
        final Item v1 = _expr.evalAsItem(contextSeq, dynEnv, true);
        if(v1 == null) {
            return ValueSequence.EMPTY_SEQUENCE;
        }
        Sequence res = _op.eval(dynEnv, v1);
        return res;
View Full Code Here

    public Sequence<? extends Item> eval(Sequence<? extends Item> contextSeq, DynamicContext dynEnv)
            throws XQueryException {
        if(!_analyzed) {
            _analyzed = false;
        }
        final Item v1 = _leftOperand.evalAsItem(contextSeq, dynEnv, true);
        if(v1 == null) {
            return ValueSequence.EMPTY_SEQUENCE;
        }
        final Item v2 = _rightOperand.evalAsItem(contextSeq, dynEnv, true);
        if(v2 == null) {
            return ValueSequence.EMPTY_SEQUENCE;
        }
        Sequence res = _op.eval(dynEnv, v1, v2);
        return res;
View Full Code Here

    protected abstract XNumber promote(XNumber value);

    public Sequence eval(Sequence<? extends Item> contextSeq, ValueSequence argv, DynamicContext dynEnv) throws XQueryException {
        assert (argv != null && argv.size() == 1);
        Item arg = argv.getItem(0);
        Iterator<? extends Item> argItor = arg.iterator();
        if (!argItor.hasNext()) {
            return ValueSequence.EMPTY_SEQUENCE;
        }
        Item firstItem = argItor.next();
        assert (!argItor.hasNext());
        if (firstItem instanceof UntypedAtomicValue) {
            firstItem = ((UntypedAtomicValue) firstItem).castAs(DoubleType.DOUBLE, dynEnv);
        }
        if (firstItem instanceof XNumber) {
            XNumber num = (XNumber) firstItem;
            XNumber promoted = promote(num);
            return promoted;
        } else {
            throw new DynamicError("err:FORG0006", "Invalid argument type: " + firstItem.getType());
        }
    }
View Full Code Here

        return this;
    }

    public Sequence<? extends Item> eval(Sequence<? extends Item> contextSeq, DynamicContext dynEnv)
            throws XQueryException {
        final Item v1 = _leftOperand.evalAsItem(contextSeq, dynEnv, true);
        if(v1 == null) {
            return ValueSequence.EMPTY_SEQUENCE;
        }
        final Item v2 = _rightOperand.evalAsItem(contextSeq, dynEnv, true);
        if(v2 == null) {
            return ValueSequence.EMPTY_SEQUENCE;
        }
        Sequence res = _op.eval(dynEnv, v1, v2);
        return res;
View Full Code Here

TOP

Related Classes of xbird.xquery.dm.value.Item

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.