axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Julie.Han...@mincom.com
Subject Re: Problem with setting boolean to nil
Date Mon, 23 Jun 2008 06:12:21 GMT
Thanks for your reply Amila.

I have tried as you suggested, but am getting compile errors now when 
compiling.

This is the code snippet generated to delcare the boolean attriute.

<code>

                        /**
                        * field for IgnoreConflict
                        */
                         protected java.lang.Boolean localIgnoreConflict ;
 
                           /**
                           * Auto generated getter method
                           * @return java.lang.Boolean
                           */
                           public  java.lang.Boolean getIgnoreConflict(){
                               return localIgnoreConflict;
                           }

                            /**
                               * Auto generated setter method
                               * @param param IgnoreConflict
                               */
                               public void 
setIgnoreConflict(java.lang.Boolean param){
 this.localIgnoreConflict=param;
                               }

</code>

which it has created as a Boolean


however the code generated to set this value is :


<code>
                                  while (!reader.isStartElement() && 
!reader.isEndElement()) reader.next();
 
                                    if (reader.isStartElement() && new 
javax.xml.namespace.QName("","ignoreConflict").equals(reader.getName())){
 
                                       nillableValue = 
reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance","nil");
                                       if (!"true".equals(nillableValue) 
&& !"1".equals(nillableValue)){
 
                                    java.lang.String content = 
reader.getElementText();
 
                                              object.setIgnoreConflict(
 
org.apache.axis2.databinding.utils.ConverterUtil.convertToBoolean(content));
 
                                       } else {
 
 
                                           reader.getElementText(); // 
throw away text nodes if any.
                                       }
 
                                        reader.next();
 </code>


Note the call to setIgnoreConflict, which uses 
ConvertUtil.convertToBoolean
This method returns a boolean, not a Boolean.


<code>

    public static boolean convertToBoolean(String s) {

        boolean returnValue = false;
        if ((s != null) && (s.length() > 0)) {
            if ("1".equals(s) || s.toLowerCase().equals("true")) {
                returnValue = true;
            } else if (!"0".equals(s) && !s.toLowerCase().equals("false")) 
{
                throw new RuntimeException("in valid string -" + s + " for 
boolean value");
            }
        }
        return returnValue;
    }

</code>


Hence causing the compile error.

Is this a known problem, or have I done something wrong during the 
generation.
If it is a known problem, I'm guessing I will have to modify the 
convertToBoolean method (assuming nothing else uses it), or is there 
another way around this problem??

Thanks

Julie

-- 
This transmission is for the intended addressee only and is confidential information. If you
have received this transmission in error, please notify the sender and delete the transmission.
The contents of this e-mail are the opinion of the writer only and are not endorsed by the
Mincom Group of companies unless expressly stated otherwise.
-- 






Mime
View raw message