axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jens Müller (JIRA) <j...@apache.org>
Subject [jira] [Comment Edited] (AXIS2-5724) totalDigits Facet of XSD type int incorrectly treated in databinding
Date Wed, 08 Jun 2016 14:52:21 GMT

    [ https://issues.apache.org/jira/browse/AXIS2-5724?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15320677#comment-15320677
] 

Jens Müller edited comment on AXIS2-5724 at 6/8/16 2:51 PM:
------------------------------------------------------------

I have the same Problem. it occurse every time you have an "integer" type with "totalDigits"
like the example:

            <xsd:restriction base="xsd:integer">
              <xsd:totalDigits value="2"/>
            </xsd:restriction>

In this case the adb Generator converts the maximum value to a BigDecimal. Which not can be
converted to a Long.
As a Workaround i have patched the file ADBBeanTemplate-bean.xsl (after <xsl:when test="(@totalDigitsFacet)">
line 480 in the file) in the following way;

   <xsl:if test="$shortTypeName != 'Integer'">
           java.lang.String totalDigitsDecimal = org.apache.axis2.databinding.utils.ConverterUtil.convertToStandardDecimalNotation("<xsl:value-of
select="$totalDigitsFacet"/>").toPlainString();
   </xsl:if>
   <xsl:if test="$shortTypeName = 'Integer'">
          java.lang.String totalDigitsDecimal = org.apache.axis2.databinding.utils.ConverterUtil.convertToStandardDecimalNotation("<xsl:value-of
select="$totalDigitsFacet"/>").toBigInteger().toString();
</xsl:if>

original code is
                                        <xsl:when test="(@totalDigitsFacet)">
                                            java.lang.String totalDigitsDecimal = org.apache.axis2.databinding.utils.ConverterUtil.convertToStandardDecimalNotation("<xsl:value-of
select="$totalDigitsFacet"/>").toPlainString();
                                            if (org.apache.axis2.databinding.utils.ConverterUtil.compare(param,
totalDigitsDecimal) &lt; 0){
                                                    this.<xsl:value-of select="$varName"/>=param;
                                            }
I use the Version 1.6.3. But the error is also reproduceable in all version after this.





was (Author: jens1):
I have the same Problem. it occurse every time you have an "integer" type with "totalDigits"
like the example:

            <xsd:restriction base="xsd:integer">
              <xsd:totalDigits value="2"/>
            </xsd:restriction>

In this case the adb Generator converts the maximum value to a BigDecimal. Which not can be
converted to a Long.
As a Workaround i have patched the file ADBBeanTemplate-bean.xsl (after <xsl:when test="(@totalDigitsFacet)">
line 480 in the file) in the following way;

   <xsl:if test="$shortTypeName != 'Integer'">
           java.lang.String totalDigitsDecimal = org.apache.axis2.databinding.utils.ConverterUtil.convertToStandardDecimalNotation("<xsl:value-of
select="$totalDigitsFacet"/>").toPlainString();
   </xsl:if>
   <xsl:if test="$shortTypeName = 'Integer'">
          java.lang.String totalDigitsDecimal = org.apache.axis2.databinding.utils.ConverterUtil.convertToStandardDecimalNotation("<xsl:value-of
select="$totalDigitsFacet"/>").toBigInteger().toString();
</xsl:if>

original code is
                                        <xsl:when test="(@totalDigitsFacet)">
                                            java.lang.String totalDigitsDecimal = org.apache.axis2.databinding.utils.ConverterUtil.convertToStandardDecimalNotation("<xsl:value-of
select="$totalDigitsFacet"/>").toPlainString();
                                            if (org.apache.axis2.databinding.utils.ConverterUtil.compare(param,
totalDigitsDecimal) &lt; 0){
                                                    this.<xsl:value-of select="$varName"/>=param;
                                            }
I use the Version 1.6.3. But the error is also reproduceable in all Version after this

> totalDigits Facet of XSD type int incorrectly treated in databinding
> --------------------------------------------------------------------
>
>                 Key: AXIS2-5724
>                 URL: https://issues.apache.org/jira/browse/AXIS2-5724
>             Project: Axis2
>          Issue Type: Bug
>          Components: adb
>    Affects Versions: 1.6.3
>         Environment: Windows 10, cygwin, java 1.8.0_60
>            Reporter: Jeff Greif (work)
>            Priority: Minor
>
> Note: I could not enter the release I'm using: 1.6.2.
> The following XSD fragment 
> <xsd:complexType name="EMPL_RCDTypeShape"><xsd:simpleContent><xsd:extension
base="EMPL_RCDTypeDef"/></xsd:simpleContent></xsd:complexType>
> <xsd:simpleType name="EMPL_RCDTypeDef"><xsd:restriction base="xsd:int"><xsd:totalDigits
value="3"/></xsd:restriction></xsd:simpleType>
> produces, in a stub generated by wsdl2java
> public void setEMPL_RCDTypeDef(int param){
>     java.lang.String totalDigitsDecimal = org.apache.axis2.databinding.utils.ConverterUtil.convertToStandardDecimalNotation("3").toString();
>     if (org.apache.axis2.databinding.utils.ConverterUtil.compare(param, totalDigitsDecimal)
> 0){
>         this.localEMPL_RCDTypeDef=param;
>     }
>     else {
>        throw new java.lang.RuntimeException();
>    }
> }
> The string value of totalDigitsDecimal is "1000.0", rather than "1000", or  some different
method should have been called to convert totalDigits to a string, causing the error seen
in this stacktrace snippet:
> Caused by: java.lang.NumberFormatException: For input string: "1000.0"
>     at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
>     at java.lang.Integer.parseInt(Integer.java:580)
>     at java.lang.Integer.parseInt(Integer.java:615)
>     at org.apache.axis2.databinding.utils.ConverterUtil.compare(ConverterUtil.java:1249)
>     at com....SomeStub$EMPL_RCDTypeShape2.setEMPL_RCDTypeDef(CI_PRJ_ABSV_RQST_CIStub.java)



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@axis.apache.org
For additional commands, e-mail: java-dev-help@axis.apache.org


Mime
View raw message