Package xbird.xquery.dm.value

Examples of xbird.xquery.dm.value.Item


        return new FunctionSignature[] { new FunctionSignature(getName(), new Type[] { ItemType.ANY_ITEM }) };
    }

    public Sequence eval(Sequence<? extends Item> contextSeq, ValueSequence argv, DynamicContext dynEnv)
            throws XQueryException {
        Item firstItem = argv.getItem(0);
        String str = firstItem.stringValue();
        int hashvalue = str.hashCode();
        return new XInteger(hashvalue);
    }
View Full Code Here


        return s;
    }

    public Sequence eval(Sequence<? extends Item> contextSeq, ValueSequence argv, DynamicContext dynEnv) throws XQueryException {
        assert (argv != null && argv.size() == 1);
        Item sourceSeq = argv.getItem(0);
        // TODO any optim?
        return sourceSeq;
    }
View Full Code Here

    }

    public BooleanValue eval(Sequence<? extends Item> contextSeq, ValueSequence argv, DynamicContext dynEnv)
            throws XQueryException {
        final int arglen = argv.size();
        Item firstItem = argv.getItem(0);
        // If $input is the empty sequence, it is interpreted as the zero-length string.
        String input = firstItem.isEmpty() ? "" : firstItem.stringValue();
        Item secondItem = argv.getItem(1);
        String pattern = secondItem.stringValue();
        int flags = Pattern.UNIX_LINES;
        if(arglen == 3) {
            Item thirdItem = argv.getItem(2);
            String flagsStr = thirdItem.stringValue();
            flags = convertFlags(flagsStr);
        }
        final Pattern compiled;
        try {
            compiled = Pattern.compile(pattern, flags);
View Full Code Here

        return s;
    }

    public ChainedSequence eval(Sequence<? extends Item> contextSeq, ValueSequence argv, DynamicContext dynEnv)
            throws XQueryException {
        Item firstItem = argv.getItem(0);
        Item secItem = argv.getItem(1);
        return new ChainedSequence(firstItem, secItem, dynEnv);
    }
View Full Code Here

            if(focuss.reachedEnd()) {
                return false;
            }
            final IFocus<? extends Item> remaining = focuss.getRemaining();
            if(remaining != null && remaining.hasNext()) {
                final Item it = remaining.next();
                focuss.setContextItem(it);
                return true;
            }
            final int exprlen = _exprs.size();
            while(focuss.incrExprPosition() < exprlen) {
                final int at = focuss.getExprPosition();
                final XQExpression e = _exprs.get(at);
                final Sequence<? extends Item> res = e.eval(_contextSeq, _dynEnv);
                final IFocus<? extends Item> resItor = res.iterator();
                if(resItor.hasNext()) {
                    final Item it = resItor.next();
                    focuss.setContextItem(it);
                    focuss.setRemaining(resItor);
                    return true;
                }
            }
View Full Code Here

        return _returnType;
    }

    public Sequence eval(Sequence<? extends Item> contextSeq, ValueSequence argv, DynamicContext dynEnv)
            throws XQueryException {
        Item src = argv.getItem(0);
        Item fromIt = argv.getItem(1);
        final int from = ((XNumber) fromIt).getNumber().intValue();
        final int arglen = argv.size();
        if(arglen == 2) {
            return new FilterExpr.Sliced(src, from, Integer.MAX_VALUE, dynEnv, getReturnType());
        }
        Item lengthIt = argv.getItem(2);
        final int length = ((XNumber) lengthIt).getNumber().intValue(); //TODO exceeds Integer.MAX
        if(length < 1) {
            return ValueSequence.EMPTY_SEQUENCE;
        }
        return new FilterExpr.Sliced(src, from, from + length - 1, dynEnv, getReturnType());
View Full Code Here

            throws XQueryException {
        final String arg;
        if(argv == null) {
            // If no argument is supplied, $arg defaults to the string value of the context item (.).
            // If no argument is supplied and the context item is undefined an error is raised: [err:XPDY0002]
            Item contextItem = dynEnv.contextItem();
            if(contextItem == null) {
                throw new DynamicError("err:XPDY0002", "ContextItem is not set");
            }
            arg = contextItem.stringValue();
        } else {
            // If the value of $arg is the empty sequence, returns the zero-length string.
            Item first = argv.getItem(0);
            arg = first.stringValue();
        }
        String normed = XMLUtils.normalizeString(arg);
        return XString.valueOf(normed);
    }
View Full Code Here

    }

    public Sequence eval(Sequence<? extends Item> contextSeq, ValueSequence argv, DynamicContext dynEnv)
            throws XQueryException {
        assert (argv != null && argv.size() == 2);
        final Item arg = argv.getItem(0);
        if(arg.isEmpty()) {
            // If the value of $arg1 is the empty sequence, the zero-length string is returned.
            return XString.valueOf("");
        }
        final Item sep = argv.getItem(1);
        final String separator = sep.stringValue();
        final StringBuilder buf = new StringBuilder(256);
        boolean first = true;
        for(Item it : arg) {
            if(first) {
                first = false;
View Full Code Here

    public Sequence eval(Sequence<? extends Item> contextSeq, ValueSequence argv, DynamicContext dynEnv) throws XQueryException {
        if(argv == null || argv.size() != 2) {
            throw new IllegalStateException();
        }
        Item arg1 = argv.getItem(0);
        String docPath = arg1.stringValue();
        Item arg2 = argv.getItem(1);
        String colPath = arg2.stringValue();
        File docFile = new File(docPath);
        if(!docFile.exists()) {
            return ValueSequence.EMPTY_SEQUENCE;
        }
        DbCollection col = DbCollection.getCollection(colPath);
View Full Code Here

    }

    public XString eval(Sequence<? extends Item> contextSeq, ValueSequence argv, DynamicContext dynEnv)
            throws XQueryException {
        // If $uri-part is the empty sequence, returns the zero-length string.
        Item firstItem = argv.getItem(0);
        if(firstItem.isEmpty()) {
            return XString.valueOf("");
        }
        assert (firstItem instanceof XString);
        String uripart = firstItem.stringValue();
        String escaped = XMLUtils.escapeUri(uripart, true);
        return XString.valueOf(escaped);
    }
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.