Package javax.xml.datatype

Examples of javax.xml.datatype.Duration


        XMLGregorianCalendar min = schema.getCalendar(this.value);
        XMLGregorianCalendar val = schema.getCalendar(value);     
        return min.compare(val)==DatatypeConstants.LESSER;
      }
      else if (type.equals(schema.XSD_URI+"#duration")) {
        Duration min = schema.getDuration(this.value);
        Duration val = schema.getDuration(value);
        return min.isShorterThan(val);
      }
      else if (type.equals(schema.XSD_URI+"#decimal")) {
        return new BigDecimal(this.value).compareTo(new BigDecimal(value))<0;
      }
View Full Code Here


    catch (Exception e) {
      // see if its a xsd:duration
      try {
        DatatypeFactory factory = DatatypeFactory.newInstance();
        Duration d = factory.newDuration(text);
        long secs = d.getTimeInMillis(new Date()) / 1000;
        timeUnit = new TimeUnit(secs + " secs");
      } catch (Exception e1) {
        throw new java.text.ParseException(e.getMessage(), 0);
      }
View Full Code Here

    text = (text == null) ? "" : text.trim();
    td.text = text;

    try {
      DatatypeFactory factory = DatatypeFactory.newInstance();
      Duration d = factory.newDuration(text);
      long secs = d.getTimeInMillis(new Date()) / 1000;
      td.timeUnit = new TimeUnit(secs + " secs");
    } catch (Exception e) {
      throw new java.text.ParseException(e.getMessage(), 0);
    }
    return td;
View Full Code Here

        XMLGregorianCalendar val = schema.getCalendar(value);     
        return min.compare(val)==DatatypeConstants.LESSER ||
          min.compare(val)==DatatypeConstants.EQUAL;
      }
      else if (type.equals(schema.XSD_URI+"#duration")) {
        Duration min = schema.getDuration(this.value);
        Duration val = schema.getDuration(value);
        return min.isShorterThan(val) || min.equals(val);
      }
      else if (type.equals(schema.XSD_URI+"#integer")
          || type.equals(schema.XSD_URI+"#negativeInteger")
          || type.equals(schema.XSD_URI+"#positiveInteger")
View Full Code Here

        XMLGregorianCalendar calendar = DatatypeFactory.newInstance().newXMLGregorianCalendar(modelSubscription.getExpiresAfter());
        subscription.setExpiresAfter(calendar);
      }
      subscription.setMaxEntities(modelSubscription.getMaxEntities());
      if (!"".equals(modelSubscription.getNotificationInterval())) {
        Duration duration = DatatypeFactory.newInstance().newDuration(modelSubscription.getNotificationInterval());
        subscription.setNotificationInterval(duration);
      }
      if (!"".equals(modelSubscription.getSubscriptionFilter())) {
        SubscriptionFilter subscriptionFilter = (SubscriptionFilter)JAXBMarshaller.unmarshallFromString(modelSubscription.getSubscriptionFilter(), JAXBMarshaller.PACKAGE_SUBSCRIPTION);
        subscription.setSubscriptionFilter(subscriptionFilter);
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 = client.testDuration(x, y, z);           
        if (!perfTestOnly) {
            assertTrue("testDuration(): Incorrect value for inout param", x.equals(y.value));
            assertTrue("testDuration(): Incorrect value for out param", yOrig.equals(z.value));
            assertTrue("testDuration(): Incorrect return value", x.equals(ret));
        }
View Full Code Here

            // A lot of testing to keep it as derived types.
            boolean isDTDur = dtXSDdayTimeDuration.equals(nv1.getDatatypeURI()) &&
                              dtXSDdayTimeDuration.equals(nv2.getDatatypeURI()) ;
            boolean isYMDur = dtXSDyearMonthDuration.equals(nv1.getDatatypeURI()) &&
                              dtXSDyearMonthDuration.equals(nv2.getDatatypeURI()) ;
            Duration d3 = nv1.getDuration().add(nv2.getDuration()) ;
            String lex = d3.toString() ;
            Node n ;
            if ( isDTDur )
                n = NodeFactory.createLiteralNode(lex, null, dtXSDdayTimeDuration) ;
            else if ( isYMDur )
                n = NodeFactory.createLiteralNode(lex, null, dtXSDyearMonthDuration) ;
View Full Code Here

         // A lot of testing to keep it as derived types.
            boolean isDTDur = dtXSDdayTimeDuration.equals(nv1.getDatatypeURI()) &&
                              dtXSDdayTimeDuration.equals(nv2.getDatatypeURI()) ;
            boolean isYMDur = dtXSDyearMonthDuration.equals(nv1.getDatatypeURI()) &&
                              dtXSDyearMonthDuration.equals(nv2.getDatatypeURI()) ;
            Duration d3 = nv1.getDuration().subtract(nv2.getDuration()) ;
            String lex = d3.toString() ;
            Node n ;
            if ( isDTDur )
                n = NodeFactory.createLiteralNode(lex, null, dtXSDdayTimeDuration) ;
            else if ( isYMDur )
                n = NodeFactory.createLiteralNode(lex, null, dtXSDyearMonthDuration) ;
View Full Code Here

            return XSDFuncOp.numMultiply(nv1, nv2) ;

        if ( vs1.equals(VSPACE_DURATION) && vs2.equals(VSPACE_NUM) )
        {
            // ONLY defined for dayTime.
            Duration dur = nv1.getDuration() ;
            boolean valid = XSDFuncOp.isDayTime(dur) ;
            if ( ! valid )
                throw new ExprEvalTypeException("Operator '*': only dayTime duration.  Got: "+nv1) ;
            BigDecimal dec = nv2.getDecimal() ;
            Duration r = dur.multiply(dec) ;
            Node n = NodeFactory.createLiteralNode(r.toString(), null, dtXSDdayTimeDuration) ;
            return NodeValue.makeNodeDuration(r, n) ;
        }
        throw new ExprEvalTypeException("Operator '*' : Undefined multiply: "+nv1+" and "+nv2) ;
    }
View Full Code Here

        schema = sf.newSchema( getClass().getResource("/schema/2.0b/oadr_20b.xsd") );
        this.validator = schema.newValidator();
    }
   
    @Test public void testSerialize() throws Exception {
        final Duration duration = xmlDataTypeFac.newDuration( true, 0, 0, 0, 0, 5, 0 );
       
        OadrSignedObject payload = new OadrSignedObject()
            .withOadrCreateReport( new OadrCreateReport()
                .withRequestID( "1234" )
                .withVenID( "Vtn-1234" )
                .withSchemaVersion( "2.0b" )
                .withOadrReportRequests( new OadrReportRequest()
                        .withReportRequestID( "request-1234" )
                        .withReportSpecifier( new ReportSpecifier()
                                .withReportSpecifierID( "1234" )
                                .withGranularity( new DurationPropType( new DurationValue( duration.toString() ) ) )
                                .withReportBackDuration( new DurationPropType( new DurationValue( duration.toString() ) ) )
                                .withSpecifierPayloads( new SpecifierPayload()
                                        .withRID( "report 1234" )
                                        .withReadingType( ReadingTypeEnumeratedType.DIRECT_READ.value() )
                                        .withItemBase( of.createPulseCount( new PulseCountType()
                                                .withItemDescription( "pulse count" )
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.