Uploaded image for project: 'Axis2'
  1. Axis2
  2. AXIS2-5789

Generated code for xsd:totalDigits throws NumberFormatException

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Duplicate
    • 1.7.3
    • None
    • adb, codegen
    • None

    Description

      In relation to issue https://issues.apache.org/jira/browse/AXIS2-5342,
      generated code for type:

          <simpleType name="INTERO3_TYPE">
              <restriction base="integer">
                  <totalDigits value="3"/>
              </restriction>
          </simpleType>
      

      produces a class with setter:

       public void setINTERO3_TYPE(java.math.BigInteger param) {
              java.lang.String totalDigitsDecimal = org.apache.axis2.databinding.utils.ConverterUtil.convertToStandardDecimalNotation("3").toPlainString();
      
              if (org.apache.axis2.databinding.utils.ConverterUtil.compare(param, totalDigitsDecimal) < 0) {
                  this.localINTERO3_TYPE = param;
              } else {
                  throw new java.lang.RuntimeException(
                      "Input values do not follow defined XSD restrictions");
              }
          }
      

      ConverterUtil.convertToStandardDecimalNotation produces a BigDecimal with a toPlainString() value "1000.0", but ConverterUtil.compare(BigInteger, String) contains code:

      ConverterUtil.java:1344
      public static long compare(BigInteger binBigInteger, String value) {
              return binBigInteger.longValue() - Long.parseLong(value);
          }
      
      

      which parses second string parameter as a Long, throwing a NumberFormatException

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              filjander Stefano Rodi
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: