Package javax.xml.datatype

Examples of javax.xml.datatype.Duration


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


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

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

            }
            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

    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

       
        readerControl.replay();
       
        DurationType dType = (DurationType) tm.getType(Duration.class);
        assertNotNull(dType);
        Duration d = (Duration) dType.readObject(reader, new MessageContext());
        assertEquals(120, d.getDays());
       
        readerControl.verify();
       
        // test writing
        MockControl writerControl = MockControl.createControl(MessageWriter.class);
        MessageWriter writer = (MessageWriter) writerControl.getMock();
       
        writer.writeValue("-P120D");
        writerControl.setVoidCallable();
       
        writerControl.replay();
       
        dType.writeObject(d, writer, new MessageContext());
        assertEquals(120, d.getDays());
       
        writerControl.verify();
    }
View Full Code Here

    }

    public void testDuration() throws Exception {
        javax.xml.datatype.DatatypeFactory datatypeFactory = javax.xml.datatype.DatatypeFactory.newInstance();

        Duration x = datatypeFactory.newDuration("P1Y35DT60M60.500S");
        Duration yOrig = datatypeFactory.newDuration("-P2MT24H60S");

        Holder<Duration> y = new Holder<Duration>(yOrig);
        Holder<Duration> z = new Holder<Duration>();

        Duration ret;
        if (testDocLiteral) {
            ret = docClient.testDuration(x, y, z);
        } else {
            // XXX - TODO getting a MarshalException with rpc-lit for the
            // xsd:duration test [DurationImpl is not known to this context].
View Full Code Here

        SourceSequence seq = new SourceSequence(id);
       
        Expires expires = factory.createExpires();
       
        DatatypeFactory dbf = DatatypeFactory.newInstance();
        Duration d = dbf.newDuration(0);       
        expires.setValue(d);
        seq.setExpires(expires);
        assertTrue(!seq.isExpired());
       
        d = dbf.newDuration("PT0S");       
View Full Code Here

        RMSource source = control.createMock(RMSource.class);
        SourcePolicyType sp = control.createMock(SourcePolicyType.class);
       
        Identifier sid = RMUtils.getWSRMFactory().createIdentifier();
        sid.setValue("s1");
        Duration osd = DatatypeFactory.newInstance().newDuration("PT24H");
        assertNotNull(osd);
        Identifier offeredSid = RMUtils.getWSRMFactory().createIdentifier();
        offeredSid.setValue("s1Offer");
     
        expect(handler.getBinding()).andReturn(binding);
View Full Code Here

        SourcePolicyType sp = control.createMock(SourcePolicyType.class);
        //RMDestination dest = control.createMock(RMDestination.class);
       
        Identifier sid = RMUtils.getWSRMFactory().createIdentifier();
        sid.setValue("s1");
        Duration osd = DatatypeFactory.newInstance().newDuration("PT24H");
        Identifier offeredSid = RMUtils.getWSRMFactory().createIdentifier();
        offeredSid.setValue("s1Offer");

        expect(handler.getBinding()).andReturn(binding)
        expect(source.getSourcePolicies()).andReturn(sp);
View Full Code Here

TOP

Related Classes of javax.xml.datatype.Duration

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.