Package xbird.xquery.type

Examples of xbird.xquery.type.Type


            throws XQueryException {
        final int size = params.length;
        final Type[] t = new Type[size];
        for(int i = 0; i < size; i++) {
            params[i].staticAnalysis(context);
            final Type type = params[i].getType();
            Type prime = type.prime();
            if(prime == Type.NONE) {
                throw new DynamicError("err:FOER0000", "User-requested error");
            }
            t[i] = prime;
        }
View Full Code Here


        for(Item item : result) {// Note that every Sequence instances implement Iterable.
            // get string value
            String stringValue = item.stringValue();
            // get type
            Type itemType = item.getType();
            if(TypeUtil.subtypeOf(itemType, NodeType.ELEMENT)) {
                // the Item is element               
            } else if(TypeUtil.instanceOf(item, NodeType.TEXT)) {
                // another variant
            }
View Full Code Here

        super(SYMBOL, TypeRegistry.safeGet("xs:anyAtomicType?"));
    }

    protected FunctionSignature[] signatures() {
        final FunctionSignature[] s = new FunctionSignature[2];
        Type anyatom = TypeRegistry.safeGet("xs:anyAtomicType*");
        s[0] = new FunctionSignature(getName(), new Type[] { anyatom });
        s[1] = new FunctionSignature(getName(), new Type[] { anyatom, StringType.STRING });
        return s;
    }
View Full Code Here

            firstItem = ((UntypedAtomicValue) firstItem).castAs(DoubleType.DOUBLE, dynEnv);
        }
        if(!argItor.hasNext()) {
            return firstItem;
        }
        final Type firstType = firstItem.getType();
        if(firstItem instanceof XNumber) {
            XNumber min = (XNumber) firstItem;
            // If the converted sequence contains the value NaN, the value NaN is returned.
            if(min.isNaN()) {
                return min;
            }
            while(argItor.hasNext()) {
                Item it = argItor.next();
                if(it instanceof UntypedAtomicValue) {
                    it = ((UntypedAtomicValue) it).castAs(DoubleType.DOUBLE, dynEnv);
                } else if(!(it instanceof XNumber)) {
                    throw new DynamicError("err:FORG0006", "fs:plus(" + min.getType() + ", "
                            + it.getType() + ") is not defined.");
                }
                XNumber cmp = (XNumber) it;
                if(cmp.isNaN()) {
                    return cmp;
                }
                if(cmp.compareTo(min) < 0) {
                    min = cmp;
                }
            }
            return min;
        } else if(firstItem instanceof DurationValue) {
            // Duration values must either all be xdt:yearMonthDuration values
            // or must all be xdt:dayTimeDuration values.
            DurationValue min = (DurationValue) firstItem;
            assert (firstType != null);
            while(argItor.hasNext()) {
                Item it = argItor.next();
                if(it instanceof DurationValue) {
                    throw new DynamicError("err:FORG0006", "Duration values must all be `"
                            + firstType + "`, but found `" + it.getType() + "`");
                }
                DurationValue cmp = (DurationValue) it;
                if(cmp.compareTo(min) < 0) {
                    min = cmp;
                }
            }
            return min;
        } else if(TypeUtil.subtypeOf(firstType, StringType.STRING)) {
            AtomicValue min = (AtomicValue) firstItem;
            final int arglen = argv.size();
            final Collator collator;
            if(arglen == 2) {
                Item sec = argv.getItem(1);
                Type secType = sec.getType();
                if(!TypeUtil.subtypeOf(secType, StringType.STRING)) {
                    throw new DynamicError("err:FORG0006", "second argument is expected to be xs:string, but was "
                            + secType);
                }
                String uri = sec.stringValue();
                collator = CollationUtils.resolve(uri, dynEnv.getStaticContext());
            } else {
                collator = Collator.getInstance(); // compare in default locale
            }
            while(argItor.hasNext()) {
                Item it = argItor.next();
                Type cmpType = it.getType();
                if(!TypeUtil.subtypeOf(cmpType, StringType.STRING)) {
                    throw new DynamicError("err:FORG0006", "imcomparable xs:string and " + cmpType);
                }
                if(collator.compare(it, firstItem) < 0) {
                    min = (AtomicValue) it;
View Full Code Here

    @Override
    public XQExpression visit(TreatExpr expr, XQueryContext ctxt) throws XQueryException {
        header("TreatExpr");
        indentln();
        expr.getExpression().visit(this, ctxt);
        Type t = expr.getType();
        if(t != null) {
            buf.append(" treat as ");
            buf.append(t.toString());
        }
        indent--;
        return expr;
    }
View Full Code Here

            }
            VarRef p = (VarRef) params.get(i);
            buf.append(p.toString());
        }
        buf.append(") ");
        Type returnType = function.getReturnType();
        if(returnType != null) {
            buf.append("as ");
            buf.append(returnType.toString());
        }
        buf.append(" {");
        indentln();
        function.getBodyExpression().visit(this, ctxt);
        indent--;
View Full Code Here

            this._entity = null;
        }
    }

    public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
        final Type type = (Type) in.readObject();
        this._type = type;
        final boolean redirectable = in.readBoolean();
        if(redirectable) {
            this._redirectable = true;
            this._entity = (Sequence<Item>) in.readObject();
View Full Code Here

    @Override
    public XQExpression visit(Variable variable, XQueryContext ctxt) throws XQueryException {
        String name = variable.getName();
        buf.append("$" + name);
        Type type = variable.getType();
        if(type != null) {
            buf.append(" as ");
            buf.append(type);
        }
        XQExpression value = variable.getValue();
View Full Code Here

    @Override
    public AtomicValue typedValue() {
        if(_typedValue != null) {
            return _typedValue;
        }
        Type t = TypeRegistry.safeGet(typeName());
        assert (t != null);
        Type mixed = new ComplexType(ContentType.MixedContent);
        if(TypeUtil.subtypeOf(t, Untyped.UNTYPED) || TypeUtil.subtypeOf(t, mixed)) {
            // - If the element is of type xdt:untyped,
            //  its typed-value is its dm:string-value as an xdt:untypedAtomic.
            // - If the element has a complex type with mixed content (including xs:anyType),
            //  its typed-value is its dm:string-value as an xdt:untypedAtomic.
View Full Code Here

        super(SYMBOL, TypeRegistry.safeGet("xs:boolean?"));
    }

    protected FunctionSignature[] signatures() {
        final FunctionSignature[] s = new FunctionSignature[1];
        Type str = TypeRegistry.safeGet("xs:string?");
        s[0] = new FunctionSignature(getName(), new Type[] { str, str });
        return s;
    }
View Full Code Here

TOP

Related Classes of xbird.xquery.type.Type

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.