Package xbird.xquery.meta

Examples of xbird.xquery.meta.IFocus


                final Sequence[] rawKeys = new Sequence[len];
                for(int i = 0; i < len; i++) {
                    GroupingSpec spec = specs[i];
                    Sequence result = spec.getKeyExpr().eval(contextSeq, dynEnv);
                    Sequence atomized = result.atomize(dynEnv);
                    IFocus atomizedItor = atomized.iterator();

                    final Item groupKey;
                    if(atomizedItor.hasNext()) {
                        AtomicValue atom = (AtomicValue) atomizedItor.next();
                        if(atomizedItor.hasNext()) {
                            atomizedItor.closeQuietly();
                            throw new DynamicError("err:XQDY0095", "Illegal resulting value for a grouping variable: "
                                    + atomized);
                        }
                        groupKey = atom.asGroupingValue();
                    } else {
                        groupKey = ValueSequence.EMPTY_SEQUENCE;
                    }
                    atomizedItor.closeQuietly();

                    groupKeys[i] = groupKey;
                    rawKeys[i] = result;
                }
View Full Code Here


        this.secItem = secItem;
    }

    @Override
    public IFocus<Item> iterator() {
        IFocus firstItor = firstItem.iterator();
        IFocus secItor = secItem.iterator();
        ChainedIterator<Item> pipedItor = new ChainedIterator<Item>(firstItor, secItor);
        return new Focus<Item>(this, pipedItor, _dynEnv);
    }
View Full Code Here

            Item it = itor.next();
            focus.setContextItem(it);
            return true;
        }
        focus.setReachedEnd(true);
        IFocus firstItor = (IFocus) itor.getFirstIterator();
        firstItor.closeQuietly();
        IFocus secItor = (IFocus) itor.getSecondIterator();
        secItor.closeQuietly();
        return false;
    }
View Full Code Here

            // Item is subclass of Sequence, thus it can also be converted to SAX events.
            ser.emit(item);
        }

        // The above 'for each' is equivalent to the following expression.
        IFocus focus = result.iterator(); // IFocus extends Iterable
        while(result.next(focus)) {
            Item item = focus.getContextItem();
            // ..
        }
    }
View Full Code Here

        return s;
    }

    public Sequence eval(Sequence<? extends Item> contextSeq, ValueSequence argv, DynamicContext dynEnv)
            throws XQueryException {
        IFocus focus = dynEnv.getFocus();
        if(focus == null) {
            throw new DynamicError("err:XPDY0002", "ContentPosition is not set");
        }
        final int pos = focus.getPosition();
        return XInteger.valueOf(pos);
    }
View Full Code Here

        return s;
    }

    public Sequence eval(Sequence<? extends Item> contextSeq, ValueSequence argv, DynamicContext dynEnv)
            throws XQueryException {
        final IFocus focus = dynEnv.getFocus();
        if(focus == null) {
            throw new DynamicError("err:XPDY0002", "Focus of fileter is not set");
        }
        int last = focus.getLast();
        if(last != -1) {
            return new XInteger(last);
        }
        final Sequence<? extends Item> src = dynEnv.peekSequence();
        if(src == null) {
            throw new DynamicError("err:XPDY0002", "Source of fileter is not set");
        }
        last = 0;
        IFocus<? extends Item> srcItor = src.iterator();
        for(Item it : srcItor) {
            ++last;
        }
        srcItor.closeQuietly();
        focus.setLast(last);
        return new XInteger(last);
    }
View Full Code Here

            this._insertPos = insertPos;
        }

        @Override
        public IFocus iterator() {
            final IFocus focus = super.iterator();
            this._insertItor = _inserts.iterator();
            this._reachedEnd = false;
            return focus;
        }
View Full Code Here

                // REVIEWME workaround for fn:last()
                dynEnv.pushSequence(_delegate);

                // evaluates predicate
                IFocus baseFocus = dynEnv.getFocus();
                dynEnv.setFocus(focus); // change focus
                Sequence cond = predicate.eval(it, dynEnv);
                dynEnv.setFocus(baseFocus);

                // workaround for fn:last()
View Full Code Here

TOP

Related Classes of xbird.xquery.meta.IFocus

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.