cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r537016 - in /incubator/cxf/trunk: common/common/src/main/java/org/apache/cxf/jaxb/WrapperHelper.java rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java
Date Thu, 10 May 2007 22:18:30 GMT
Author: dkulp
Date: Thu May 10 15:18:29 2007
New Revision: 537016

URL: http://svn.apache.org/viewvc?view=rev&rev=537016
Log:
Minor updates for boolean[] and for "list" types

Modified:
    incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/jaxb/WrapperHelper.java
    incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java

Modified: incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/jaxb/WrapperHelper.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/jaxb/WrapperHelper.java?view=diff&rev=537016&r1=537015&r2=537016
==============================================================================
--- incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/jaxb/WrapperHelper.java
(original)
+++ incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/jaxb/WrapperHelper.java
Thu May 10 15:18:29 2007
@@ -193,7 +193,9 @@
             accessor2 = "get_return";
         }
 
-        if (elementType != null && "boolean".equals(elementType.toLowerCase())) {
+        if (elementType != null 
+            && "boolean".equals(elementType.toLowerCase())
+            && !Collection.class.isAssignableFrom(elField.getType())) {
             // JAXB Exception to get the Boolean property
             accessor = accessor.replaceFirst("get", "is");
             accessor2 = accessor2.replaceFirst("get", "is");

Modified: incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java?view=diff&rev=537016&r1=537015&r2=537016
==============================================================================
--- incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java
(original)
+++ incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java
Thu May 10 15:18:29 2007
@@ -23,7 +23,9 @@
 import java.lang.reflect.GenericArrayType;
 import java.lang.reflect.ParameterizedType;
 import java.lang.reflect.Type;
+import java.util.Arrays;
 import java.util.Collection;
+import java.util.List;
 import java.util.ResourceBundle;
 
 import javax.xml.bind.JAXBContext;
@@ -47,6 +49,9 @@
 import org.apache.cxf.common.i18n.Message;
 import org.apache.cxf.interceptor.Fault;
 import org.apache.cxf.service.model.MessagePartInfo;
+import org.apache.ws.commons.schema.XmlSchemaElement;
+import org.apache.ws.commons.schema.XmlSchemaSimpleType;
+import org.apache.ws.commons.schema.XmlSchemaSimpleTypeList;
 
 /**
  * Utility functions for JAXB.
@@ -106,7 +111,19 @@
                 elName = part.getConcreteName();
             }
             
-            if (null != elName && !cls.isAnnotationPresent(XmlRootElement.class))
{
+            if (null != elName
+                && !cls.isAnnotationPresent(XmlRootElement.class)) {
+                
+                if (mObj.getClass().isArray()
+                    && part != null
+                    && part.getXmlSchema() instanceof XmlSchemaElement) {
+                    XmlSchemaElement el = (XmlSchemaElement)part.getXmlSchema();
+                    if (el.getSchemaType() instanceof XmlSchemaSimpleType
+                        && ((XmlSchemaSimpleType)el.getSchemaType()).getContent()
+                            instanceof XmlSchemaSimpleTypeList) {
+                        mObj = Arrays.asList((Object[])mObj);
+                    }
+                }
                 mObj = JAXBElement.class.getConstructor(new Class[] {QName.class, Class.class,
Object.class})
                     .newInstance(elName, cls, mObj);
             }
@@ -165,6 +182,7 @@
         return unmarshall(context, schema, source, null, null, true);
     }
 
+    @SuppressWarnings("unchecked")
     public static Object unmarshall(JAXBContext context, 
                                     Schema schema, 
                                     Object source,
@@ -173,6 +191,26 @@
                                     boolean unwrap) {
         Class<?> clazz = part != null ? (Class) part.getTypeClass() : null;
         QName elName = part != null ? part.getConcreteName() : null;
+        if (clazz != null
+            && clazz.isArray()
+            && part != null 
+            && part.getXmlSchema() instanceof XmlSchemaElement) {
+            XmlSchemaElement el = (XmlSchemaElement)part.getXmlSchema();
+            if (el.getSchemaType() instanceof XmlSchemaSimpleType
+                && ((XmlSchemaSimpleType)el.getSchemaType()).getContent()
+                    instanceof XmlSchemaSimpleTypeList) {
+                
+                Object obj = unmarshall(context, schema, source, elName, null, au, unwrap);
+                if (clazz.isArray()
+                    && obj instanceof List) {
+                    return ((List)obj).toArray((Object[])Array.newInstance(clazz.getComponentType(),
+                                                                 ((List)obj).size()));
+                }
+                    
+                
+                return obj;
+            }
+        }
 
         return unmarshall(context, schema, source, elName, clazz, au, unwrap);
     }



Mime
View raw message