Examples of DynamicError


Examples of xbird.xquery.DynamicError

        static final ModDecimal INSTANCE = new ModDecimal();

        public XDecimal eval(DynamicContext dynEnv, Item v1, Item v2) throws XQueryException {
            final BigDecimal divisor = asDecimal(v2, dynEnv);
            if(divisor.equals(BigDecimal.ZERO)) {
                throw new DynamicError("err:FOAR0001", "mod by zero");
            }
            BigDecimal bd1 = asDecimal(v1, dynEnv);
            BigDecimal res = bd1.remainder(divisor); // result may be negative
            return XDecimal.valueOf(res);
        }
View Full Code Here

Examples of xbird.xquery.DynamicError

            }
        }
    }

    private static XQRTException wrapSAXException(SAXException ex) throws DynamicError {
        throw new DynamicError("Writing SAX event failed", ex);
    }
View Full Code Here

Examples of xbird.xquery.DynamicError

        public XDouble eval(DynamicContext dynEnv, Item v1, Item v2) throws XQueryException {
            double d1 = asDouble(v1, dynEnv);
            double d2 = asDouble(v2, dynEnv);
            final double res = d1 + d2;
            if(res == Double.POSITIVE_INFINITY) {
                throw new DynamicError("err:FOAR0002", "result overflow");
            }
            if(res == Double.NEGATIVE_INFINITY) {
                throw new DynamicError("err:FOAR0002", "result underflow");
            }
            return XDouble.valueOf(res);
        }
View Full Code Here

Examples of xbird.xquery.DynamicError

            case TypeTable.NUMERIC_TID:
                v = this;
                break;
            case TypeTable.INTEGER_TID:
                if(Double.isNaN(value)) {
                    throw new DynamicError("err:FOCA0002", "Can't convert xs:double(" + toString()
                            + ") to xs:integer");
                }
                if(Double.isInfinite(value)) {
                    throw new DynamicError("err:FOCA0002", "Can't convert xs:double(" + toString()
                            + ") to xs:integer");
                }
                v = XInteger.valueOf(asLong());
                break;
            case TypeTable.FLOAT_TID:
                if(Double.isNaN(value)) {
                    v = XFloat.valueOf(Float.NaN);
                } else if(value == Double.POSITIVE_INFINITY) {
                    v = XFloat.valueOf(Float.POSITIVE_INFINITY);
                } else if(value == Double.NEGATIVE_INFINITY) {
                    v = XFloat.valueOf(Float.NEGATIVE_INFINITY);
                } else {
                    v = XFloat.valueOf((float) value);
                }
                break;
            case TypeTable.DECIMAL_TID:
                if(Double.isNaN(value)) {
                    throw new DynamicError("err:FORG0001", "Can't convert xs:double(" + toString()
                            + ") to xs:decimal");
                }
                if(Double.isInfinite(value)) {
                    throw new DynamicError("err:FOCA0002", "Can't convert xs:double(" + toString()
                            + ") to xs:decimal");
                }
                v = XDecimal.valueOf(asDecimal());
                break;
            default:
View Full Code Here

Examples of xbird.xquery.DynamicError

    public XDouble createInstance(String literal, AtomicType srcType, DynamicContext dynEnv)
            throws XQueryException {
        try {
            return new XDouble(literal);
        } catch (NumberFormatException e) {
            throw new DynamicError("err:FORG0001", e);
        }
    }
View Full Code Here

Examples of xbird.xquery.DynamicError

        final XQNode node;
        if (argv == null) {
            // If the argument is omitted, it defaults to the context node.
            Item contextItem = dynEnv.contextItem();
            if (contextItem == null) {
                throw new DynamicError("err:XPDY0002", "ContextItem is not set");
            }
            if (!(contextItem instanceof XQNode)) {
                throw new DynamicError("err:XPTY0004", "context item is expected to be a node, but was "
                        + contextItem.getType());
            }
            node = (XQNode) contextItem;
        } else {
            assert (argv.size() == 1);
View Full Code Here

Examples of xbird.xquery.DynamicError

    public AtomicValue createInstance(String literal, AtomicType srcType, DynamicContext dynEnv)
            throws XQueryException {
        try {
            return new XFloat(literal);
        } catch (NumberFormatException e) {
            throw new DynamicError("err:FORG0001", e);
        }
    }
View Full Code Here

Examples of xbird.xquery.DynamicError

        final XQNode node;
        if (argv == null) {
            // If the argument is omitted, it defaults to the context node.
            Item contextItem = dynEnv.contextItem();
            if (contextItem == null) {
                throw new DynamicError("err:XPDY0002", "ContextItem is not set");
            }
            if (!(contextItem instanceof XQNode)) {
                throw new DynamicError("err:XPTY0004", "context item is expected to be a node, but was "
                        + contextItem.getType());
            }
            node = (XQNode) contextItem;
        } else {
            assert (argv.size() == 1);
View Full Code Here

Examples of xbird.xquery.DynamicError

            XQNode element = (XQNode) secondItem;
            nsuri = NamespaceUriForPrefix.resolveNamespaceUri(element, prefix);
            if(nsuri == null) {
                // If the $qname has a prefix and if there is no namespace binding for $element
                // that matches this prefix, then an error is raised [err:FONS0004].
                throw new DynamicError("err:FONS0004", "Namespace for the prefix `" + qnameStr
                        + "` not found");
            }
        }
        final QualifiedName resolved;
        try {
            resolved = QNameUtil.parse(qnameStr, nsuri);
        } catch (IllegalArgumentException e) {
            // If $qname does not have the correct lexical form for xs:QName an error
            // is raised [err:FOCA0002].
            throw new DynamicError("err:FOCA0002", "Illegal qname form: " + qnameStr);
        }
        return new QNameValue(resolved);
    }
View Full Code Here

Examples of xbird.xquery.DynamicError

            throws XQueryException {
        final long lv;
        try {
            lv = Long.parseLong(literal);
        } catch (NumberFormatException pe) {
            throw new DynamicError("err:FORG0001", "failed to cast as '" + SYMBOL + "': " + literal);
        }
        if(lv < lowerBound() || lv > upperBound()) {
            throw new DynamicError("err:FORG0001", "Illegal value for '" + SYMBOL + "': " + literal);
        }
        return new XInteger(lv, this);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.