Examples of DurationValue


Examples of com.volantis.xml.expression.atomic.temporal.DurationValue

        if (arguments.length == 0) {
            result = Sequence.EMPTY;
        } else {
            ExpressionFactory factory = context.getFactory();

            DurationValue duration = factory.createDurationValue(
                    arguments[0].stringValue().asJavaString());
            result = getValue(factory, duration);
        }
        return result;
    }
View Full Code Here

Examples of com.volantis.xml.expression.atomic.temporal.DurationValue

                                    new Integer(arguments.length)}));
        }
       
        Value result = Sequence.EMPTY;
        if (arguments[0].getSequence() != Sequence.EMPTY) {
            DurationValue duration = context.getFactory().createDurationValue(
                    arguments[0].stringValue().asJavaString());
            DateTimeValue dateTime = CurrentDateTimeHelper
                    .getCurrentDateTimeValue(context);
            DateTimeValue newDateTime = ((SimpleDateTimeValue) dateTime)
                    .add(duration);
View Full Code Here

Examples of org.exist.xquery.value.DurationValue

    Sequence result;
    if (args.length == 0 || args[0].isEmpty()) {
      result = Sequence.EMPTY_SEQUENCE;
    } else {
      final Sequence arg = args[0];
      final DurationValue duration = new DurationValue(((DurationValue) arg.itemAt(0)).getCanonicalDuration());
      if (isCalledAs("days-from-duration")) {
            result = new IntegerValue(duration.getPart(DurationValue.DAY));
      } else if (isCalledAs("hours-from-duration")) {
            result = new IntegerValue(duration.getPart(DurationValue.HOUR));
      } else if (isCalledAs("minutes-from-duration")) {
            result = new IntegerValue(duration.getPart(DurationValue.MINUTE));
      } else if (isCalledAs("seconds-from-duration")) {
        if (duration.getCanonicalDuration().getField(DatatypeConstants.SECONDS) == null)
          {result = new DecimalValue(0);}
        else
          {result = new DecimalValue((BigDecimal)duration.getCanonicalDuration().getField(DatatypeConstants.SECONDS));}
        if (duration.getCanonicalDuration().getSign() < 0)
          {result = ((DecimalValue)result).negate();}
      } else if (isCalledAs("months-from-duration")) {
            result = new IntegerValue(duration.getPart(DurationValue.MONTH));
      } else if (isCalledAs("years-from-duration")) {
            result = new IntegerValue(duration.getPart(DurationValue.YEAR));
      } else {
                logger.error("can't handle function " + mySignature.getName().getLocalName());
        throw new Error("can't handle function " + mySignature.getName().getLocalName());
      }
    }
View Full Code Here

Examples of org.exist.xquery.value.DurationValue

        if(!(item instanceof AbstractDateTimeValue))
          throw new XPathException("Function requires one of xs:dateTime, xs:date, or xs:time as first parameter.");

        ValueSequence result = new ValueSequence();
        AbstractDateTimeValue d1 = (AbstractDateTimeValue)item;
        DurationValue diff = (DurationValue)args[1].itemAt(0);
        Sequence seq = args[2].convertTo(Type.INTEGER);
        int count = ((NumericValue)seq.itemAt(0).convertTo(Type.INTEGER)).getInt();
        if (count < 0)
            count = 0;
View Full Code Here

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

     */
    private static final class AddDurationToDateTime extends Exec {
        static final AddDurationToDateTime INSTANCE = new AddDurationToDateTime();

        public DateTimeValue eval(DynamicContext dynEnv, Item v1, Item v2) throws XQueryException {
            final DurationValue d1;
            final DateTimeValue dt2;
            if(v1 instanceof DurationValue) {
                d1 = (DurationValue) v1;
                dt2 = (DateTimeValue) v2;
            } else {
                d1 = (DurationValue) v2;
                dt2 = (DateTimeValue) v1;
            }
            XMLGregorianCalendar cal2 = dt2.getValue();
            cal2.add(d1.getValue());
            return new DateTimeValue(cal2, dt2.getDateTimeType());
        }
View Full Code Here

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

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

        public DurationValue eval(DynamicContext dynEnv, Item v1, Item v2) throws XQueryException {
            DurationValue d1 = (DurationValue) v1;
            DurationValue d2 = (DurationValue) v2;
            Duration dv1 = d1.getValue();
            Duration res = dv1.add(d2.getValue());
            DurationType dt1 = d1.getDurationType();
            DurationType dt2 = d2.getDurationType();
            if(dt1 == dt2) {
                return new DurationValue(res, dt1);
            } else {
                return new DurationValue(res);
            }
        }
View Full Code Here

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

    public static final class DivDuration extends Exec {
        static final DivDuration INSTANCE = new DivDuration();

        public DurationValue eval(DynamicContext dynEnv, Item v1, Item v2) throws XQueryException {
            final DurationValue dur1;
            final double divisor;
            if(v1 instanceof DurationValue) {
                dur1 = (DurationValue) v1;
                divisor = NumericOp.asDouble(v2, dynEnv);
            } 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

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

    public static final class DivDurationByDuration extends Exec {
        static final DivDurationByDuration INSTANCE = new DivDurationByDuration();

        public XDecimal eval(DynamicContext dynEnv, Item v1, Item v2) throws XQueryException {
            DurationValue d1 = (DurationValue) v1;
            DurationValue d2 = (DurationValue) v2;

            final int dt1 = d1.getDurationType().getTypeId();
            final int dt2 = d2.getDurationType().getTypeId();
            if(dt1 == dt2) {
                if(dt1 == TypeTable.YEAR_MONTH_DURATION_TID) {
                    return evalYearMonthDuration(d1, d2);
                }
                //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");
View Full Code Here

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

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

        public DateTimeValue eval(DynamicContext dynEnv, Item v1, Item v2) throws XQueryException {
            final DurationValue d1;
            final DateTimeValue dt2;
            if(v1 instanceof DurationValue) {
                d1 = (DurationValue) v1;
                dt2 = (DateTimeValue) v2;
            } else {
                d1 = (DurationValue) v2;
                dt2 = (DateTimeValue) v1;
            }
            XMLGregorianCalendar cal2 = dt2.getValue();
            cal2.add(d1.getValue().negate());
            return new DateTimeValue(cal2, dt2.getDateTimeType());
        }
View Full Code Here

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

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

        public DurationValue eval(DynamicContext dynEnv, Item v1, Item v2) throws XQueryException {
            DurationValue d1 = (DurationValue) v1;
            DurationValue d2 = (DurationValue) v2;
            Duration dv1 = d1.getValue();
            Duration res = dv1.subtract(d2.getValue());
            DurationType dt1 = d1.getDurationType();
            DurationType dt2 = d2.getDurationType();
            if(dt1 == dt2) {
                return new DurationValue(res, dt1);
            } else {
                return new DurationValue(res);
            }
        }
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.