Package xbird.xquery

Examples of xbird.xquery.DynamicError


        static final NegDouble INSTANCE = new NegDouble();

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


    private static XInteger divideByFloatFloat(final Item v1, final Item v2, final DynamicContext dynEnv)
            throws XQueryException {
        final float res = DivFloat.compute(v1, v2, dynEnv);
        if(res == Float.POSITIVE_INFINITY) {
            throw new DynamicError("err:FOAR0002", "result overflow");
        }
        if(res == Float.NEGATIVE_INFINITY) {
            throw new DynamicError("err:FOAR0002", "result underflow");
        }
        long casted = (long) res;
        return new XInteger(casted);
    }
View Full Code Here

    private static XInteger divideByDoubleDouble(final Item v1, final Item v2, final DynamicContext dynEnv)
            throws XQueryException {
        final double res = DivDouble.compute(v1, v2, dynEnv);
        if(res == Double.POSITIVE_INFINITY) {
            throw new DynamicError("err:FOAR0002", "result overflow");
        }
        if(res == Double.NEGATIVE_INFINITY) {
            throw new DynamicError("err:FOAR0002", "result underflow");
        }
        long casted = (long) res;
        return new XInteger(casted);
    }
View Full Code Here

        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

            } else {
                dur1 = (DurationValue) v2;
                d2 = asDouble(v1, dynEnv);
            }
            if(Double.isNaN(d2)) {
                throw new DynamicError("err:FOCA0005", "Illegally multiplying with NaN.");
            }
            if(Double.isInfinite(d2)) {
                throw new DynamicError("err:FODT0002", "Duration value is too large or too small to be represented.");
            }
            DurationType dt = dur1.getDurationType();
            final Duration res;
            final int dt1 = dt.getTypeId();
            if(dt1 == TypeTable.YEAR_MONTH_DURATION_TID) {
View Full Code Here

         */
        public static long compute(final Item v1, final Item v2, final DynamicContext dynEnv)
                throws XQueryException {
            final long divisor = asLong(v2, dynEnv);
            if(divisor == 0) {
                throw new DynamicError("err:FOAR0001", "divide by zero");
            }
            long src = asLong(v1, dynEnv);
            long res = src / divisor;
            return res;
        }
View Full Code Here

            }
            final float f1 = asFloat(v1, dynEnv);
            // If either operand is NaN or if $arg1 is INF or -INF then an error is raised
            // [err:FOAR0002].
            if(f1 != f1 || Float.isInfinite(f1)) {
                throw new DynamicError("err:FOAR0002", "Invalid $arg1 operand: "
                        + Double.toString(f1));
            }
            if(divisor != divisor) {
                throw new DynamicError("err:FOAR0002", "Invalid $arg2 operand: "
                        + Double.toString(divisor));
            }
            float res = f1 / divisor;
            return res;
        }
View Full Code Here

            }
            double d1 = asDouble(v1, dynEnv);
            // If either operand is NaN or if $arg1 is INF or -INF then an error is raised
            // [err:FOAR0002].
            if(d1 != d1 || Double.isInfinite(d1)) {
                throw new DynamicError("err:FOAR0002", "Invalid $arg1 operand: "
                        + Double.toString(d1));
            }
            if(divisor != divisor) {
                throw new DynamicError("err:FOAR0002", "Invalid $arg2 operand: "
                        + Double.toString(divisor));
            }
            final double res = d1 / divisor;
            return res;
        }
View Full Code Here

        _handler.init();
        final StopWatch sw = new StopWatch();
        try {
            _reader.parse(new InputSource(is));
        } catch (IOException ie) {
            throw new DynamicError("Invalid source", ie);
        } catch (SAXException se) {
            throw new DynamicError("Parse failed", se);
        }
        if(LOG.isDebugEnabled()) {
            LOG.debug("Elasped time of building a DTM: " + sw.elapsed() + " msec");
        }
        this._docid = nextDocumentId();
View Full Code Here

        Item arg = argv.getItem(0);
        final Type.Occurrence quantifier = arg.getType().quantifier();
        if(!Type.Occurrence.OCC_ONE_OR_MORE.accepts(quantifier.getAlignment())) {
            if(arg.isEmpty()) {
                // Returns $arg if it contains one or more items. Otherwise, raises an error [err:FORG0004].
                throw new DynamicError("err:FORG0004", "Invalid result sequence type was detected: "
                        + arg.getType());
            }
        }
        return arg;
    }
View Full Code Here

TOP

Related Classes of xbird.xquery.DynamicError

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.