axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r291787 - /webservices/axis/trunk/java/src/org/apache/axis/wsdl/toJava/JavaBeanWriter.java
Date Mon, 26 Sep 2005 23:43:58 GMT
Author: dims
Date: Mon Sep 26 16:43:55 2005
New Revision: 291787

URL: http://svn.apache.org/viewcvs?rev=291787&view=rev
Log:
fix for AXIS-2236 - Bad constructor with derived classes that inherit xs:any members

Notes:
- change the order of attributes and elements
- fix null names for attributes
- fix null names for elements


Modified:
    webservices/axis/trunk/java/src/org/apache/axis/wsdl/toJava/JavaBeanWriter.java

Modified: webservices/axis/trunk/java/src/org/apache/axis/wsdl/toJava/JavaBeanWriter.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/src/org/apache/axis/wsdl/toJava/JavaBeanWriter.java?rev=291787&r1=291786&r2=291787&view=diff
==============================================================================
--- webservices/axis/trunk/java/src/org/apache/axis/wsdl/toJava/JavaBeanWriter.java (original)
+++ webservices/axis/trunk/java/src/org/apache/axis/wsdl/toJava/JavaBeanWriter.java Mon Sep
26 16:43:55 2005
@@ -314,13 +314,13 @@
             for (int i = 0; i < attributes.size(); i++) {
                 ContainedAttribute attr = (ContainedAttribute) attributes.get(i);
                 String typeName = attr.getType().getName();
-                String variableName = attr.getName();
+                String variableName = getAttributeName(attr);
 
-		// TODO - What about MinOccurs and Nillable?
-		// Do they make sense here?
-		if (attr.getOptional()) {
-		    typeName = Utils.getWrapperType(typeName);
-		}
+                // TODO - What about MinOccurs and Nillable?
+                // Do they make sense here?
+                if (attr.getOptional()) {
+                    typeName = Utils.getWrapperType(typeName);
+                }
 
                 // Make sure the property name is not reserved.
                 variableName = JavaUtils.getUniqueValue(
@@ -384,14 +384,29 @@
     }
 
     /**
-     * Check if we need to use the wrapper type
+     * generate a name for the attribute
+     * @param attr
+     * @return name
+     */
+    private String getAttributeName(ContainedAttribute attr) {
+        String variableName = attr.getName();
+        if (variableName == null) {
+            variableName = Utils.getLastLocalPart(attr.getQName().getLocalPart());
+        }
+        return variableName;
+    }
+
+    /**
+     * Check if we need to use the wrapper type or MessageElement
      *
      * @param elem
      * @param typeName
      * @return type name
      */
     private String processTypeName(ElementDecl elem, String typeName) {
-        if (elem.getType().getUnderlTypeNillable()
+        if (elem.getAnyElement()) {
+            typeName = "org.apache.axis.message.MessageElement []";
+        } else if (elem.getType().getUnderlTypeNillable()
                 || (elem.getNillable() && elem.getMaxOccursIsUnbounded())) {
                     /*
 		             * Soapenc arrays with nillable underlying type or
@@ -399,7 +414,6 @@
 		             * should be mapped to a wrapper type.
 		             */
             typeName = Utils.getWrapperType(elem.getType());
-
         } else if (elem.getMinOccursIs0() && elem.getMaxOccursIsExactlyOne()
                 || elem.getNillable() || elem.getOptional()) {
                     /*
@@ -667,17 +681,6 @@
                         + "_";
             }
 
-            // Process the attributes
-            Vector attributes = te.getContainedAttributes();
-            if (attributes != null) {
-                for (int j = 0; j < attributes.size(); j += 1) {
-                    ContainedAttribute attr = (ContainedAttribute) attributes.get(j);
-                    paramTypes.add(attr.getType().getName());
-                    paramNames.add(JavaUtils.getUniqueValue(
-                            helper.reservedPropNames, attr.getName()));
-                }
-            }
-
             // Process the elements
             Vector elements = te.getContainedElements();
 
@@ -685,8 +688,30 @@
                 for (int j = 0; j < elements.size(); j++) {
                     ElementDecl elem = (ElementDecl) elements.get(j);
                     paramTypes.add(processTypeName(elem,elem.getType().getName()));
+                    String name = elem.getName() == null ? ("param" + i) : elem.getName();
+                    paramNames.add(JavaUtils.getUniqueValue(
+                            helper.reservedPropNames, name));
+                }
+            }
+
+            // Process the attributes
+            Vector attributes = te.getContainedAttributes();
+            if (attributes != null) {
+                for (int j = 0; j < attributes.size(); j += 1) {
+                    ContainedAttribute attr = (ContainedAttribute) attributes.get(j);
+
+                    String name = getAttributeName(attr);
+                    String typeName = attr.getType().getName();
+
+                    // TODO - What about MinOccurs and Nillable?
+                    // Do they make sense here?
+                    if (attr.getOptional()) {
+                        typeName = Utils.getWrapperType(typeName);
+                    }
+
+                    paramTypes.add(typeName);
                     paramNames.add(JavaUtils.getUniqueValue(
-                            helper.reservedPropNames, elem.getName()));
+                            helper.reservedPropNames, name));
                 }
             }
 



Mime
View raw message