Package xbird.xquery.dm.value.xsi

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


        return Date.class;
    }

    public AtomicValue createInstance(String literal, AtomicType srcType, DynamicContext dynEnv)
            throws XQueryException {
        return new DateTimeValue(literal, this);
    }
View Full Code Here


            throws XQueryException {
        return new DateTimeValue(literal, this);
    }

    public DateTimeValue createInstance(XMLGregorianCalendar value) {
        return new DateTimeValue(value, DATETIME);
    }
View Full Code Here

    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

        return Date.class;
    }

    public AtomicValue createInstance(String literal, AtomicType srcType, DynamicContext dynEnv)
            throws XQueryException {
        return new DateTimeValue(literal, this);
    }
View Full Code Here

        assert (arglen == 1) : arglen;
        Item first = argv.getItem(0);
        if(first.isEmpty()) {
            return ValueSequence.EMPTY_SEQUENCE;
        }
        DateTimeValue arg = (DateTimeValue) first;
        AtomicValue extracted = extract(arg);
        if(extracted == null) {
            return ValueSequence.EMPTY_SEQUENCE;
        }
        return extracted;
View Full Code Here

        return Date.class;
    }

    public DateTimeValue createInstance(String literal, AtomicType srcType, DynamicContext dynEnv)
            throws XQueryException {
        return new DateTimeValue(literal, this);
    }
View Full Code Here

        if(previous.first == dynEnv) {
            return previous.second;
        } else {
            final XMLGregorianCalendar cal = XsDatatypeFactory.createXMLGregorianCalendar(dynEnv.currentDateTime());
            DateTimeBaseType casttoType = getReturnType();
            final DateTimeValue date = new DateTimeValue(cal, casttoType);
            previous.first = dynEnv;
            previous.second = date;
            return date;
        }
    }
View Full Code Here

    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

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

        public DurationValue eval(DynamicContext dynEnv, Item v1, Item v2) throws XQueryException {
            DateTimeValue d1 = (DateTimeValue) v1;
            DateTimeValue d2 = (DateTimeValue) v2;
            long l1 = d1.getValue().toGregorianCalendar().getTimeInMillis();
            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

    public Sequence eval(Sequence<? extends Item> contextSeq, ValueSequence argv, DynamicContext dynEnv)
            throws XQueryException {
        Item arg1 = argv.getItem(0);
        Item arg2 = argv.getItem(1);
        DateTimeValue date = (DateTimeValue) arg1;
        DateTimeValue time = (DateTimeValue) arg2;
        XMLGregorianCalendar dateValue = date.getValue();
        XMLGregorianCalendar newValue = (XMLGregorianCalendar) dateValue.clone();
        XMLGregorianCalendar timeValue = time.getValue();
        final int timeTz = timeValue.getTimezone();
        if(timeTz != DatatypeConstants.FIELD_UNDEFINED) {
            final int dateTz = newValue.getTimezone();
            if(dateTz != DatatypeConstants.FIELD_UNDEFINED && dateTz != timeTz) {
                throw new DynamicError("err:FORG0008", "fn:dateTime(" + date + ", " + time
                        + ") for `" + dateValue.getTimeZone(dateTz).getID() + " and `"
                        + timeValue.getTimeZone(timeTz).getID() + "` is not allowed.");
            }
            newValue.setTimezone(timeTz);
        }
        newValue.setTime(timeValue.getHour(), timeValue.getMinute(), timeValue.getSecond(), timeValue.getMillisecond());
        DateTimeValue dt = new DateTimeValue(newValue, DateTimeType.DATETIME);
        return dt;
    }
View Full Code Here

TOP

Related Classes of xbird.xquery.dm.value.xsi.DateTimeValue

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.