axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aj...@apache.org
Subject svn commit: r321283 - in /webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema: JavaBeanWriter.java SchemaCompiler.java
Date Sat, 15 Oct 2005 03:54:33 GMT
Author: ajith
Date: Fri Oct 14 20:54:22 2005
New Revision: 321283

URL: http://svn.apache.org/viewcvs?rev=321283&view=rev
Log:
Modified the bean writer to fix the name repeating

Modified:
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/JavaBeanWriter.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/SchemaCompiler.java

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/JavaBeanWriter.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/JavaBeanWriter.java?rev=321283&r1=321282&r2=321283&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/JavaBeanWriter.java
(original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/JavaBeanWriter.java
Fri Oct 14 20:54:22 2005
@@ -14,6 +14,8 @@
 import javax.xml.transform.stream.StreamSource;
 import java.util.Iterator;
 import java.util.Map;
+import java.util.List;
+import java.util.ArrayList;
 import java.io.*;
 
 /*
@@ -38,6 +40,10 @@
     private boolean templateLoaded = false;
     private Templates templateCache;
 
+    private List namesList;
+    private static int count = 0;
+
+
 
     private File rootDir;
 
@@ -50,6 +56,7 @@
             this.rootDir = rootDir;
         }
 
+        namesList = new ArrayList();
     }
 
     /**
@@ -77,7 +84,9 @@
 
     private String process(QName qName, BeanWriterMetaInfoHolder metainf, Map typeMap, boolean
isElement) throws Exception {
         String packageName = URLProcessor.getNameSpaceFromURL(qName.getNamespaceURI());
-        String className = qName.getLocalPart();
+        String className = getNonConflictingName(this.namesList,qName.getLocalPart());
+
+        ArrayList propertyNames = new ArrayList();
 
         if (!templateLoaded){
             loadTemplate();
@@ -113,6 +122,7 @@
             }else{
                 javaName = JavaUtils.xmlNameToJava(xmlName,false);
             }
+            javaName = getNonConflictingName(propertyNames,javaName);
             XSLTUtils.addAttribute(model,"name",xmlName,property);
             XSLTUtils.addAttribute(model,"javaname",javaName,property);
             String javaClassNameForElement = metainf.getJavaClassNameForElement(name);
@@ -124,7 +134,7 @@
             if (typeMap.containsKey(metainf.getSchemaQNameForElement(name))){
                 XSLTUtils.addAttribute(model,"ours","yes",property); //todo introduce a better
name for this
             }
-             XSLTUtils.addAttribute(model,"shorttypename",shortTypeName,property);
+            XSLTUtils.addAttribute(model,"shorttypename",shortTypeName,property);
         }
 
         //create the file
@@ -137,6 +147,22 @@
 
     /**
      *
+     * @param listOfNames
+     * @param nameBase
+     * @return
+     */
+    private String getNonConflictingName(List listOfNames,String nameBase){
+        String nameToReturn = nameBase;
+        while (listOfNames.contains(nameToReturn)){
+            nameToReturn = nameToReturn + count++;
+        }
+
+        listOfNames.add(nameToReturn);
+        return nameToReturn;
+    }
+
+    /**
+     *
      * @param element
      * @param typeMap
      * @param metainf
@@ -148,7 +174,7 @@
         try {
             //determine the package for this type.
             QName qName = element.getQName();
-             return process(qName, metainf, typeMap, true);
+            return process(qName, metainf, typeMap, true);
         } catch (Exception e) {
             throw new SchemaCompilationException(e);
         }

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/SchemaCompiler.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/SchemaCompiler.java?rev=321283&r1=321282&r2=321283&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/SchemaCompiler.java
(original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/SchemaCompiler.java
Fri Oct 14 20:54:22 2005
@@ -120,9 +120,6 @@
         XmlSchemaType schemaType = schemaElement.getSchemaType();
 
         if (schemaType!=null){
-            //at this time it is not wise to directly write the class for the element
-            //so we push the complete element to an arraylist and let the process
-            //pass through
             BeanWriterMetaInfoHolder metainf = new BeanWriterMetaInfoHolder();
             QName qName = schemaType.getQName();
             //find the class name
@@ -150,8 +147,6 @@
         if (processedElementList.contains(xsElt.getQName())){
             return;
         }
-        System.out.println("xsElt = " + xsElt);
-        System.out.println("xsElt.getQName() = " + xsElt.getQName());
 
         XmlSchemaType schemaType = xsElt.getSchemaType();
 



Mime
View raw message