Package org.exist.xquery.value

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


        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

TOP

Related Classes of org.exist.xquery.value.DurationValue

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.