[ 
http://issues.apache.org/jira/browse/AXIS-1886?page=comments#action_61190 ]
     
Daniel David Schäfer commented on AXIS-1886:
--------------------------------------------

Hi,

this version should work:

===================================================================
RCS file: 
/usr/local/cvsroot/dev_projects/axis12/src/org/apache/axis/encoding/SerializationContext.java,v
retrieving revision 1.1
retrieving revision 1.3
diff -u -r1.1 -r1.3
--- dev_projects/axis12/src/org/apache/axis/encoding/SerializationContext.java  
2005/03/17 13:01:38     1.1
+++ dev_projects/axis12/src/org/apache/axis/encoding/SerializationContext.java  
2005/03/18 08:15:02     1.3
@@ -595,6 +595,22 @@
         return getTypeMapping().getTypeQName(cls);
     }
 
+       /**
+        * Checks if the javaType is a primitive-wrapper
+        */
+    private static boolean isPrimitiveWrapper(Class javaType)
+    {
+        if (javaType == Integer.class) return true;
+        if (javaType == Long.class) return true;
+        if (javaType == Double.class) return true;
+        if (javaType == Float.class) return true;
+        if (javaType == Boolean.class) return true;
+        if (javaType == Short.class) return true;
+        if (javaType == Character.class) return true;
+        if (javaType == Byte.class) return true;
+        return false;
+    }
+       
     /**
      * Indicates whether the object should be interpretted as a primitive
      * for the purposes of multi-ref processing.  A primitive value
@@ -606,11 +622,10 @@
     public boolean isPrimitive(Object value)
     {
         if (value == null) return true;
-
+               
         Class javaType = value.getClass();
 
-        if (javaType.isPrimitive()) return true;
-
+               if (SerializationContext.isPrimitiveWrapper(javaType)) return 
true;
         if (javaType == String.class) return true;
         if (Calendar.class.isAssignableFrom(javaType)) return true;
         if (Date.class.isAssignableFrom(javaType)) return true;



> Axis serializes xsd:int as multiRef
> -----------------------------------
>
>          Key: AXIS-1886
>          URL: http://issues.apache.org/jira/browse/AXIS-1886
>      Project: Axis
>         Type: Bug
>   Components: Serialization/Deserialization
>     Versions: 1.2RC3
>  Environment: every environment
>     Reporter: Daniel David Schäfer

>
> Hi all,
> I found a strange behaviour of axis when it serializes nillable bean-members 
> declared as xsd:int.
> I think, it is absolutely overkill to encode a single integer to a chunk like 
> this:
> <multiRef 
>       id="id5"
>       soapenc:root="0" 
>       soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"; 
>       xsi:type="xsd:int"
>       
> xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/";>1111054002</multiRef>
> I found a routine called isPrimitive() that decides if a given object should 
> be serialized as an 
> object-reference (multiRef at the end of the soap-body) or directly into the 
> data-structure where
> it is located. This routine calls obj.getClass().isPrimitive() which is 
> unfortunately never true
> with any java-object but only with class-objects like Integer.TYPE (which is 
> the type of int and not
> of java.lang.Integer). 
> So I provided a little patch that returns true for isPrimitive if the given 
> object is of a subtype
> of java.lang.Number (like Integer, Float, etc.).
> bye
> Daniel
> ===================================================================
> RCS file: 
> /usr/local/cvsroot/dev_projects/axis12/src/org/apache/axis/encoding/SerializationContext.java,v
> retrieving revision 1.1
> retrieving revision 1.2
> diff -u -r1.1 -r1.2
> --- 
> dev_projects/axis12/src/org/apache/axis/encoding/SerializationContext.java    
>     2005/03/17 13:01:38     1.1
> +++ 
> dev_projects/axis12/src/org/apache/axis/encoding/SerializationContext.java    
>     2005/03/17 13:03:05     1.2
> @@ -606,9 +606,13 @@
>      public boolean isPrimitive(Object value)
>      {
>          if (value == null) return true;
> -
> +             
> +             if(value instanceof java.lang.Number) {
> +                     return true;
> +             }
> +             
>          Class javaType = value.getClass();
> -
> +             
>          if (javaType.isPrimitive()) return true;
>  
>          if (javaType == String.class) return true;

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira

Reply via email to