Package xbird.xquery.dm.value

Examples of xbird.xquery.dm.value.Item


        return s;
    }

    public XString eval(Sequence<? extends Item> contextSeq, ValueSequence argv, DynamicContext dynEnv)
            throws XQueryException {
        Item firstItem = argv.getItem(0);
        if(firstItem.isEmpty()) {
            // If the value of $arg is the empty sequence, the zero-length string is returned.
            return XString.valueOf("");
        }
        Item secItem = argv.getItem(1);
        Item thirdItem = argv.getItem(2);
        String src = firstItem.stringValue();
        String map = secItem.stringValue();
        String trans = thirdItem.stringValue();
        String translated = translate(src, map, trans);
        return XString.valueOf(translated);
    }
View Full Code Here


            throw new IllegalArgumentException("Illegal fetch size: " + size);
        }
        final Item[] result = new Item[size];
        int actsize = 0;
        while(actsize < size) {
            final Item e;
            try {
                e = _queue.take();
            } catch (InterruptedException ie) {
                throw new RemoteException(ie.getMessage(), ie);
            }
View Full Code Here

        public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
            //this._type = (Type) in.readObject();
            final List<Item> decodedItems = _decodedItems;
            final int numDecoded = in.readInt();
            for(int i = 0; i < numDecoded; i++) {
                Item item = (Item) in.readObject();
                decodedItems.add(item);
            }
            final boolean decodeFinished = in.readBoolean();
            if(decodeFinished) {
                this._decodeFinished = true;
View Full Code Here

            //out.writeObject(_type);
            final List<Item> decodedItems = _decodedItems;
            final int numDecoded = decodedItems.size();
            out.writeInt(numDecoded);
            for(int i = 0; i < numDecoded; i++) {
                Item item = decodedItems.get(i);
                out.writeObject(item);
            }
            final boolean decodeFinished = _decodeFinished;
            if(decodeFinished) {
                out.writeBoolean(true);
View Full Code Here

            final List<Item> decodedItems = _decodedItems;
            final int decodedCount = decodedItems.size();
            final int curPos = focus.getContextPosition();
            if(curPos < decodedCount) {
                final Item it = decodedItems.get(curPos);
                if(it == null) {
                    throw new IllegalStateException();
                }
                focus.setContextItem(it);
                return true;
            }

            if(_decodeFinished) {
                focus.setReachedEnd(true);
                focus.closeQuietly();
                if(!_reaccessable) {//TODO
                    this._decodedItems = Collections.emptyList();
                }
                return false;
            }
            final XDMTreeBuilder treeBuilder = _treeBuilder;
            final int last = _decodeUnit - 1;
            for(int i = 0; i < _decodeUnit; i++) {
                final Item item;
                try {
                    item = _decoder.decodeItem(treeBuilder);
                } catch (IOException e) {
                    throw new XQueryException("failed decoding an Item", e);
                } finally {
View Full Code Here

    }

    public Sequence eval(Sequence<? extends Item> contextSeq, ValueSequence argv, DynamicContext dynEnv) throws XQueryException {
        assert (argv != null && argv.size() == 2);
        // If either argument is the empty sequence, the result is the empty sequence.
        Item firstItem = argv.getItem(0);
        if(firstItem.isEmpty()) {
            return ValueSequence.EMPTY_SEQUENCE;
        }
        Item secondItem = argv.getItem(1);
        if(secondItem.isEmpty()) {
            return ValueSequence.EMPTY_SEQUENCE;
        }
        String comparand1 = firstItem.stringValue();
        String comparand2 = secondItem.stringValue();
        final boolean b = comparand1.equals(comparand2);
        return b ? BooleanValue.TRUE : BooleanValue.FALSE;
    }
View Full Code Here

        return s;
    }

    public Sequence eval(Sequence<? extends Item> contextSeq, ValueSequence argv, DynamicContext dynEnv)
            throws XQueryException {
        Item arg1 = argv.getItem(0);
        Item arg2 = argv.getItem(1);
        DateTimeValue date = (DateTimeValue) arg1;
        DateTimeValue time = (DateTimeValue) arg2;
        XMLGregorianCalendar dateValue = date.getValue();
        XMLGregorianCalendar newValue = (XMLGregorianCalendar) dateValue.clone();
        XMLGregorianCalendar timeValue = time.getValue();
View Full Code Here

    }

    public Sequence eval(Sequence<? extends Item> contextSeq, ValueSequence argv, DynamicContext dynEnv)
            throws XQueryException {
        final int arglen = argv.size();
        Item first = argv.getItem(0);
        DateTimeValue arg = (DateTimeValue) first;
        XMLGregorianCalendar cal = arg.getValue();
        final long utcOffsetInMillis;
        if(arglen == 1) {
            TimeZone tz = dynEnv.implicitTimezone();
            utcOffsetInMillis = tz.getRawOffset();
        } else if(arglen == 2) {
            Item sec = argv.getItem(1);
            if(sec.isEmpty()) {
                cal.setTimezone(DatatypeConstants.FIELD_UNDEFINED);
                return arg;
            } else {
                Type secType = sec.getType();
                if(!TypeUtil.subtypeOf(secType, DayTimeDurationType.DAYTIME_DURATION)) {
                    throw new IllegalStateException("second argument is expected to be xdt:dayTimeDuration, but was "
                            + secType);
                }
                DurationValue dv = (DurationValue) sec;
View Full Code Here

            throw new IllegalArgumentException();
        }
        // NaN does not equal itself, if $arg contains multiple NaN values
        // a single NaN is returned.
        // TODO handle collation
        Item arg = argv.getItem(0);
        return DistinctSequence.<Item> wrap(arg, dynEnv);
    }
View Full Code Here

        return this;
    }

    public Sequence eval(Sequence<? extends Item> contextSeq, ValueSequence argv, DynamicContext dynEnv)
            throws XQueryException {
        Item arg = argv.getItem(0);
        final Type.Occurrence quantifier = arg.getType().quantifier();
        if(!Type.Occurrence.OCC_EXACTLY_ONE.accepts(quantifier.getAlignment())) {
            Iterator<? extends Item> argItor = arg.iterator();
            if(!argItor.hasNext()) {
                throw new DynamicError("err:FORG0005", "Item not found");
            }
            Item first = argItor.next();
            if(argItor.hasNext()) {
                // Returns $arg if it contains one or more items. Otherwise, raises an error [err:FORG0004].
                throw new DynamicError("err:FORG0005", "Sequence has more than one items");
            }
            return first;
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.