cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r542753 - /incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/jaxb/WrapperHelper.java
Date Wed, 30 May 2007 05:33:38 GMT
Author: gawor
Date: Tue May 29 22:33:37 2007
New Revision: 542753

URL: http://svn.apache.org/viewvc?view=rev&rev=542753
Log:
match wrapper methods by fieldname and partname first, and if that fails try to match by partname
only

Modified:
    incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/jaxb/WrapperHelper.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=542753&r1=542752&r2=542753
==============================================================================
--- 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
Tue May 29 22:33:37 2007
@@ -89,19 +89,9 @@
                 }
             }
             if (!setInvoked) {
-                XmlElement el = null;
-                Field elField = null;
-                for (Field field : wrapperType.getClass().getDeclaredFields()) {
-                    if (field.getName().equals(fieldName)) {
-                        elField = field;
-                        el = elField.getAnnotation(XmlElement.class);
-                        break;
-                    }
-                }
+                Field elField = getField(wrapperType, partName, fieldName);
                 // JAXB Type get XmlElement Annotation
-                if (elField != null 
-                    && el != null
-                    && partName.equals(el.name())) {
+                if (elField != null) {
                     elField.setAccessible(true);
                     elField.set(wrapperType, part);
                     setInvoked = true;
@@ -112,6 +102,26 @@
                                                    + partName);
             }
         }
+    }
+
+    private static Field getField(Object wrapperType, String partName, String fieldName)
{
+        // match fieldName and partName first
+        for (Field field : wrapperType.getClass().getDeclaredFields()) {
+            if (field.getName().equals(fieldName)) {
+                XmlElement el = field.getAnnotation(XmlElement.class);
+                if (el != null && el.name().equals(partName)) {
+                    return field;
+                }
+            }
+        }
+        // if above fails, check partName only
+        for (Field field : wrapperType.getClass().getDeclaredFields()) {
+            XmlElement el = field.getAnnotation(XmlElement.class);
+            if (el != null && el.name().equals(partName)) {
+                return field;
+            }
+        }
+        return null;
     }
 
     private static boolean setJAXBElementValueIntoWrapType(Method method, Object wrapType,
Object value) {



Mime
View raw message