Package xbird.xquery

Examples of xbird.xquery.DynamicError


        return focus.getContextItem();
    }

    public int contextPosition() throws DynamicError {
        if(focus == null) {
            throw new DynamicError("err:XPDY0002", "ContentPosition is not set");
        }
        return focus.getContextPosition();
    }
View Full Code Here


        public static BigDecimal compute(final Item v1, final Item v2, final DynamicContext dynEnv)
                throws XQueryException {
            final BigDecimal divisor = asDecimal(v2, dynEnv);
            if(divisor.equals(BigDecimal.ZERO)) {
                throw new DynamicError("err:FOAR0001", "divide by zero");
            }
            BigDecimal dv1 = asDecimal(v1, dynEnv);
            BigDecimal res = XDecimal.divide(dv1, divisor);
            return res;
        }
View Full Code Here

            } else {
                dur1 = (DurationValue) v2;
                divisor = NumericOp.asDouble(v1, dynEnv);
            }
            if(divisor == 0) {
                throw new DynamicError("err:FODT0002", "Overflow in duration arithmetic, divided by zero");
            }
            if(Double.isNaN(divisor)) {
                throw new DynamicError("err:FOCA0005", "$arg2 is NaN");
            }
            double res = 1.0 / divisor;
            DurationValue resDur = dur1.multiply(res);
            return resDur;
        }
View Full Code Here

                //TODO else if(dt1 == TypeTable.DAYTIME_DURATION_TID) {}
            }

            final double divisor = d2.getTimeInMillis();
            if(divisor == 0) {
                throw new DynamicError("err:FODT0002", "Overflow in duration arithmetic, divided by zero");
            }
            if(Double.isNaN(divisor)) {
                throw new DynamicError("err:FOCA0005", "$arg2 is NaN");
            }
            double l1 = d1.getTimeInMillis();
            double res = l1 / divisor;
            BigDecimal bdv = BigDecimal.valueOf(res);
            return XDecimal.valueOf(bdv);
View Full Code Here

        private static XDecimal evalYearMonthDuration(final DurationValue d1, final DurationValue d2)
                throws DynamicError {
            final int divisor = d2.totalMonths();
            if(divisor == 0) {
                throw new DynamicError("err:FODT0002", "Overflow in duration arithmetic, divided by zero");
            }
            double m1 = d1.totalMonths();
            double res = m1 / divisor;
            BigDecimal bdv = BigDecimal.valueOf(res);
            return XDecimal.valueOf(bdv);
View Full Code Here

            case TypeTable.NUMERIC_TID:
                v = this;
                break;
            case TypeTable.INTEGER_TID:
                if(Float.isNaN(value)) {
                    throw new DynamicError("err:FOCA0002", "Can't convert xs:double(" + toString()
                            + ") to xs:integer");
                }
                if(Float.isInfinite(value)) {
                    throw new DynamicError("err:FOCA0002", "Can't convert xs:double(" + toString()
                            + ") to xs:integer");
                }
                v = XInteger.valueOf(asLong());
                break;
            case TypeTable.DOUBLE_TID:
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

        if(literal == null) {
            throw new IllegalArgumentException();
        }
        final int strlen = literal.length();
        if(strlen < 4 || !literal.startsWith("--")) {
            throw new DynamicError("err:FORG0001", "Illegal value for xs:gMonth: " + literal);
        }
        StringBuilder buf = new StringBuilder(strlen + 2);
        buf.append(literal.substring(0, 4));
        // [workaround] gMonth, --MM(z?), but per XML Schema Errata, used to be --MM--(z?)
        buf.append("--");
View Full Code Here

    }

    public AtomicValue createInstance(String literal, AtomicType srcType, DynamicContext dynEnv)
            throws XQueryException {
        if(literal.indexOf('E') != -1 || literal.indexOf('e') != -1) {
            throw new DynamicError("err:FORG0001", "Illegal representation as xs:decimal: "
                    + literal);
        }
        try {
            return new XDecimal(literal, this);
        } catch (NumberFormatException nfe) {
            throw new DynamicError("err:FORG0001", "failed to cast as '" + SYMBOL + "': " + literal);
        }
    }
View Full Code Here

    public void evStartDocument() throws XQueryException {
        try {
            output.writeByte(EV_START_DOC);
        } catch (IOException e) {
            throw new DynamicError("failed on evStartDocument", e);
        }
    }
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.