Package org.exist.xquery.value

Examples of org.exist.xquery.value.AbstractDateTimeValue


        }
        Sequence result;
        if (args[0].isEmpty())
            {result =Sequence.EMPTY_SEQUENCE;}
        else {
            final AbstractDateTimeValue time = (AbstractDateTimeValue) args[0].itemAt(0);
            if (getSignature().getArgumentCount() == 2) {
                if (args[1].isEmpty()) {
                    result = time.withoutTimezone();
                } else {
                    final DayTimeDurationValue offset = (DayTimeDurationValue) args[1].itemAt(0);
                    result = time.adjustedToTimezone(offset);
                }
            } else {
                result = time.adjustedToTimezone(null);
            }
        }
        if (context.getProfiler().isEnabled())
            {context.getProfiler().end(this, "", result);}
        return result;
View Full Code Here


  }

  public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathException {
    long ms;
    if (args.length == 1) {
          AbstractDateTimeValue value = (AbstractDateTimeValue) args[0].itemAt(0);
          ms = value.getTimeInMillis();
    } else {
          ms = System.currentTimeMillis();
    }
   
    return new IntegerValue( ms );
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;

        // loop through dates/times
        while(count-- > 0)
        {
          result.add(d1);
          d1 = (AbstractDateTimeValue)d1.plus(diff);
        }

        return result;
    }
View Full Code Here

    Sequence result;
    if (args.length == 0 || args[0].isEmpty()) {
      result = Sequence.EMPTY_SEQUENCE;
    } else {
      final Sequence arg = args[0];
      final AbstractDateTimeValue date = (AbstractDateTimeValue) arg.itemAt(0);
      if (isCalledAs("day-from-dateTime") || isCalledAs("day-from-date")) {
        result = new IntegerValue(date.getPart(DateValue.DAY), Type.INTEGER);
      } else if (isCalledAs("month-from-dateTime") || isCalledAs("month-from-date")) {
        result = new IntegerValue(date.getPart(DateValue.MONTH),
            Type.INTEGER);
      } else if (isCalledAs("year-from-dateTime") || isCalledAs("year-from-date")) {
        result = new IntegerValue(date.getPart(DateValue.YEAR),
            Type.INTEGER);
      } else if (isCalledAs("hours-from-dateTime") || isCalledAs("hours-from-time")) {
        result = new IntegerValue(date.getPart(DateValue.HOUR),
            Type.INTEGER);
      } else if (isCalledAs("minutes-from-dateTime") || isCalledAs("minutes-from-time")) {
        result = new IntegerValue(date.getPart(DateValue.MINUTE),
            Type.INTEGER);
      } else if (isCalledAs("seconds-from-dateTime") || isCalledAs("seconds-from-time")) {
        result = new IntegerValue(date.calendar.getSecond()).convertTo(Type.DECIMAL);
        if (date.calendar.getFractionalSecond() != null)           
          {result = ((DecimalValue)result).plus(new DecimalValue(date.calendar.getFractionalSecond()));}     
      } else if (isCalledAs("timezone-from-dateTime") || isCalledAs("timezone-from-date") || isCalledAs("timezone-from-time")) {
        result = date.getTimezone();
      } else {
                logger.error("can't handle function " + mySignature.getName().getLocalName());
        throw new Error("can't handle function " + mySignature.getName().getLocalName());
      }
    }
View Full Code Here

TOP

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

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.