axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nadira...@apache.org
Subject svn commit: r424580 - in /webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws: CUtils.java WSDL2Ws.java c/AllParamWriter.java cpp/AllParamWriter.java info/Type.java
Date Sat, 22 Jul 2006 14:19:55 GMT
Author: nadiramra
Date: Sat Jul 22 07:19:55 2006
New Revision: 424580

URL: http://svn.apache.org/viewvc?rev=424580&view=rev
Log:
Consistent use of sanitiseClassName() for generate type names.

Modified:
    webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/CUtils.java
    webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/WSDL2Ws.java
    webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/AllParamWriter.java
    webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/AllParamWriter.java
    webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/info/Type.java

Modified: webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/CUtils.java
URL: http://svn.apache.org/viewvc/webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/CUtils.java?rev=424580&r1=424579&r2=424580&view=diff
==============================================================================
--- webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/CUtils.java (original)
+++ webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/CUtils.java Sat Jul 22
07:19:55 2006
@@ -78,6 +78,7 @@
     private static Hashtable isPointerBasedType = new Hashtable();
     private static boolean cpp = true;
     
+    // following in support of generating unique names
     private static Hashtable uniqueNameMapper = new Hashtable();
     private static Vector uniqueNamesGenerated = new Vector();
     
@@ -935,11 +936,7 @@
         if((cpp && !qname2classmapCpp.containsKey(qname)) ||
            (!cpp && !qname2classmapC.containsKey(qname)))
         {
-            /* arrayName = qname.getLocalPart()+"_Array";
-            * This avoid compilation issue for wsdl SimpleTypeInnerUnboundedInOutput.wsdl
-            * See : malling list.
-            */
-            arrayName = qname.getLocalPart().replace('>','_')+"_Array";            
+            arrayName = CUtils.sanitiseClassName(qname.getLocalPart()) + "_Array";
         }
         return arrayName;        
     }
@@ -1055,13 +1052,20 @@
     
     public static String sanitiseClassName( String name)
     {
-        String sanitisedName = name;
+        int i;
+        String sanitisedName=name;
+        
+        // Anonymous names start with '>'. For example, '>Type'. However, if it was

+        // nested, then it would be something like '>>Type>Type2'. 
+        // We should really be nice and get the name after last '>', but will wait and
+        // simply remove starting '>'.
+        for (i=0; i<name.length() && name.charAt(i) == TypeMap.ANON_TOKEN_CHAR;
++i);
+        sanitisedName = name.substring(i);
 
-        for( int i=0; i < Array.getLength(invalidCChars); i++)
+        // Now replace invalid character with '_'
+        for(i=0; i < Array.getLength(invalidCChars); i++)
             sanitisedName = sanitisedName.replace((char)invalidCChars[i], '_'); 
         
-        //System.out.println("name=" + name + " sanitisedName=" + sanitisedName);
-        
         return sanitisedName;
     }
 
@@ -1096,14 +1100,7 @@
         // If name was not in hash table, generate one, store in hash table.
         if (newName == null)
         {            
-            // Anonymous names start with '>'. For example, '>Type'. However, if it
was 
-            // nested, then it would be something like '>>Type>Type2'. 
-            // We should really be nice and get the name after last '>', but will wait.
           
-            newName = oldName;
-            
-            // Ensure invalid characters are replaced
-            for(i=0; i < Array.getLength(invalidCChars); i++)
-                newName = newName.replace((char)invalidCChars[i], '_');             
+            newName = sanitiseClassName(oldName);
             
             // Ensure name does not conflict with language constructs
             newName = TypeMap.resolveWSDL2LanguageNameClashes(newName, WrapperConstants.LANGUAGE_CPP);

Modified: webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/WSDL2Ws.java
URL: http://svn.apache.org/viewvc/webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/WSDL2Ws.java?rev=424580&r1=424579&r2=424580&view=diff
==============================================================================
--- webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/WSDL2Ws.java (original)
+++ webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/WSDL2Ws.java Sat Jul 22
07:19:55 2006
@@ -736,7 +736,8 @@
 
     public Type createTypeInfo(TypeEntry type, String targetLanguage) throws WrapperFault
     {
-        Type typedata;
+        Type typedata = null;
+        Type newSecondaryType = null;
         
         // Do not add types which are not used in the wsdl
         if (!type.isReferenced())
@@ -835,14 +836,13 @@
             {
                 String localpart = type.getQName().getLocalPart() + "_value";
                 QName typeName =  new QName(type.getQName().getNamespaceURI(), localpart);
-                ElementInfo eleinfo = new ElementInfo(typeName, createTypeInfo(base.getQName(),

-                                                      targetLanguage));
+                newSecondaryType = createTypeInfo(base.getQName(), targetLanguage);
+                ElementInfo eleinfo = new ElementInfo(typeName, newSecondaryType);
                 typedata.setExtensionBaseType(eleinfo);
                 if (WSDL2Ws.verbose)
                     System.out.print(
                         "=====complexType with simpleContent is found : "
-                            + type.getQName().getLocalPart()
-                            + "=====\n");
+                            + type.getQName().getLocalPart() + "=====\n");
             }
             else
             {
@@ -859,16 +859,15 @@
             if (attributes != null)
                 for (int j = 0; j < attributes.size(); j += 2)
                 {
+                    newSecondaryType = createTypeInfo(((TypeEntry) attributes.get(j)).getQName(),
targetLanguage);
                     typedata.setTypeForAttributeName(
-                        ((QName) attributes.get(j + 1)).getLocalPart(),
-                        createTypeInfo(((TypeEntry) attributes.get(j)).getQName(), targetLanguage));
+                        ((QName) attributes.get(j + 1)).getLocalPart(), newSecondaryType);
                 }
         }
         else if (type instanceof CollectionType)
         {
-            typedata.setTypeNameForElementName(
-                new ElementInfo(type.getQName(),
-                                createTypeInfo(type.getRefType().getQName(),targetLanguage)));
+            newSecondaryType = createTypeInfo(type.getRefType().getQName(),targetLanguage);
+            typedata.setTypeNameForElementName(new ElementInfo(type.getQName(),newSecondaryType));
             typedata.setArray(true);
         }
         else
@@ -877,14 +876,14 @@
             QName arrayType = CSchemaUtils.getArrayComponentQName(node,new IntHolder(0),symbolTable);
             if (arrayType != null)
             {
-                typedata.setTypeNameForElementName(
-                    new ElementInfo(new QName("item"), createTypeInfo(arrayType, targetLanguage)));
+                newSecondaryType = createTypeInfo(arrayType, targetLanguage);
+                typedata.setTypeNameForElementName(new ElementInfo(new QName("item"), newSecondaryType));
                 typedata.setArray(true);
             }
             else if ((arrayType = CSchemaUtils.getCollectionComponentQName(node)) != null)
             {
-                typedata.setTypeNameForElementName(
-                    new ElementInfo(new QName("item"), createTypeInfo(arrayType, targetLanguage)));
+                newSecondaryType = createTypeInfo(arrayType, targetLanguage);
+                typedata.setTypeNameForElementName(new ElementInfo(new QName("item"), newSecondaryType));
                 typedata.setArray(true);
             }
             //Note in a array the parameter type is stored as under the name item all the
time  
@@ -894,7 +893,7 @@
                 Vector extendList = new Vector();
                 extendList.add(type);
                 
-                TypeEntry parent =
+                TypeEntry parent = 
                     CSchemaUtils.getComplexElementExtensionBase(type.getNode(), symbolTable);
                 while (parent != null)
                 {
@@ -929,10 +928,10 @@
                     if (attributes != null)
                         for (int j = 0; j < attributes.size(); j += 2)
                         {
-                            typedata.setTypeForAttributeName(
-                                ((QName) attributes.get(j + 1)).getLocalPart(),
-                                createTypeInfo(((TypeEntry) attributes.get(j)).getQName(),
-                                    targetLanguage));
+                            newSecondaryType = createTypeInfo(((TypeEntry) attributes.get(j)).getQName(),
+                                                              targetLanguage);
+                            typedata.setTypeForAttributeName(((QName) attributes.get(j +
1)).getLocalPart(), 
+                                                             newSecondaryType);
                         }
                     
                     // Process the elements
@@ -944,14 +943,13 @@
                     if (elements != null)
                         for (int j = 0; j < elements.size(); j++)
                         {
-                            Type newType = null;
                             ElementInfo eleinfo = null;
                             
                             CElementDecl elem = (CElementDecl) elements.get(j);
                             
                             if (elem.getAnyElement())
                             {
-                                newType =  new Type(CUtils.anyTypeQname,
+                                newSecondaryType =  new Type(CUtils.anyTypeQname,
                                                     CUtils.anyTypeQname.getLocalPart(),
                                                     true,
                                                     targetLanguage);
@@ -968,15 +966,15 @@
                                     typeName = new QName(typeName.getNamespaceURI(), localpart);
                                     
                                     if (CUtils.isBasicType(typeName))
-                                        newType = createTypeInfo(typeName, targetLanguage);
+                                        newSecondaryType = createTypeInfo(typeName, targetLanguage);
                                     else
-                                        newType = createTypeInfo(elem.getType(), targetLanguage);
+                                        newSecondaryType = createTypeInfo(elem.getType(),
targetLanguage);
                                 }
                                 else
-                                    newType = createTypeInfo(typeName, targetLanguage);
+                                    newSecondaryType = createTypeInfo(typeName, targetLanguage);
                             }
                             
-                            eleinfo = new ElementInfo(elem.getName(), newType);
+                            eleinfo = new ElementInfo(elem.getName(), newSecondaryType);
                             
                             eleinfo.setMinOccurs(elem.getMinOccurs());
                             eleinfo.setMaxOccurs(elem.getMaxOccurs());
@@ -1104,7 +1102,7 @@
                             {
                                 if(WSDL2Ws.verbose)
                                     System.out.println( "EXPOSE1: Exposing ref-type "+referencedType.getQName());
-
+                                
                                 Type innerClassType = wsContext.getTypemap().getType(referencedType.getQName());
                                 innerClassType.setLanguageSpecificName(new QName(defType.getQName().getLocalPart()).toString());
                                 
@@ -1139,8 +1137,7 @@
             if(!(highLevelType instanceof BaseType))
             {
                 DefinedType type = (DefinedType)highLevelType;
-                if(type.getQName().getLocalPart().toString().startsWith(">")
-                        && !(type.getQName().getLocalPart().toString().lastIndexOf(">")>1))
+                if(type.getQName().getLocalPart().toString().startsWith(">"))
                 {
                     if(WSDL2Ws.verbose)
                         System.out.println( "EXPOSE2: Checking whether to expose anon type
"+type.getQName().getLocalPart());
@@ -1166,23 +1163,23 @@
                                       System.out.println( "EXPOSE2: Matches input parm, exposing
anon type "+parameterType.getName());
                          
                                   QName oldName = parameterType.getName();
-                                  QName newTypeName = 
-                                      new QName(parameterType.getName().getNamespaceURI(),

-                                                parameterType.getName().getLocalPart().substring(1));
-                                  
-                                  Type innerClassType =  wsContext.getTypemap().getType(parameterType.getName());
-                                  
-                                  // First thing to do is to expose the type so it gets created.
-                                  innerClassType.setLanguageSpecificName(newTypeName.getLocalPart().toString());
-                                  
-                                  // also have to set the QName becuase this is used in generating
the header info.
-                                  innerClassType.setName(newTypeName);
-                                  innerClassType.externalize(true);
-                                  
-                                  // The typemap we get back is a copy of the actual typemap
so we have to set the new value explicitly
-                                  // firstly remove the old version
-                                  wsContext.getTypemap().removeType(oldName);
-                                  wsContext.getTypemap().addType(newTypeName, innerClassType);
+                                  Type innerClassType =  wsContext.getTypemap().getType(oldName);
+                                  if (innerClassType != null && !innerClassType.isExternalized())
+                                  {
+                                      String newLocalPart = parameterType.getLanguageSpecificName();
+                                      QName newTypeName   =  new QName(parameterType.getName().getNamespaceURI(),
newLocalPart);
+                                      
+                                      // First thing to do is to expose the type so it gets
created.
+                                      innerClassType.setLanguageSpecificName(newLocalPart);
+                                      
+                                      // also have to set the QName since it used in generating
the header info.
+                                      innerClassType.setName(newTypeName);
+                                      innerClassType.externalize(true);
+                                      
+                                      // Update the typemap with new info
+                                      wsContext.getTypemap().removeType(oldName);
+                                      wsContext.getTypemap().addType(newTypeName, innerClassType);
+                                  }
                               }
                           }
                           
@@ -1199,20 +1196,23 @@
                                       System.out.println( "EXPOSE2: Matches output parm,
exposing anon type "+parameterType.getName());
                               
                                   QName oldName = parameterType.getName();
-                                  QName newTypeName = new QName(parameterType.getName().getNamespaceURI(),
parameterType.getName().getLocalPart().substring(1));
-                                  
-                                  Type innerClassType =  wsContext.getTypemap().getType(parameterType.getName());
-                                  
-                                  // First thing to do is to expose the type so it gets created.
-                                  innerClassType.setLanguageSpecificName(newTypeName.getLocalPart().toString());
-                                  
-                                  // also have to set the QName becuase this is used in generating
the header info.
-                                  innerClassType.setName(newTypeName);
-                                  innerClassType.externalize(true);
-                                  
-                                  // remove the old version and add new one
-                                  wsContext.getTypemap().removeType(oldName);
-                                  wsContext.getTypemap().addType(newTypeName, innerClassType);
+                                  Type innerClassType =  wsContext.getTypemap().getType(oldName);
+                                  if (innerClassType != null && !innerClassType.isExternalized())
+                                  {
+                                      String newLocalPart =  parameterType.getLanguageSpecificName();
+                                      QName newTypeName   =  new QName(parameterType.getName().getNamespaceURI(),
newLocalPart);
+                                      
+                                      // First thing to do is to expose the type so it gets
created.
+                                      innerClassType.setLanguageSpecificName(newLocalPart);
+                                      
+                                      // also have to set the QName since it used in generating
the header info.
+                                      innerClassType.setName(newTypeName);
+                                      innerClassType.externalize(true);
+                                      
+                                      // Update the typemap with new info
+                                      wsContext.getTypemap().removeType(oldName);
+                                      wsContext.getTypemap().addType(newTypeName, innerClassType);
+                                  }
                               }
                           }
                     }
@@ -1257,26 +1257,25 @@
                                System.out.println( "EXPOSE3: Checking whether to expose nested
type "+ nestedType.getQName());
                                 
                             if(name.startsWith(">") && name.lastIndexOf(">")>0)
-                            {
-                              // then this type needs to be exposed !
-                              QName oldName = nestedType.getQName();
-                                  
+                            {     
                               if(WSDL2Ws.verbose)
                                   System.out.println( "EXPOSE3: Exposing nestedType "+nestedType.getQName());
-                                  
-                              QName newTypeName =new QName(oldName.getNamespaceURI(), CUtils.sanitiseClassName(oldName.getLocalPart().toString()));
-                              
-                              Type innerClassType =  wsContext.getTypemap().getType(nestedType.getQName());
-                              if(innerClassType!=null)
+ 
+                              QName oldName = nestedType.getQName();                    
         
+                              Type innerClassType =  wsContext.getTypemap().getType(oldName);
+                              if (innerClassType != null && !innerClassType.isExternalized())
                               {
-                                  //     First thing to do is to expose the type so it gets
created.
-                                  innerClassType.setLanguageSpecificName(newTypeName.getLocalPart().toString());
-                              
-                                  //     also have to set the QName because this is used
in generating the header info.
+                                  String newLocalPart =  innerClassType.getLanguageSpecificName();
+                                  QName newTypeName   =  new QName(oldName.getNamespaceURI(),
newLocalPart);
+                                  
+                                  // First thing to do is to expose the type so it gets created.
+                                  innerClassType.setLanguageSpecificName(newLocalPart);
+                                  
+                                  // also have to set the QName since it used in generating
the header info.
                                   innerClassType.setName(newTypeName);
                                   innerClassType.externalize(true);
-
-                                  // remove the old version and add new one
+                                  
+                                  // Update the typemap with new info
                                   wsContext.getTypemap().removeType(oldName);
                                   wsContext.getTypemap().addType(newTypeName, innerClassType);
                               }

Modified: webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/AllParamWriter.java
URL: http://svn.apache.org/viewvc/webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/AllParamWriter.java?rev=424580&r1=424579&r2=424580&view=diff
==============================================================================
--- webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/AllParamWriter.java (original)
+++ webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/AllParamWriter.java Sat
Jul 22 07:19:55 2006
@@ -62,24 +62,35 @@
             try
             {
                 type = (Type) types.next();
-                if (type.isArray())
+
+                if (!type.isExternalized())
+                {
+                    if(WSDL2Ws.verbose)
+                        System.out.println("\nSkipping type " + type.getName());
+                }                
+                else if (type.isArray())
                 {
                     QName qname = type.getName();
+                    if (WSDL2Ws.verbose)
+                        System.out.println("\nArray processing for type: " + qname);
                     
                     String elementType = type.getElementType();
                     if (elementType != null)
                     {
+                        elementType = CUtils.sanitiseClassName(elementType);
+                        
                         if (WSDL2Ws.verbose)
-                            System.out.println("Array element type: " + elementType);
-                        elementType = elementType.replace('>', '_');
-                        QName elementQname = new QName(qname.getNamespaceURI(), elementType);
+                            System.out.println("    Array element type " 
+                                    + type.getElementType() + " normalized to " + elementType);
                         
+                        QName elementQname = new QName(qname.getNamespaceURI(), elementType);
                      
                         Type currentType = wscontext.getTypemap().getType(elementQname);
+                        
                         if (currentType != null)
                             if ( currentType.isSimpleType())
                             {
                                 if (WSDL2Ws.verbose)
-                                    System.out.println("Array writer not called - element
type is simple");
+                                    System.out.println("    Array writer not called - element
type is simple");
 
                                 continue;
                             }
@@ -96,24 +107,16 @@
                     if (!writer.isSimpleTypeArray())
                     {
                         if (WSDL2Ws.verbose)
-                            System.out.println("Array writer called ......");
+                            System.out.println("    Array writer called......");
                         
                         writer.writeSource();
                         (new ArrayParamWriter(wscontext, type)).writeSource();
                     }
                 }
-                else if (type.isAnonymous() && !type.isExternalized())
-                {
-                    if(WSDL2Ws.verbose)
-                    {                          
-                        System.out.println(
-                                "ignoring anonymous type " + type.getLanguageSpecificName()
+ "\n");
-                    }
-                }
                 else
                 {
                     if (WSDL2Ws.verbose)
-                        System.out.println("struct writer called ......");
+                        System.out.println("\nstruct writer called for......" + type.getName());
                     
                     (new BeanParamWriter(wscontext, type)).writeSource();
                     (new ParmHeaderFileWriter(wscontext, type)).writeSource();
@@ -122,7 +125,7 @@
             catch (Exception e)
             {
                 System.out.println(
-                        "Error occurred generating code for " + type.getLanguageSpecificName()
+                        "Error occurred generating code for " + type.getName()
                             + ". Other classes will continue to be generated.");
                 e.printStackTrace();
             }

Modified: webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/AllParamWriter.java
URL: http://svn.apache.org/viewvc/webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/AllParamWriter.java?rev=424580&r1=424579&r2=424580&view=diff
==============================================================================
--- webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/AllParamWriter.java
(original)
+++ webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/AllParamWriter.java
Sat Jul 22 07:19:55 2006
@@ -56,24 +56,34 @@
             try
             {
                 type = (Type) types.next();
-                if (type.isArray())
+                if (!type.isExternalized())
+                {
+                    if(WSDL2Ws.verbose)
+                        System.out.println("\nSkipping type " + type.getName());
+                }               
+                else if (type.isArray())
                 {
                     QName qname = type.getName();
+                    if (WSDL2Ws.verbose)
+                        System.out.println("\nArray processing for type: " + qname);
                     
                     String elementType = type.getElementType();
                     if (elementType != null)
                     {
+                        elementType = CUtils.sanitiseClassName(elementType);
+                        
                         if (WSDL2Ws.verbose)
-                            System.out.println("Array element type: " + elementType);
-                        elementType = elementType.replace('>', '_');
-                        QName elementQname = new QName(qname.getNamespaceURI(), elementType);
+                            System.out.println("    Array element type " 
+                                    + type.getElementType() + " normalized to " + elementType);
                         
+                        QName elementQname = new QName(qname.getNamespaceURI(), elementType);
                      
                         Type currentType = wscontext.getTypemap().getType(elementQname);
+                        
                         if (currentType != null)
                             if ( currentType.isSimpleType())
                             {
                                 if (WSDL2Ws.verbose)
-                                    System.out.println("Array writer not called - element
type is simple");
+                                    System.out.println("    Array writer not called - element
type is simple");
 
                                 continue;
                             }
@@ -90,21 +100,16 @@
                     if (!writer.isSimpleTypeArray())
                     {
                         if (WSDL2Ws.verbose)
-                            System.out.println("Array writer called for......" + type.getName());
+                            System.out.println("    Array writer called......");
                         
                         writer.writeSource();
                         (new ArrayParamWriter(wscontext, type)).writeSource();
                     }
                 }
-                else if (type.isAnonymous() && !type.isExternalized())
-                {
-                    if(WSDL2Ws.verbose)
-                        System.out.println("ignoring anonymous type " + type.getLanguageSpecificName()
+ "\n");
-                }
                 else
                 {
                     if (WSDL2Ws.verbose)
-                        System.out.println("struct writer called for......" + type.getName());
+                        System.out.println("\nstruct writer called for......" + type.getName());
 
                     (new BeanParamWriter(wscontext, type)).writeSource();
                     (new ParmHeaderFileWriter(wscontext, type)).writeSource();
@@ -113,7 +118,7 @@
             catch (Exception e)
             {
                 System.out.println(
-                    "Error occurred generating code for " + type.getLanguageSpecificName()
+                    "Error occurred generating code for " + type.getName()
                             + ". Other classes will continue to be generated.");        
       
                 e.printStackTrace();
             }

Modified: webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/info/Type.java
URL: http://svn.apache.org/viewvc/webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/info/Type.java?rev=424580&r1=424579&r2=424580&view=diff
==============================================================================
--- webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/info/Type.java (original)
+++ webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/info/Type.java Sat Jul
22 07:19:55 2006
@@ -135,25 +135,21 @@
                 this.languageSpecificName = TypeMap.getBasicTypeClass4qname(name);
         }
 
+        //if language specific name still not set, use localPart of QName
+        if (this.languageSpecificName == null)
+            this.languageSpecificName = this.name.getLocalPart();
+        
+        // Ensure name is valid and does not clash with language specific constructs
+        this.languageSpecificName = CUtils.sanitiseClassName(this.languageSpecificName);
+        
         // Indicate whether type is anonymous. Anonymous type start with '>' and are not
         // externalized by default.
-        if (this.name.getLocalPart().charAt(0) == '>')
+        if (TypeMap.isAnonymousType(this.name))
         {
             isAnonymous = true;
             externalize = false;
         }
-
-        //if it is not a simple type try name using usual QName -> language specific name
mapping
-        if (this.languageSpecificName == null)
-            this.languageSpecificName = qname2LSN();
-        else
-        {
-            //remove any funny Charactors
-            this.languageSpecificName = this.languageSpecificName.replaceAll("/", "_");
-            this.languageSpecificName = this.languageSpecificName.replaceAll(":", "_");
-            this.languageSpecificName = this.languageSpecificName.replaceAll(">", "_");
-        }     
-        
+                            
         this.attribOrder = new Vector();
 
         if (name.getNamespaceURI().equals(WrapperConstants.APACHE_XMLSOAP_NAMESPACE) &&

@@ -191,7 +187,8 @@
     }
 
     /**
-     * The Type take the attributes name to lowercase when add, If there is two names like
"Name" and "name"
+     * The Type take the attributes name to lowercase when add, 
+     * If there is two names like "Name" and "name"
      * they will convert to "name"  Is that acceptable ....  
      */
     public void setTypeForAttributeName(String attribName, Type type)
@@ -224,14 +221,13 @@
     }
 
     /**
-     * The Type take the attributes name to lowercase when add, If there is two names like
"Name" and "name"
+     * The Type take the attributes name to lowercase when add, 
+     * If there is two names like "Name" and "name"
      * they will convert to "name"  Is that acceptable ....  
      */
     public void setTypeNameForElementName(ElementInfo element)
     {
-        String attribName =
-            TypeMap.resolveWSDL2LanguageNameClashes(
-                element.getName().getLocalPart(),this.language);
+        String attribName = element.getName().getLocalPart();
 
         if (attribName.lastIndexOf(SymbolTable.ANON_TOKEN) > 1)
         {
@@ -239,8 +235,7 @@
                 attribName.substring(
                     attribName.lastIndexOf(SymbolTable.ANON_TOKEN) + 1,attribName.length());
         }
-        // Samisa: This second call to TypeMap.resoleveWSDL2LanguageNameClashes
-        // is made to make sure after replacinf ANON_TOKEN it is still not a keyword
+
         attribName = TypeMap.resolveWSDL2LanguageNameClashes(attribName, this.language);
 
         if (hasOrder)
@@ -272,33 +267,9 @@
 
     public void setLanguageSpecificName(String languageSpecificName)
     {
-        this.languageSpecificName = languageSpecificName;
+        this.languageSpecificName = CUtils.sanitiseClassName(languageSpecificName);
     }
-    /**
-     *  This mrthod define the standread conversion from qname to language spesific name
-     *  @return language specific name 
-     */
-    protected String qname2LSN()
-    {
-        String nsuri = this.name.getNamespaceURI();
-        if (nsuri == null)
-            return this.name.getLocalPart();
 
-        if (language.equalsIgnoreCase(WrapperConstants.LANGUAGE_CPP))
-        {
-            /* if it is CPP the namespace is neglected fr time been */
-            return this.name.getLocalPart();
-        }
-        else if (language.equalsIgnoreCase(WrapperConstants.LANGUAGE_C))
-            return this.name.getLocalPart();
-        else
-        {
-            return WrapperUtils.firstCharacterToLowercase(
-                WrapperUtils.nsURI2packageName(nsuri))
-                + "."
-                + WrapperUtils.capitalizeFirstCaractor(this.name.getLocalPart());
-        }
-    }
     /**
      * @return
      */



---------------------------------------------------------------------
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