Package javax.xml.datatype

Examples of javax.xml.datatype.Duration


         Lifetime lifetime = new Lifetime();

         XMLGregorianCalendar currentTime = toXMLGregorianCalendar(exportContext.getCurrentTime());
         XMLGregorianCalendar terminationTime = toXMLGregorianCalendar(exportContext.getTermintationTime());

         Duration duration = toDuration(exportContext.getRefreshDuration());

         lifetime.setCurrentTime(currentTime);
         lifetime.setTerminationTime(terminationTime);
         lifetime.setRefreshDuration(duration);
View Full Code Here


        return tt;
    }

    protected XMLGregorianCalendar parseTerminationTime(String value) {
        try {
            Duration d = datatypeFactory.newDuration(value);
            XMLGregorianCalendar c = getCurrentTime();
            c.add(d);
            return c;
        } catch (Exception e) {
            // Ignore
        }
        try {
            Duration d = datatypeFactory.newDurationDayTime(value);
            XMLGregorianCalendar c = getCurrentTime();
            c.add(d);
            return c;
        } catch (Exception e) {
            // Ignore
        }
        try {
            Duration d = datatypeFactory.newDurationYearMonth(value);
            XMLGregorianCalendar c = getCurrentTime();
            c.add(d);
            return c;
        } catch (Exception e) {
            // Ignore
View Full Code Here

   
    GetSubscriptionResults getSubscriptionResults = null;
    Date startPoint = subscription.getLastNotified();
    if (startPoint==null) startPoint = new Date(0);

    Duration duration = TypeConvertor.convertStringToDuration(subscription.getNotificationInterval());
    Date nextDesiredNotificationDate = new Date(startPoint.getTime());
    duration.addTo(nextDesiredNotificationDate);

    if (subscription.getLastNotified()==null || nextDesiredNotificationDate.after(startPoint) && nextDesiredNotificationDate.before(endPoint)) {
      getSubscriptionResults = new GetSubscriptionResults();
     
      CoveragePeriod period = new CoveragePeriod();
View Full Code Here

     * @param duration lexical duration representation
     *
     * @return duration in milliseconds
     */
    public static long durationToLong(String duration) {
        Duration xmlDuration = getDataTypeFactory().newDuration(duration);
        return xmlDuration.getTimeInMillis(new GregorianCalendar());
    }
View Full Code Here

     * @param duration the duration
     *
     * @return the lexical representation
     */
    public static String longToDuration(long duration) {
        Duration xmlDuration = getDataTypeFactory().newDuration(duration);
        return xmlDuration.toString();
    }
View Full Code Here

               // todo: deal with expiration time
               Lifetime lifetime = lifetimeHolder.value;
               if (lifetime != null)
               {
                  XMLGregorianCalendar currentTime = lifetime.getCurrentTime();
                  Duration refreshDuration = lifetime.getRefreshDuration();
                  XMLGregorianCalendar terminationTime = lifetime.getTerminationTime();
               }

               ExportInfo exportInfo = new ExportInfo(System.currentTimeMillis(), errorCodeToHandle, handleToState, exportContextHolder.value);
               getConsumerRegistry().getMigrationService().add(exportInfo);
View Full Code Here

        } else {
            acksTo = defaultAcksTo;
        }
        create.setAcksTo(acksTo);

        Duration d = sp.getSequenceExpiration();
        if (null != d) {
            Expires expires = new Expires();
            expires.setValue(d)
            create.setExpires(expires);
        }
View Full Code Here

        DestinationPolicyType dp = reliableEndpoint.getManager().getDestinationPolicy();
        if (dp.getMaxSequences() > 0
            && destination.getProcessingSequenceCount() >= dp.getMaxSequences()) {
            throw new RuntimeException("Sequence creation refused");
        }
        Duration supportedDuration = dp.getSequenceExpiration();
        if (null == supportedDuration) {
            supportedDuration = DatatypeFactory.PT0S;
        }
        Expires ex = create.getExpires();
       
        if (null != ex) {
            Duration effectiveDuration = ex.getValue();
            // PT0S represents 0 second and the shortest duration but in ws-rm, considered the longest
            if (DatatypeFactory.PT0S.equals(effectiveDuration)
                || (!DatatypeFactory.PT0S.equals(supportedDuration)
                    &&  supportedDuration.isShorterThan(effectiveDuration)))  {
                effectiveDuration = supportedDuration;
View Full Code Here

        return expires == null ? false : new Date().after(expires);

    }

    public void setExpires(Expires ex) {
        Duration d = null;
        expires = null;
        if (null != ex) {
            d = ex.getValue();
        }

        if (null != d && !d.equals(DatatypeFactory.PT0S)) {
            Date now = new Date();
            expires = new Date(now.getTime() + ex.getValue().getTimeInMillis(now));
        }
    }
View Full Code Here

        RMManager manager = control.createMock(RMManager.class);
        EasyMock.expect(rme.getManager()).andReturn(manager).anyTimes();
        SourcePolicyType sp = control.createMock(SourcePolicyType.class);
        EasyMock.expect(manager.getSourcePolicy()).andReturn(sp).anyTimes();
        EasyMock.expect(sp.getAcksTo()).andReturn(null).anyTimes();
        Duration d = DatatypeFactory.createDuration("PT12H");
        EasyMock.expect(sp.getSequenceExpiration()).andReturn(d).anyTimes();
        EasyMock.expect(sp.isIncludeOffer()).andReturn(Boolean.TRUE).anyTimes();
        Duration dOffered = DatatypeFactory.createDuration("PT24H");
        EasyMock.expect(sp.getOfferedSequenceExpiration()).andReturn(dOffered).anyTimes();
        Source source = control.createMock(Source.class);
        EasyMock.expect(rme.getSource()).andReturn(source).anyTimes();
        Identifier offeredId = control.createMock(Identifier.class);
        EasyMock.expect(source.generateSequenceIdentifier()).andReturn(offeredId).anyTimes();
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.