You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by aj...@apache.org on 2006/01/22 08:01:00 UTC

svn commit: r371222 - in /webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema: SchemaCompiler.java template/ADBBeanTemplate.xsl writer/JavaBeanWriter.java

Author: ajith
Date: Sat Jan 21 23:00:53 2006
New Revision: 371222

URL: http://svn.apache.org/viewcvs?rev=371222&view=rev
Log:
Made a small fix for the OMElement case. Still needs a bit of fixing in the deserilizer

Modified:
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/SchemaCompiler.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/writer/JavaBeanWriter.java

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/SchemaCompiler.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/SchemaCompiler.java?rev=371222&r1=371221&r2=371222&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/SchemaCompiler.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/SchemaCompiler.java Sat Jan 21 23:00:53 2006
@@ -75,6 +75,8 @@
     private static final String ANY_ELEMENT_FIELD_NAME = "extraElements";
     private static final String EXTRA_ATTRIBUTE_FIELD_NAME = "extraAttributes";
 
+    public static final String DEFAULT_CLASS_NAME = OMElement.class.getName();
+
 
     /**
      * @return the processes element map
@@ -324,7 +326,7 @@
             //contained schema type. We better set the default then
             //however it's better if the default can be set through the
             //property file
-            className = OMElement.class.getName();
+            className = DEFAULT_CLASS_NAME;
         }
         if (isArray) {
             //append the square braces that say this is an array
@@ -588,7 +590,7 @@
         //we need to put a name here
         metainf.registerMapping(new QName(ANY_ELEMENT_FIELD_NAME),
                 null,
-                OMElement.class.getName(),
+                DEFAULT_CLASS_NAME,
                 SchemaConstants.ANY_TYPE);
 
     }

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl?rev=371222&r1=371221&r2=371222&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl Sat Jan 21 23:00:53 2006
@@ -145,7 +145,7 @@
 
                     <xsl:if test="$min=0"> if (<xsl:value-of select="$settingTracker"/>){</xsl:if>
                     <xsl:choose>
-                        <xsl:when test="@ours or @any">
+                        <xsl:when test="@ours or @any or @default">
                             elementList.add(new javax.xml.namespace.QName("<xsl:value-of select="$namespace"/>",
                                                                       "<xsl:value-of select="$propertyName"/>"));
                             elementList.add(<xsl:value-of select="$varName"/>);

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/writer/JavaBeanWriter.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/writer/JavaBeanWriter.java?rev=371222&r1=371221&r2=371222&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/writer/JavaBeanWriter.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/writer/JavaBeanWriter.java Sat Jan 21 23:00:53 2006
@@ -3,6 +3,7 @@
 import org.apache.axis2.schema.BeanWriterMetaInfoHolder;
 import org.apache.axis2.schema.CompilerOptions;
 import org.apache.axis2.schema.SchemaCompilationException;
+import org.apache.axis2.schema.SchemaCompiler;
 import org.apache.axis2.schema.i18n.SchemaCompilerMessages;
 import org.apache.axis2.schema.util.SchemaPropertyLoader;
 import org.apache.axis2.util.JavaUtils;
@@ -370,7 +371,14 @@
             if (javaClassNameForElement == null) {
                 throw new SchemaCompilationException("Type missing!");
             }
+
             XSLTUtils.addAttribute(model, "type", javaClassNameForElement, property);
+
+            //add an attribute that says the type is default
+            if (isDefault(javaClassNameForElement)){
+                XSLTUtils.addAttribute(model, "default", "yes", property);
+            }
+
             if (typeMap.containsKey(metainf.getSchemaQNameForQName(name))) {
                 XSLTUtils.addAttribute(model, "ours", "yes", property); //todo introduce a better name for this
             }
@@ -413,9 +421,18 @@
         }
 
         /////////////////////////////////////
-//        System.out.println("rootElt = " + rootElt);
+        //System.out.println("rootElt = " + rootElt);
         /////////////////////////////////////
         return rootElt;
+    }
+
+    /**
+     * Test whether the given class name matches the default
+     * @param javaClassNameForElement
+     * @return
+     */
+    private boolean isDefault(String javaClassNameForElement) {
+        return SchemaCompiler.DEFAULT_CLASS_NAME.equals(javaClassNameForElement);
     }