Package xbird.xquery.dm.value.sequence

Examples of xbird.xquery.dm.value.sequence.ValueSequence


            if(LOG.isDebugEnabled()) {
                LOG.debug("materialized $" + getName() + "=> \n" + _value);
            }
            Sequence<? extends Item> result = _value.eval(contextSeq, dynEnv);
            List<? extends Item> materialized = result.materialize();
            ValueSequence vs = new ValueSequence(materialized, dynEnv);
            this._result = vs;
            return vs;
        }
View Full Code Here


            if(!merge.contains(n)) {
                merge.add(n);
            }
        }
        return merge.isEmpty() ? ValueSequence.emptySequence()
                : new ValueSequence(new ArrayList<XQNode>(merge), dynEnv);
    }
View Full Code Here

        final Item secondItem = secondItor.next();
        assert (!firstItor.hasNext());
        assert (!secondItor.hasNext());
        firstItor.closeQuietly();
        secondItor.closeQuietly();
        final ValueSequence newSeq = new ValueSequence(dynEnv);
        final int from = ((XInteger) firstItem).getNumber().intValue();
        final int to = ((XInteger) secondItem).getNumber().intValue();
        for(int i = from; i <= to; i++) {
            newSeq.addItem(new XInteger(i));
        }
        return newSeq;
    }
View Full Code Here

        }
    }

    public Sequence<? extends Item> eval(Sequence<? extends Item> contextSeq, DynamicContext dynEnv)
            throws XQueryException {
        final ValueSequence argv;
        final int arity = _params.size();
        if(arity == 0) {
            argv = null;
        } else {
            argv = new ValueSequence(dynEnv);
            FunctionSignature sign = func.getFunctionSignature(arity);
            for(int i = 0; i < arity; i++) {
                XQExpression p = _params.get(i);
                Sequence seq = p.eval(contextSeq, dynEnv);
                Sequence converted = mapFunctionArgument(seq, sign.getArgumentType(i), dynEnv);
                argv.addItem(SingleCollection.wrap(converted, dynEnv));
            }
        }
        return func.eval(contextSeq, argv, dynEnv);
    }
View Full Code Here

            if(!(expectedArgType instanceof AtomicType)) {
                throw new TypeError("expectedArgType must be built-in atomic type, but was "
                        + expectedArgType);
            }
            final AtomicType expected = (AtomicType) expectedArgType;
            final ValueSequence res = new ValueSequence(dynEnv);
            final IFocus<? extends Item> atomizedItor = argv.atomize(dynEnv).iterator();
            for(Item it : atomizedItor) {
                final Type actualType = it.getType();
                // apply fs:ConvertSimpleOperand
                if(actualType == UntypedAtomicType.UNTYPED_ATOMIC && expected.getTypeId() >= 0) {
                    final AtomicValue casted = ((AtomicValue) it).castAs(expected, dynEnv);
                    res.addItem(casted);
                } else {
                    res.addItem(it);
                }
            }
            atomizedItor.closeQuietly();
            return res.atomize(dynEnv);
        }
        return argv;
    }
View Full Code Here

        }
    }

    public Sequence<? extends Item> eval(Sequence<? extends Item> contextSeq, DynamicContext dynEnv)
            throws XQueryException {
        final ValueSequence argv;
        final int arity = _params.size();
        if(arity == 0) {
            argv = null;
        } else {
            argv = new ValueSequence(dynEnv);
            FunctionSignature sign = func.getFunctionSignature(arity);
            for(int i = 0; i < arity; i++) {
                XQExpression p = _params.get(i);
                Sequence seq = p.eval(contextSeq, dynEnv);
                Sequence converted = mapFunctionArgument(seq, sign.getArgumentType(i), dynEnv);
                argv.addItem(SingleCollection.wrap(converted, dynEnv));
            }
        }
        return func.eval(contextSeq, argv, dynEnv);
    }
View Full Code Here

            if(!(expectedArgType instanceof AtomicType)) {
                throw new TypeError("expectedArgType must be built-in atomic type, but was "
                        + expectedArgType);
            }
            final AtomicType expected = (AtomicType) expectedArgType;
            final ValueSequence res = new ValueSequence(dynEnv);
            final IFocus<? extends Item> atomizedItor = argv.atomize(dynEnv).iterator();
            for(Item it : atomizedItor) {
                final Type actualType = it.getType();
                // apply fs:ConvertSimpleOperand
                if(actualType == UntypedAtomicType.UNTYPED_ATOMIC && expected.getTypeId() >= 0) {
                    final AtomicValue casted = ((AtomicValue) it).castAs(expected, dynEnv);
                    res.addItem(casted);
                } else {
                    res.addItem(it);
                }
            }
            atomizedItor.closeQuietly();
            return res.atomize(dynEnv);
        }
        return argv;
    }
View Full Code Here

            if(LOG.isDebugEnabled()) {
                LOG.debug("materialized $" + getName() + "=> \n" + _value);
            }
            Sequence<? extends Item> result = _value.eval(contextSeq, dynEnv);
            List<? extends Item> materialized = result.materialize();
            ValueSequence vs = new ValueSequence(materialized, dynEnv);
            this._result = vs;
            return vs;
        }
View Full Code Here

        LetVariable lv = (LetVariable) _variable;
        XQExpression letExpr = lv.getValue();
        Sequence<? extends Item> res = letExpr.eval(contextSeq, dynEnv);
        if(lv.attemptEagarEvaluation() && lv.getReferenceCount() > 1) {
            List<? extends Item> items = res.materialize(); // TODO REVIEWME weak memory utilization
            lv.allocateResult(new ValueSequence(items, dynEnv), dynEnv);
        } else {
            lv.allocateResult(res, dynEnv);
        }
        return res;
    }
View Full Code Here

        final ReturnType returnType = request.getReturnType();
        final Serializable ret;
        switch(returnType) {
            case SEQUENCE:
                final List<Item> materialized = result.materialize();
                ret = new ValueSequence(materialized, dynEnv);
                break;
            case MARSHALLED_SEQUENCE:
                ret = new MarshalledSequence(result, dynEnv);
                break;
            case AUTO:
View Full Code Here

TOP

Related Classes of xbird.xquery.dm.value.sequence.ValueSequence

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.