Examples of DurationValue


Examples of xbird.xquery.dm.value.xsi.DurationValue

            long l2 = d2.getValue().toGregorianCalendar().getTimeInMillis();
            Duration d = XsDatatypeFactory.createDuration(l1 - l2);
            DateTimeBaseType dt1 = d1.getDateTimeType();
            DateTimeBaseType dt2 = d2.getDateTimeType();
            if(dt1 == dt2 && (dt1.getTypeId() == TypeTable.YEAR_MONTH_DURATION_TID)) {
                return new DurationValue(d, YearMonthDurationType.YEARMONTH_DURATION);
            } else {
                return new DurationValue(d, DayTimeDurationType.DAYTIME_DURATION);
            }
        }
View Full Code Here

Examples of xbird.xquery.dm.value.xsi.DurationValue

    private static final class MulDuration extends Exec {
        static final MulDuration INSTANCE = new MulDuration();

        public DurationValue eval(DynamicContext dynEnv, Item v1, Item v2) throws XQueryException {
            final DurationValue dur1;
            final double d2;
            if(v1 instanceof DurationValue) {
                dur1 = (DurationValue) v1;
                d2 = asDouble(v2, dynEnv);
            } 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) {
                int months = dur1.totalMonths();
                long ym = Math.round(months * d2);
                res = XsDatatypeFactory.createYearMonthDuration(ym);
            } else {
                Duration dv1 = dur1.getValue();
                res = dv1.multiply(BigDecimal.valueOf(d2));
            }
            return new DurationValue(res, dt);
        }
View Full Code Here

Examples of xbird.xquery.dm.value.xsi.DurationValue

    public Sequence eval(Sequence<? extends Item> contextSeq, ValueSequence argv, DynamicContext dynEnv)
            throws XQueryException {
        TimeZone tz = dynEnv.implicitTimezone();
        int utcOffset = tz.getOffset(0);
        final Duration d = XsDatatypeFactory.createDuration(utcOffset);
        return new DurationValue(d, DayTimeDurationType.DAYTIME_DURATION);
    }
View Full Code Here

Examples of xbird.xquery.dm.value.xsi.DurationValue

            if(tzOffsetInMinutes == DatatypeConstants.FIELD_UNDEFINED) {
                return null;
            }
            long offsetInMillis = tzOffsetInMinutes * 60 * 1000;
            final Duration dur = XsDatatypeFactory.createDuration(offsetInMillis);
            return new DurationValue(dur, DayTimeDurationType.DAYTIME_DURATION);
        }
View Full Code Here

Examples of xbird.xquery.dm.value.xsi.DurationValue

                Type secType = sec.getType();
                if(!TypeUtil.subtypeOf(secType, DayTimeDurationType.DAYTIME_DURATION)) {
                    throw new IllegalStateException("second argument is expected to be xdt:dayTimeDuration, but was "
                            + secType);
                }
                DurationValue dv = (DurationValue) sec;
                utcOffsetInMillis = dv.getTimeInMillis();
            }
        } else {
            throw new IllegalStateException("Illegal argument length: " + arglen);
        }
        final int offsetInMinutes = (int) (utcOffsetInMillis / 60000);
View Full Code Here

Examples of xbird.xquery.dm.value.xsi.DurationValue

        Item first = argv.getItem(0);
        if(first.isEmpty()) {
            return ValueSequence.EMPTY_SEQUENCE;
        }
        assert (first instanceof DurationValue);
        DurationValue arg = (DurationValue) first;
        return extract(arg);
    }
View Full Code Here

Examples of xbird.xquery.dm.value.xsi.DurationValue

            op.staticAnalysis(dynEnv.getStaticContext(), sum, divby);
            return op.eval(dynEnv, sum, divby);
        } else if(firstItem instanceof DurationValue) {
            // Duration values must either all be xdt:yearMonthDuration values
            // or must all be xdt:dayTimeDuration values.
            DurationValue sum = (DurationValue) firstItem;
            Type firstType = firstItem.getType();
            assert (firstType != null);
            int size;
            for(size = 1; argItor.hasNext(); size++) {
                Item toadd = argItor.next();
View Full Code Here

Examples of xbird.xquery.dm.value.xsi.DurationValue

            }
            return sum;
        } else if(firstItem instanceof DurationValue) {
            // Duration values must either all be xdt:yearMonthDuration values
            // or must all be xdt:dayTimeDuration values.
            DurationValue sum = (DurationValue) firstItem;
            Type firstType = firstItem.getType();
            assert (firstType != null);
            while(argItor.hasNext()) {
                Item toadd = argItor.next();
                if(toadd instanceof DurationValue) {
View Full Code Here

Examples of xbird.xquery.dm.value.xsi.DurationValue

            }
            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)) {
View Full Code Here

Examples of xbird.xquery.dm.value.xsi.DurationValue

            }
            return max;
        } else if(firstItem instanceof DurationValue) {
            // Duration values must either all be xdt:yearMonthDuration values
            // or must all be xdt:dayTimeDuration values.
            DurationValue max = (DurationValue) firstItem;
            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(max) > 0) {
                    max = cmp;
                }
            }
            return max;
        } else if(TypeUtil.subtypeOf(firstType, StringType.STRING)) {
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.