axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ami...@apache.org
Subject svn commit: r598197 - in /webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema: CompilerOptions.java ExtensionUtility.java SchemaConstants.java XSD2Java.java util/PrimitiveTypeWrapper.java writer/JavaBeanWriter.java
Date Mon, 26 Nov 2007 10:04:52 GMT
Author: amilas
Date: Mon Nov 26 02:04:44 2007
New Revision: 598197

URL: http://svn.apache.org/viewvc?rev=598197&view=rev
Log:
Add code to use wrapper types instead of primitive types if nillable and minOccurs is zero.

Modified:
    webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/CompilerOptions.java
    webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/ExtensionUtility.java
    webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/SchemaConstants.java
    webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/XSD2Java.java
    webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/util/PrimitiveTypeWrapper.java
    webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/writer/JavaBeanWriter.java

Modified: webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/CompilerOptions.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/CompilerOptions.java?rev=598197&r1=598196&r2=598197&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/CompilerOptions.java
(original)
+++ webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/CompilerOptions.java
Mon Nov 26 02:04:44 2007
@@ -46,6 +46,7 @@
     private boolean generateAll = false;
 
     private boolean offStrictValidation = false;
+    private boolean isUseWrapperClasses = false;
 
     /**
      * Package for the mapper
@@ -195,5 +196,11 @@
         this.offStrictValidation = offStrictValidation;
     }
 
+    public boolean isUseWrapperClasses() {
+        return isUseWrapperClasses;
+    }
 
+    public void setUseWrapperClasses(boolean useWrapperClasses) {
+        this.isUseWrapperClasses = useWrapperClasses;
+    }
 }

Modified: webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/ExtensionUtility.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/ExtensionUtility.java?rev=598197&r1=598196&r2=598197&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/ExtensionUtility.java
(original)
+++ webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/ExtensionUtility.java
Mon Nov 26 02:04:44 2007
@@ -584,6 +584,10 @@
             options.setOffStrictValidation(true);
         }
 
+        if (propertyMap.containsKey(SchemaConstants.SchemaCompilerArguments.USE_WRAPPER_CLASSES)){
+            options.setUseWrapperClasses(true);
+        }
+
         //set helper mode
         //this becomes effective only if the classes are unpacked
         if (!options.isWrapClasses()) {

Modified: webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/SchemaConstants.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/SchemaConstants.java?rev=598197&r1=598196&r2=598197&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/SchemaConstants.java
(original)
+++ webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/SchemaConstants.java
Mon Nov 26 02:04:44 2007
@@ -110,7 +110,10 @@
         public static final String PACKAGE = "p";
         public static final String MAPPER_PACKAGE = "mp";
         public static final String HELPER_MODE = "h";
+        // this option is used to set minOccurs =0 for all the elements
         public static final String OFF_STRICT_VALIDATION = "osv";
+        // this option is used to use Wrapper classes for primitives
+        public static final String USE_WRAPPER_CLASSES = "uwc";
 
     }
 

Modified: webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/XSD2Java.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/XSD2Java.java?rev=598197&r1=598196&r2=598197&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/XSD2Java.java
(original)
+++ webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/XSD2Java.java
Mon Nov 26 02:04:44 2007
@@ -83,6 +83,8 @@
             //there's no point in not writing the classes here.
              compilerOptions.setWriteOutput(true);
 
+//             compilerOptions.setUseWrapperClasses(true);
+
             SchemaCompiler compiler = new SchemaCompiler(compilerOptions);
             compiler.compile(currentSchema);
     }

Modified: webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/util/PrimitiveTypeWrapper.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/util/PrimitiveTypeWrapper.java?rev=598197&r1=598196&r2=598197&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/util/PrimitiveTypeWrapper.java
(original)
+++ webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/util/PrimitiveTypeWrapper.java
Mon Nov 26 02:04:44 2007
@@ -47,6 +47,13 @@
      * @param primitiveclassName
      */
     public static String getWrapper(String primitiveclassName){
-        return (String) primitiveTypeWrappersMap.get(primitiveclassName);
+        String returnClassName = null;
+        if (primitiveclassName.trim().endsWith("[]")) {
+            String className = primitiveclassName.substring(0, primitiveclassName.length()
- 2);
+            returnClassName = primitiveTypeWrappersMap.get(className) + "[]";
+        } else {
+            returnClassName = (String) primitiveTypeWrappersMap.get(primitiveclassName);
+        }
+        return returnClassName;
     }
 }

Modified: webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/writer/JavaBeanWriter.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/writer/JavaBeanWriter.java?rev=598197&r1=598196&r2=598197&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/writer/JavaBeanWriter.java
(original)
+++ webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/writer/JavaBeanWriter.java
Mon Nov 26 02:04:44 2007
@@ -44,8 +44,6 @@
 import java.io.*;
 import java.util.*;
 
-import com.ibm.wsdl.util.xml.DOM2Writer;
-
 /**
  * Java Bean writer for the schema compiler.
  */
@@ -69,6 +67,8 @@
 
     private boolean writeClasses = false;
 
+    private boolean isUseWrapperClasses = false;
+
     private String packageName = null;
 
     private File rootDir;
@@ -149,6 +149,8 @@
             initWithFile(options.getOutputLocation());
             packageName = options.getPackageName();
             writeClasses = options.isWriteOutput();
+            isUseWrapperClasses = options.isUseWrapperClasses();
+
             if (!writeClasses) {
                 wrapClasses = false;
             } else {
@@ -491,6 +493,7 @@
         XSLTUtils.addAttribute(model, "originalName", originalName, rootElt);
         XSLTUtils.addAttribute(model, "package", packageName, rootElt);
         XSLTUtils.addAttribute(model, "nsuri", qName.getNamespaceURI(), rootElt);
+        XSLTUtils.addAttribute(model, "isUseWrapperClasses", isUseWrapperClasses? "yes" :
"false", rootElt);
         XSLTUtils.addAttribute(model, "nsprefix", isSuppressPrefixesMode ? "" : getPrefixForURI(qName
                 .getNamespaceURI(), qName.getPrefix()), rootElt);
 
@@ -730,9 +733,18 @@
                 //XSLTUtils.addAttribute(model, "restricted", "yes", property);
             }
 
+            long minOccurs = metainf.getMinOccurs(name);
+            if (PrimitiveTypeFinder.isPrimitive(javaClassNameForElement)
+                    && isUseWrapperClasses && ((minOccurs == 0) || metainf.isNillable(name)))
{
+                 // if this is an primitive class and user wants to use the
+                 // wrapper type we change the type to wrapper type.
+                 javaClassNameForElement = PrimitiveTypeWrapper.getWrapper(javaClassNameForElement);
+            }
+
             XSLTUtils.addAttribute(model, "type", javaClassNameForElement, property);
 
             if (PrimitiveTypeFinder.isPrimitive(javaClassNameForElement)) {
+
                 XSLTUtils.addAttribute(model, "primitive", "yes", property);
             }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org


Mime
View raw message