Package org.exolab.castor.types

Examples of org.exolab.castor.types.Duration


            ShippingMethod method = invoice.getShippingMethod();
            System.out.print("   " + method.getCarrier());
            System.out.println("  " + method.getOption());
            System.out.print("   Estimated Time: ");

            Duration duration = method.getEstimatedDelivery();

            int years = duration.getYear();
            int months = duration.getMonth();
            int days = duration.getDay();
            int hours = duration.getHour();

            boolean printComma = false;

            if (years > 0) {
                System.out.print(years + " year(s)");
View Full Code Here


            throw new ValidationException(err);
        }

        if (object instanceof String) {
            try {
                Duration duration = Duration.parseDuration((String) object);
                validate(duration, context);
                return;
            } catch (java.text.ParseException pe) {
                String err = "String provided fails to parse into a Duration: " + (String) object;
                throw new ValidationException(err, pe);
            }
        }

        Duration value = null;
        try {
            value = (Duration) object;
        } catch (Exception ex) {
            String err = "Expecting a duration, received instead: " + object.getClass().getName();
            throw new ValidationException(err);
View Full Code Here

    if (jsc == null)
      jsc = new JSourceCode();
   
    jsc.add("DurationValidator typeValidator = new DurationValidator();");
    if (hasMinimum()) {
      Duration min = getMinExclusive();
      if (min != null)
        jsc.add("typeValidator.setMinExclusive(");
      else {
        min = getMinInclusive();
        jsc.add("typeValidator.setMinInclusive(");
      }
      /* it is better for a good understanding to use
      the parse method with 'min.toSring()' but in that case
      we have to deal with the ParseException*/
      jsc.append(
        "new org.exolab.castor.types.Duration(" + min.toLong() + "L)");
      jsc.append(");");
    }
    if (hasMaximum()) {
      Duration max = getMaxExclusive();
      if (max != null)
        jsc.add("typeValidator.setMaxExclusive(");
      else {
        max = getMaxInclusive();
        jsc.add("typeValidator.setMaxInclusive(");
      }
      /* it is better for a good understanding to use
      the parse method with 'min.toSring()' but in that case
      we have to deal with the ParseException*/
      jsc.append(
        "new org.exolab.castor.types.Duration(" + max.toLong() + "L)");
      jsc.append(");");
    }
    //-- pattern facet
   
    jsc.add(fieldValidatorInstanceName+".setValidator(typeValidator);");
View Full Code Here

        if (object == null) {
            String err = "durationValidator cannot validate a null object.";
            throw new ValidationException(err);
        }

        Duration value = null;
        try {
            value = Duration.parseDuration(object.toString());
        }
        catch(Exception ex) {
            String err = "Expecting a duration, received instead: ";
View Full Code Here

    if (jsc == null)
      jsc = new JSourceCode();
   
    jsc.add("DurationValidator typeValidator = new DurationValidator();");
    if (hasMinimum()) {
      Duration min = getMinExclusive();
      if (min != null)
        jsc.add("typeValidator.setMinExclusive(");
      else {
        min = getMinInclusive();
        jsc.add("typeValidator.setMinInclusive(");
      }
      /* it is better for a good understanding to use
      the parse method with 'min.toSring()' but in that case
      we have to deal with the ParseException*/
      jsc.append(
        "new org.exolab.castor.types.Duration(" + min.toLong() + "L)");
      jsc.append(");");
    }
    if (hasMaximum()) {
      Duration max = getMaxExclusive();
      if (max != null)
        jsc.add("typeValidator.setMaxExclusive(");
      else {
        max = getMaxInclusive();
        jsc.add("typeValidator.setMaxInclusive(");
      }
      /* it is better for a good understanding to use
      the parse method with 'min.toSring()' but in that case
      we have to deal with the ParseException*/
      jsc.append(
        "new org.exolab.castor.types.Duration(" + max.toLong() + "L)");
      jsc.append(");");
    }
    //-- pattern facet
   
    jsc.add(fieldValidatorInstanceName+".setValidator(typeValidator);");
View Full Code Here

      ShippingMethod method = invoice.getShippingMethod();
      System.out.print("   " + method.getCarrier());
      System.out.println("  " + method.getOption());
      System.out.print("   Estimated Time: ");

      Duration duration = method.getEstimatedDelivery();

      int years  = duration.getYear();
      int months = duration.getMonth();
      int days   = duration.getDay();
      int hours  = duration.getHour();

      boolean printComma = false;

      if (years > 0) {
          System.out.print(years + " year(s)");
View Full Code Here

TOP

Related Classes of org.exolab.castor.types.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.