axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nadira...@apache.org
Subject svn commit: r687212 - in /webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws: CUtils.java WSDL2Ws.java info/Type.java info/TypeMap.java info/WSDLInfo.java
Date Wed, 20 Aug 2008 01:09:12 GMT
Author: nadiramra
Date: Tue Aug 19 18:09:11 2008
New Revision: 687212

URL: http://svn.apache.org/viewvc?rev=687212&view=rev
Log:
Simplify, remove redundant/unused code.

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/info/Type.java
    webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/info/TypeMap.java
    webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/info/WSDLInfo.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=687212&r1=687211&r2=687212&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 Tue Aug 19
18:09:11 2008
@@ -28,9 +28,11 @@
 import org.apache.axis.wsdl.wsdl2ws.info.TypeMap;
 import org.apache.axis.wsdl.wsdl2ws.info.WebServiceContext;
 
+import java.util.HashSet;
 import java.util.Iterator;
 import java.util.Vector;
 import java.util.Hashtable;
+import java.util.Arrays;
 
 import javax.xml.namespace.QName;
 
@@ -91,7 +93,7 @@
     public static Hashtable c_basicTypeToEnumMapper = new Hashtable();
     
     // Used to find out whether a basic type is a pointer type.
-    public static Hashtable c_isPointerBasedType = new Hashtable();
+    public static HashSet c_pointerBasedTypes = null;
     
     // Language
     private static String  c_language = WrapperConstants.LANGUAGE_CPP;
@@ -104,9 +106,9 @@
     private static Vector c_uniqueNamesGenerated = new Vector();
     
     // list of c and cpp keywords
-    private static Hashtable c_cppkeywords = new Hashtable();
+    private static HashSet c_cppkeywords = null;
     
-    static{        
+    static{              
         c_basicTypeToQNameMapper.put("xsd__duration",                new QName(WrapperConstants.SCHEMA_NAMESPACE,
"duration"));
         c_basicTypeToQNameMapper.put("xsd__dateTime",                new QName(WrapperConstants.SCHEMA_NAMESPACE,
"dateTime"));
         c_basicTypeToQNameMapper.put("xsd__time",                    new QName(WrapperConstants.SCHEMA_NAMESPACE,
"time"));
@@ -242,6 +244,16 @@
         c_qname2classmapCpp.put(new QName(WrapperConstants.SCHEMA_NAMESPACE, "anyURI"), 
              "xsd__anyURI");
         c_qname2classmapCpp.put(new QName(WrapperConstants.SCHEMA_NAMESPACE, "NOTATION"),
               "xsd__NOTATION");
         
+        // TODO revisit attachment support.
+        c_qname2classmapCpp.put(new QName(WrapperConstants.APACHE_XMLSOAP_NAMESPACE, "Image"),
      "ISoapAttachment");
+        c_qname2classmapCpp.put(new QName(WrapperConstants.APACHE_XMLSOAP_NAMESPACE, "PlainText"),
 "ISoapAttachment");
+        c_qname2classmapCpp.put(new QName(WrapperConstants.APACHE_XMLSOAP_NAMESPACE, "Multipart"),
 "ISoapAttachment");
+        c_qname2classmapCpp.put(new QName(WrapperConstants.APACHE_XMLSOAP_NAMESPACE, "Source"),
    "ISoapAttachment");
+        c_qname2classmapCpp.put(new QName(WrapperConstants.APACHE_XMLSOAP_NAMESPACE, "octet-stream"),
  "ISoapAttachment");
+        c_qname2classmapCpp.put(new QName(WrapperConstants.APACHE_XMLSOAP_NAMESPACE, "DataHandler"),
   "ISoapAttachment");
+
+
+        
         c_qname2classmapC.put(new QName(WrapperConstants.SCHEMA_NAMESPACE, "duration"), 
          "xsdc__duration");
         c_qname2classmapC.put(new QName(WrapperConstants.SCHEMA_NAMESPACE, "dateTime"), 
          "xsdc__dateTime");
         c_qname2classmapC.put(new QName(WrapperConstants.SCHEMA_NAMESPACE, "time"),     
          "xsdc__time");
@@ -314,9 +326,9 @@
         c_qname2classmapCpp.put(new QName(WrapperConstants.SOAPENC_NAMESPACE, "unsignedLong"),
   "xsd__unsignedLong");
         c_qname2classmapCpp.put(new QName(WrapperConstants.SOAPENC_NAMESPACE, "unsignedShort"),
   "xsd__unsignedShort");
         c_qname2classmapCpp.put(new QName(WrapperConstants.SOAPENC_NAMESPACE, "QName"), 
          "xsd__QName");        
-//        qname2classmapCpp.put(new QName(WrapperConstants.SOAPENC_NAMESPACE, "NCName"),
           "xsd__NCName");        
-
-
+//        c_qname2classmapCpp.put(new QName(WrapperConstants.SOAPENC_NAMESPACE, "NCName"),
           "xsd__NCName");                
+        c_qname2classmapCpp.put(new QName(WrapperConstants.SOAPENC_NAMESPACE, "NMTOKEN"),
      "xsd__NMTOKEN");
+        
         /* TODO:
          *  Another strange issue from Axis 1.1 runtime when base64binary is in input/output
operations.
          */    
@@ -629,96 +641,23 @@
         c_initValueForBasicType.put("xsdc__QName",                    "NULL");
         c_initValueForBasicType.put("xsdc__NOTATION",                "NULL");
         
-        c_isPointerBasedType.put("xsd__duration", new Boolean(false));
-        c_isPointerBasedType.put("xsd__dateTime", new Boolean(false));
-        c_isPointerBasedType.put("xsd__time", new Boolean(false));
-        c_isPointerBasedType.put("xsd__date", new Boolean(false));
-        c_isPointerBasedType.put("xsd__gYearMonth", new Boolean(false));
-        c_isPointerBasedType.put("xsd__gYear", new Boolean(false));
-        c_isPointerBasedType.put("xsd__gMonthDay", new Boolean(false));
-        c_isPointerBasedType.put("xsd__gDay", new Boolean(false));
-        c_isPointerBasedType.put("xsd__gMonth", new Boolean(false));
-        c_isPointerBasedType.put("xsd__string", new Boolean(true));
-        c_isPointerBasedType.put("xsd__normalizedString", new Boolean(true));
-        c_isPointerBasedType.put("xsd__token", new Boolean(true));
-        c_isPointerBasedType.put("xsd__language", new Boolean(true));
-        c_isPointerBasedType.put("xsd__Name", new Boolean(true));
-        c_isPointerBasedType.put("xsd__NCName", new Boolean(true));
-        c_isPointerBasedType.put("xsd__ID", new Boolean(true));
-        c_isPointerBasedType.put("xsd__IDREF", new Boolean(true));
-        c_isPointerBasedType.put("xsd__IDREFS", new Boolean(true));
-        c_isPointerBasedType.put("xsd__ENTITY", new Boolean(true));
-        c_isPointerBasedType.put("xsd__ENTITIES", new Boolean(true));
-        c_isPointerBasedType.put("xsd__NMTOKEN", new Boolean(true));
-        c_isPointerBasedType.put("xsd__NMTOKENS", new Boolean(true));
-        c_isPointerBasedType.put("xsd__boolean", new Boolean(false));
-        c_isPointerBasedType.put("xsd__base64Binary", new Boolean(false));
-        c_isPointerBasedType.put("xsd__hexBinary", new Boolean(false));
-        c_isPointerBasedType.put("xsd__float", new Boolean(false));
-        c_isPointerBasedType.put("xsd__decimal", new Boolean(false));
-        c_isPointerBasedType.put("xsd__integer", new Boolean(false));
-        c_isPointerBasedType.put("xsd__nonPositiveInteger", new Boolean(false));
-        c_isPointerBasedType.put("xsd__negativeInteger", new Boolean(false));
-        c_isPointerBasedType.put("xsd__long", new Boolean(false));
-        c_isPointerBasedType.put("xsd__int", new Boolean(false));
-        c_isPointerBasedType.put("xsd__short", new Boolean(false));
-        c_isPointerBasedType.put("xsd__byte", new Boolean(false));
-        c_isPointerBasedType.put("xsd__nonNegativeInteger", new Boolean(false));
-        c_isPointerBasedType.put("xsd__unsignedLong", new Boolean(false));
-        c_isPointerBasedType.put("xsd__unsignedInt", new Boolean(false));
-        c_isPointerBasedType.put("xsd__unsignedShort", new Boolean(false));
-        c_isPointerBasedType.put("xsd__unsignedByte", new Boolean(false));
-        c_isPointerBasedType.put("xsd__positiveInteger", new Boolean(false));
-        c_isPointerBasedType.put("xsd__double", new Boolean(false));
-        c_isPointerBasedType.put("xsd__anyURI", new Boolean(true));
-        c_isPointerBasedType.put("xsd__QName", new Boolean(true));
-        c_isPointerBasedType.put("xsd__NOTATION", new Boolean(true));
-
-        c_isPointerBasedType.put("xsdc__duration", new Boolean(false));
-        c_isPointerBasedType.put("xsdc__dateTime", new Boolean(false));
-        c_isPointerBasedType.put("xsdc__time", new Boolean(false));
-        c_isPointerBasedType.put("xsdc__date", new Boolean(false));
-        c_isPointerBasedType.put("xsdc__gYearMonth", new Boolean(false));
-        c_isPointerBasedType.put("xsdc__gYear", new Boolean(false));
-        c_isPointerBasedType.put("xsdc__gMonthDay", new Boolean(false));
-        c_isPointerBasedType.put("xsdc__gDay", new Boolean(false));
-        c_isPointerBasedType.put("xsdc__gMonth", new Boolean(false));
-        c_isPointerBasedType.put("xsdc__string", new Boolean(true));
-        c_isPointerBasedType.put("xsdc__normalizedString", new Boolean(true));
-        c_isPointerBasedType.put("xsdc__token", new Boolean(true));
-        c_isPointerBasedType.put("xsdc__language", new Boolean(true));
-        c_isPointerBasedType.put("xsdc__Name", new Boolean(true));
-        c_isPointerBasedType.put("xsdc__NCName", new Boolean(true));
-        c_isPointerBasedType.put("xsdc__ID", new Boolean(true));
-        c_isPointerBasedType.put("xsdc__IDREF", new Boolean(true));
-        c_isPointerBasedType.put("xsdc__IDREF", new Boolean(true));
-        c_isPointerBasedType.put("xsdc__IDREFS", new Boolean(true));
-        c_isPointerBasedType.put("xsdc__ENTITY", new Boolean(true));
-        c_isPointerBasedType.put("xsdc__ENTITIES", new Boolean(true));
-        c_isPointerBasedType.put("xsdc__NMTOKEN", new Boolean(true));
-        c_isPointerBasedType.put("xsdc__NMTOKENS", new Boolean(true));
-        c_isPointerBasedType.put("xsdc__boolean", new Boolean(false));
-        c_isPointerBasedType.put("xsdc__base64Binary", new Boolean(false));
-        c_isPointerBasedType.put("xsdc__hexBinary", new Boolean(false));
-        c_isPointerBasedType.put("xsdc__float", new Boolean(false));
-        c_isPointerBasedType.put("xsdc__decimal", new Boolean(false));
-        c_isPointerBasedType.put("xsdc__integer", new Boolean(false));
-        c_isPointerBasedType.put("xsdc__nonPositiveInteger", new Boolean(false));
-        c_isPointerBasedType.put("xsdc__negativeInteger", new Boolean(false));
-        c_isPointerBasedType.put("xsdc__long", new Boolean(false));
-        c_isPointerBasedType.put("xsdc__int", new Boolean(false));
-        c_isPointerBasedType.put("xsdc__short", new Boolean(false));
-        c_isPointerBasedType.put("xsdc__byte", new Boolean(false));
-        c_isPointerBasedType.put("xsdc__nonNegativeInteger", new Boolean(false));
-        c_isPointerBasedType.put("xsdc__unsignedLong", new Boolean(false));
-        c_isPointerBasedType.put("xsdc__unsignedInt", new Boolean(false));
-        c_isPointerBasedType.put("xsdc__unsignedShort", new Boolean(false));
-        c_isPointerBasedType.put("xsdc__unsignedByte", new Boolean(false));
-        c_isPointerBasedType.put("xsdc__positiveInteger", new Boolean(false));
-        c_isPointerBasedType.put("xsdc__double", new Boolean(false));
-        c_isPointerBasedType.put("xsdc__anyURI", new Boolean(true));
-        c_isPointerBasedType.put("xsdc__QName", new Boolean(true));
-        c_isPointerBasedType.put("xsdc__NOTATION", new Boolean(true));
+        String[] pointerTypes = {
+        // C++ types
+        "xsd__string",         "xsd__normalizedString",             "xsd__token",
+        "xsd__language",       "xsd__Name",                         "xsd__NCName",
+        "xsd__ID",             "xsd__IDREF",                        "xsd__IDREFS",
+        "xsd__ENTITY",         "xsd__ENTITIES",                     "xsd__NMTOKEN",
+        "xsd__NMTOKENS",       "xsd__anyURI",                       "xsd__QName",
+        "xsd__NOTATION",    
+        // C types
+        "xsdc__string",        "xsdc__normalizedString",            "xsdc__token",
+        "xsdc__language",      "xsdc__Name",                        "xsdc__NCName",
+        "xsdc__ID",            "xsdc__IDREF",                       "xsdc__IDREFS",
+        "xsdc__ENTITY",        "xsdc__ENTITIES",                    "xsdc__NMTOKEN",    
  
+        "xsdc__NMTOKENS",      "xsdc__anyURI",                      "xsdc__QName",      
  
+        "xsdc__NOTATION"
+        };
+        c_pointerBasedTypes = new HashSet(Arrays.asList(pointerTypes));
     
         String[] words2 = {
                 "and", "and_eq", "asm", "auto",
@@ -743,8 +682,7 @@
                 "xor", "xor_eq",
                 "string"
          };
-        for (int i = 0; i < words2.length; i++)
-            c_cppkeywords.put(words2[i], words2[i]);
+        c_cppkeywords = new HashSet(Arrays.asList(words2));
     }
     
     
@@ -757,10 +695,7 @@
      */
     public static String resolveWSDL2LanguageNameClashes(String name)
     {
-       // C and C++ keywords are all in one hash table
-       Hashtable keywords = c_cppkeywords;
-
-       if (keywords.containsKey(name))
+       if (c_cppkeywords.contains(name))
            return "_" + name;
 
        return name;
@@ -789,7 +724,6 @@
         }
         else
             throw new WrapperFault("Unsupported language.");
-
     }
     
     /**
@@ -825,6 +759,28 @@
     }
     
     /**
+     * Returns boolean indicating whether QName represents a primitive basic type.
+     * Primitive basic types map to axis types such as xsd__xxxx or xsdc__xxxxx.
+     * 
+     * @param qname
+     * @return
+     */
+    public static boolean isPrimitiveBasicType(QName qname)
+    {
+        String t = (String)c_qnameToBasicTypeMapper.get(qname);
+        return ((t != null) 
+                && (t.startsWith("xsd__") 
+                        || t.startsWith("xsdc__")
+                        || (qname.getNamespaceURI().equals(WrapperConstants.APACHE_XMLSOAP_NAMESPACE)

+                                && (qname.getLocalPart().equals("DataHandler") 
+                                        || qname.getLocalPart().equals("Image") 
+                                        || qname.getLocalPart().equals("MimeMultipart") 
+                                        || qname.getLocalPart().equals("Source") 
+                                        || qname.getLocalPart().equals("octet-stream") 
+                                        || qname.getLocalPart().equals("PlainText")))));
+    }
+    
+    /**
      * Method to determine if name passed in is that of a simple type. 
      * 
      * @param name
@@ -836,7 +792,7 @@
     } 
     
     /**
-     * Method to determine if basic type is a pointer type. 
+     * Method to determine if simple type is a pointer type. 
      * 
      * @param name
      * @return
@@ -844,17 +800,13 @@
     public static boolean isPointerType(String name)
     {
         if (name != null)
-        {
-            Object o = c_isPointerBasedType.get(name);
-            if( o != null)
-                return ((Boolean)o).booleanValue();
-        }
+            return c_pointerBasedTypes.contains(name);
         
         return false;
     }
     
     /**
-     * Method to determine if basic type is a pointer type. 
+     * Method to determine if simple type is a pointer type. 
      * 
      * @param name
      * @return
@@ -864,6 +816,13 @@
         return isPointerType((String)c_qnameToBasicTypeMapper.get(name));
     }    
     
+  
+    /**
+     * Method to determine if QName represents an AnyType.
+     * 
+     * @param name
+     * @return
+     */
     public static boolean isAnyType(QName name)
     {
             return name.equals(anyTypeQname);
@@ -877,11 +836,25 @@
             return c_schemaDefinedSimpleTypesMap.containsKey(name);
     } 
 
+    /**
+     * Method to determine if QName represents a type that is a schema-defined 
+     * simple type.
+     * 
+     * @param name
+     * @return
+     */
     public static boolean isDefinedSimpleType(QName name)
     {
         return c_schemaDefinedSimpleTypesMap.containsKey(name);    
     }
         
+    /**
+     * Returns deserializer method name for element or attribute to be deserialized.
+     * 
+     * @param typeName
+     * @param isAttrib
+     * @return
+     */
     public static String getDeserializerMethodNameForType(String typeName, boolean isAttrib)
     {
         String methodname = (String)c_basicTypeToMethodSuffixMapper.get(typeName);
@@ -916,6 +889,20 @@
     }
 
     /**
+     * Returns primitive basic type that matches QName.
+     * 
+     * @param qname
+     * @return
+     */
+    public static String getPrimitiveBasicTypeForQName(QName qname) 
+    {
+        if (isPrimitiveBasicType(qname))
+            return (String)c_qnameToBasicTypeMapper.get(qname);
+        
+        return null;
+    }
+    
+    /**
      * Get initialization value string for a basic type. 
      * 
      * @param typeName
@@ -1156,7 +1143,7 @@
     }
 
     /**
-     *  get classpart of the class and if name happen to be a Simple type return 
+     *  get class part of the class and if name happen to be a Simple type return 
      *  the Wrapper Class name(service.0 wrapper class name)
      *  
      */
@@ -1175,6 +1162,7 @@
 
     /**
      * Capitalize the first Character of a given String. 
+     * 
      * @param value String 
      * @return changed String 
      */
@@ -1185,6 +1173,12 @@
         return new String(chars);
     }
 
+    /**
+     * Lowercase the first character in a string.
+     * 
+     * @param value
+     * @return
+     */
     public static String firstCharacterToLowercase(String value)
     {
         char[] chars = value.toCharArray();
@@ -1210,7 +1204,7 @@
             
             return name;
         }
-        else if (!TypeMap.isSimpleType(param.getSchemaName()))
+        else if (!CUtils.isPrimitiveBasicType(param.getSchemaName()))
         { 
             //array or complex types
             if (null != type && type.isArray())
@@ -1248,6 +1242,13 @@
             return param.getLangName();
     }
 
+    /**
+     * Returns the Type of elements in the array.
+     * 
+     * @param type
+     * @return
+     * @throws WrapperFault
+     */
     public static Type getArrayType(Type type) throws WrapperFault
     {
         if (!type.isArray())

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=687212&r1=687211&r2=687212&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 Tue Aug 19
18:09:11 2008
@@ -828,7 +828,7 @@
         if (!type.isReferenced())
             return null;
         
-        if (c_verbose && !TypeMap.isSimpleType(type.getQName()))
+        if (c_verbose && !CUtils.isPrimitiveBasicType(type.getQName()))
             System.out.println("Attempting to create type: " + type.getQName());
         
         if (type instanceof CollectionElement)
@@ -866,7 +866,7 @@
             typedata = c_typeMap.getType(newqn);
             if (typedata != null)
             {
-                if (c_verbose && !TypeMap.isSimpleType(type.getQName()))
+                if (c_verbose && !CUtils.isPrimitiveBasicType(type.getQName()))
                     System.out.println("Type not created, already exists: " + type.getQName());
                 
                 return typedata;
@@ -885,7 +885,7 @@
             typedata = c_typeMap.getType(type.getQName());
             if (typedata != null)
             {
-                if (c_verbose && !TypeMap.isSimpleType(type.getQName()))
+                if (c_verbose && !CUtils.isPrimitiveBasicType(type.getQName()))
                     System.out.println("Type not created, already exists: " + type.getQName());
                 
                 return typedata;

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=687212&r1=687211&r2=687212&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 Tue Aug
19 18:09:11 2008
@@ -432,7 +432,7 @@
      */
     public void addRelatedType(Type type)
     {
-        if (type != null && !TypeMap.isSimpleType(type.getName()))
+        if (type != null && !CUtils.isPrimitiveBasicType(type.getName()))
             this.vRelatedTypes.add(type);
     }    
     // vvv FJP - 17667

Modified: webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/info/TypeMap.java
URL: http://svn.apache.org/viewvc/webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/info/TypeMap.java?rev=687212&r1=687211&r2=687212&view=diff
==============================================================================
--- webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/info/TypeMap.java (original)
+++ webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/info/TypeMap.java Tue Aug
19 18:09:11 2008
@@ -15,17 +15,6 @@
  *   limitations under the License.
  */
 
-/**
- * Type map has information about all the custom types in the webservice and it has the
- * Information about in-built datatypes as well. The Type map class does not know about the
- * namespace(c++) etc information. The typemap registers the types against the
- * xmlqname in WSDL. It is the underline applications responsibility to make sense of the
- * namespaceuri and localname in the qname
- *
- * e.g.  C++  {urn:ns}classname -> ns:classname
- * @author hemapani  
- */
-
 package org.apache.axis.wsdl.wsdl2ws.info;
 
 import java.util.Collection;
@@ -34,144 +23,83 @@
 
 import javax.xml.namespace.QName;
 
-import org.apache.axis.wsdl.wsdl2ws.WrapperConstants;
+import org.apache.axis.wsdl.wsdl2ws.CUtils;
 
+/**
+ * Type map has information about all the custom types in the WSDL.
+ * The type map registers the types against the XML QName in WSDL. 
+ *
+ * e.g.  C++  {urn:ns}classname -> ns:classname
+ * 
+ * @author hemapani  
+ */
 public class TypeMap
 {
     public static final String ANON_TOKEN_STRING = ">";
     public static final char   ANON_TOKEN_CHAR   = '>';
     
-    /* this map maps QName -> classname */
-    private static Hashtable basicTypeQname2classmap = new Hashtable();
-    
-    /* this map stores Types keyed by the parameter name */
-    private Hashtable typeInfo = new Hashtable();;
-
-    static {
-        // xml -> c type mapping 
-        basicTypeQname2classmap.put(new QName(WrapperConstants.SCHEMA_NAMESPACE, "duration"),
  		"xsd__duration");
-        basicTypeQname2classmap.put(new QName(WrapperConstants.SCHEMA_NAMESPACE, "dateTime"),
  		"xsd__dateTime");
-        basicTypeQname2classmap.put(new QName(WrapperConstants.SCHEMA_NAMESPACE, "time"),
      		"xsd__time");
-        basicTypeQname2classmap.put(new QName(WrapperConstants.SCHEMA_NAMESPACE, "date"),
      		"xsd__date");
-        basicTypeQname2classmap.put(new QName(WrapperConstants.SCHEMA_NAMESPACE, "gYearMonth"),
      	"xsd__gYearMonth");
-        basicTypeQname2classmap.put(new QName(WrapperConstants.SCHEMA_NAMESPACE, "gYear"),
      		"xsd__gYear");
-        basicTypeQname2classmap.put(new QName(WrapperConstants.SCHEMA_NAMESPACE, "gMonthDay"),
      	"xsd__gMonthDay");
-        basicTypeQname2classmap.put(new QName(WrapperConstants.SCHEMA_NAMESPACE, "gDay"),
      		"xsd__gDay");
-        basicTypeQname2classmap.put(new QName(WrapperConstants.SCHEMA_NAMESPACE, "gMonth"),
      		"xsd__gMonth");
-        basicTypeQname2classmap.put(new QName(WrapperConstants.SCHEMA_NAMESPACE, "string"),
			"xsd__string");
-        basicTypeQname2classmap.put(new QName(WrapperConstants.SCHEMA_NAMESPACE, "normalizedString"),
"xsd__normalizedString");
-        basicTypeQname2classmap.put(new QName(WrapperConstants.SCHEMA_NAMESPACE, "token"),
			"xsd__token");
-        basicTypeQname2classmap.put(new QName(WrapperConstants.SCHEMA_NAMESPACE, "language"),
		"xsd__language");
-        basicTypeQname2classmap.put(new QName(WrapperConstants.SCHEMA_NAMESPACE, "Name"),
			"xsd__Name");
-        basicTypeQname2classmap.put(new QName(WrapperConstants.SCHEMA_NAMESPACE, "NCName"),
			"xsd__NCName");
-        basicTypeQname2classmap.put(new QName(WrapperConstants.SCHEMA_NAMESPACE, "ID"),	
			"xsd__ID");
-        basicTypeQname2classmap.put(new QName(WrapperConstants.SCHEMA_NAMESPACE, "IDREF"),
			"xsd__IDREF");
-        basicTypeQname2classmap.put(new QName(WrapperConstants.SCHEMA_NAMESPACE, "IDREFS"),
			"xsd__IDREFS");
-        basicTypeQname2classmap.put(new QName(WrapperConstants.SCHEMA_NAMESPACE, "ENTITY"),
			"xsd__ENTITY");
-        basicTypeQname2classmap.put(new QName(WrapperConstants.SCHEMA_NAMESPACE, "ENTITIES"),
		"xsd__ENTITIES");
-        basicTypeQname2classmap.put(new QName(WrapperConstants.SCHEMA_NAMESPACE, "NMTOKEN"),
		"xsd__NMTOKEN");
-        basicTypeQname2classmap.put(new QName(WrapperConstants.SCHEMA_NAMESPACE, "NMTOKENS"),
		"xsd__NMTOKENS");
-        basicTypeQname2classmap.put(new QName(WrapperConstants.SCHEMA_NAMESPACE, "boolean"),
		"xsd__boolean");
-        basicTypeQname2classmap.put(new QName(WrapperConstants.SCHEMA_NAMESPACE, "base64Binary"),
	"xsd__base64Binary");
-        basicTypeQname2classmap.put(new QName(WrapperConstants.SCHEMA_NAMESPACE, "hexBinary"),
		"xsd__hexBinary");
-        basicTypeQname2classmap.put(new QName(WrapperConstants.SCHEMA_NAMESPACE, "float"),
			"xsd__float");
-        basicTypeQname2classmap.put(new QName(WrapperConstants.SCHEMA_NAMESPACE, "decimal"),
		"xsd__decimal");
-        basicTypeQname2classmap.put(new QName(WrapperConstants.SCHEMA_NAMESPACE, "integer"),
		"xsd__integer");
-        basicTypeQname2classmap.put(new QName(WrapperConstants.SCHEMA_NAMESPACE, "nonPositiveInteger"),
"xsd__nonPositiveInteger");
-        basicTypeQname2classmap.put(new QName(WrapperConstants.SCHEMA_NAMESPACE, "negativeInteger"),
"xsd__negativeInteger");
-        basicTypeQname2classmap.put(new QName(WrapperConstants.SCHEMA_NAMESPACE, "long"),
			"xsd__long");
-        basicTypeQname2classmap.put(new QName(WrapperConstants.SCHEMA_NAMESPACE, "int"),
			"xsd__int");
-        basicTypeQname2classmap.put(new QName(WrapperConstants.SCHEMA_NAMESPACE, "short"),
			"xsd__short");
-        basicTypeQname2classmap.put(new QName(WrapperConstants.SCHEMA_NAMESPACE, "byte"),
			"xsd__byte");
-        basicTypeQname2classmap.put(new QName(WrapperConstants.SCHEMA_NAMESPACE, "nonNegativeInteger"),
"xsd__nonNegativeInteger");
-        basicTypeQname2classmap.put(new QName(WrapperConstants.SCHEMA_NAMESPACE, "unsignedLong"),
	"xsd__unsignedLong");
-        basicTypeQname2classmap.put(new QName(WrapperConstants.SCHEMA_NAMESPACE, "unsignedInt"),
	"xsd__unsignedInt");
-        basicTypeQname2classmap.put(new QName(WrapperConstants.SCHEMA_NAMESPACE, "unsignedShort"),
	"xsd__unsignedShort");
-        basicTypeQname2classmap.put(new QName(WrapperConstants.SCHEMA_NAMESPACE, "unsignedByte"),
	"xsd__unsignedByte");
-        basicTypeQname2classmap.put(new QName(WrapperConstants.SCHEMA_NAMESPACE, "positiveInteger"),
"xsd__positiveInteger");
-        basicTypeQname2classmap.put(new QName(WrapperConstants.SCHEMA_NAMESPACE, "double"),
			"xsd__double");
-        basicTypeQname2classmap.put(new QName(WrapperConstants.SCHEMA_NAMESPACE, "anyURI"),
			"xsd__anyURI");
-        basicTypeQname2classmap.put(new QName(WrapperConstants.SCHEMA_NAMESPACE, "QName"),
			"xsd__QName");
-        basicTypeQname2classmap.put(new QName(WrapperConstants.SCHEMA_NAMESPACE, "NOTATION"),
		"xsd__NOTATION");
-        basicTypeQname2classmap.put(new QName(WrapperConstants.APACHE_XMLSOAP_NAMESPACE,
"Image"),		"ISoapAttachment");
-        basicTypeQname2classmap.put(new QName(WrapperConstants.APACHE_XMLSOAP_NAMESPACE,
"PlainText"),	"ISoapAttachment");
-        basicTypeQname2classmap.put(new QName(WrapperConstants.APACHE_XMLSOAP_NAMESPACE,
"Multipart"),	"ISoapAttachment");
-        basicTypeQname2classmap.put(new QName(WrapperConstants.APACHE_XMLSOAP_NAMESPACE,
"Source"),		"ISoapAttachment");
-        basicTypeQname2classmap.put(new QName(WrapperConstants.APACHE_XMLSOAP_NAMESPACE,
"octet-stream"),	"ISoapAttachment");
-        basicTypeQname2classmap.put(new QName(WrapperConstants.APACHE_XMLSOAP_NAMESPACE,
"DataHandler"),	"ISoapAttachment");
-
-        /* TODO:
-         *   Should be removed when the following issue will be fixed :
-         * 	-> http://marc.theaimsgroup.com/?t=107907748000002&r=1&w=2 
-         */
-        basicTypeQname2classmap.put(new QName(WrapperConstants.SOAPENC_NAMESPACE, "integer"),
      "xsd__integer");
-        basicTypeQname2classmap.put(new QName(WrapperConstants.SOAPENC_NAMESPACE, "string"),
       "xsd__string");
-        basicTypeQname2classmap.put(new QName(WrapperConstants.SOAPENC_NAMESPACE, "decimal"),
      "xsd__decimal");
-        basicTypeQname2classmap.put(new QName(WrapperConstants.SOAPENC_NAMESPACE, "QName"),
        "xsd__QName");
-/*      basicTypeQname2classmap.put(new QName(WrapperConstants.SOAPENC_NAMESPACE, "NCName"),
       "xsd__NCName");  */
-        basicTypeQname2classmap.put(new QName(WrapperConstants.SOAPENC_NAMESPACE, "dateTime"),
     "xsd__dateTime");
-        basicTypeQname2classmap.put(new QName(WrapperConstants.SOAPENC_NAMESPACE, "date"),
         "xsd__date");
-        basicTypeQname2classmap.put(new QName(WrapperConstants.SOAPENC_NAMESPACE, "time"),
         "xsd__time");
-        basicTypeQname2classmap.put(new QName(WrapperConstants.SOAPENC_NAMESPACE, "duration"),
     "xsd__duration");
-        basicTypeQname2classmap.put(new QName(WrapperConstants.SOAPENC_NAMESPACE, "base64Binary"),
 "xsd__base64Binary");
-        basicTypeQname2classmap.put(new QName(WrapperConstants.SOAPENC_NAMESPACE, "hexBinary"),
    "xsd__hexBinary");
-        basicTypeQname2classmap.put(new QName(WrapperConstants.SOAPENC_NAMESPACE, "int"),
          "xsd__int");
-        basicTypeQname2classmap.put(new QName(WrapperConstants.SOAPENC_NAMESPACE, "byte"),
         "xsd__byte");
-        basicTypeQname2classmap.put(new QName(WrapperConstants.SOAPENC_NAMESPACE, "float"),
        "xsd__float");
-        basicTypeQname2classmap.put(new QName(WrapperConstants.SOAPENC_NAMESPACE, "long"),
         "xsd__long");
-        basicTypeQname2classmap.put(new QName(WrapperConstants.SOAPENC_NAMESPACE, "double"),
       "xsd__double");
-        basicTypeQname2classmap.put(new QName(WrapperConstants.SOAPENC_NAMESPACE, "boolean"),
      "xsd__boolean");
-        basicTypeQname2classmap.put(new QName(WrapperConstants.SOAPENC_NAMESPACE, "short"),
        "xsd__short");
-        basicTypeQname2classmap.put(new QName(WrapperConstants.SOAPENC_NAMESPACE, "unsignedByte"),
 "xsd__unsignedByte");
-        basicTypeQname2classmap.put(new QName(WrapperConstants.SOAPENC_NAMESPACE, "unsignedInt"),
  "xsd__unsignedInt");
-        basicTypeQname2classmap.put(new QName(WrapperConstants.SOAPENC_NAMESPACE, "unsignedLong"),
 "xsd__unsignedLong");
-        basicTypeQname2classmap.put(new QName(WrapperConstants.SOAPENC_NAMESPACE, "unsignedShort"),
"xsd__unsignedShort");
-        basicTypeQname2classmap.put(new QName(WrapperConstants.SOAPENC_NAMESPACE, "anyURI"),
       "xsd__anyURI");
-        basicTypeQname2classmap.put(new QName(WrapperConstants.SOAPENC_NAMESPACE, "NMTOKEN"),
      "xsd__NMTOKEN");
-        /* TODO:
-         *  Another strange issue from Axis 1.1 runtime when base64binary is in input/output
operations.
-         */
-        basicTypeQname2classmap.put(new QName(WrapperConstants.SOAPENC_NAMESPACE, "base64"),
"xsd__base64Binary");
-    }
+    // this map stores custom type generated from WSDL
+    private Hashtable typeInfo = new Hashtable();
     
+    /**
+     * Constructor
+     */
     public TypeMap()
     {
     }
 
-    public static String getBasicTypeClass4qname(QName qname)
-    {
-        Object val = basicTypeQname2classmap.get(qname);
-        return (String) val;
-    }
-
-    public static boolean isSimpleType(QName type)
-    {
-        return basicTypeQname2classmap.containsKey(type);
-    }
-
+    /**
+     * Returns customer type from map.  Note that primitive basic types
+     * are generated on-the-fly.
+     * 
+     * @param name
+     * @return
+     */
     public Type getType(QName name)
     {
-        if (isSimpleType(name))
+        if (CUtils.isPrimitiveBasicType(name))
             return new Type(name, null);
 
         return (Type) this.typeInfo.get(name);
     }
 
-    public void addType(QName wsdlname, Type type)
-    {
-        this.typeInfo.put(wsdlname, type);
-    }
-
+    /**
+     * Add a type to the map. 
+     * 
+     * @param qname
+     * @param type
+     */
+    public void addType(QName qname, Type type)
+    {
+        this.typeInfo.put(qname, type);
+    }
+
+    /**
+     * Remove type from the map.
+     * 
+     * @param wsdlname
+     */
     public void removeType(QName wsdlname)
     {
         this.typeInfo.remove(wsdlname);
     }
-    /* get all the custom types in the typeMap */
+
+    /**
+     * Get all the types in the map.
+     * 
+     * @return
+     */
     public Collection getTypes()
     {
         return this.typeInfo.values();
     }
     
+    /**
+     * Determines if a type exists in the map.
+     * 
+     * @param name
+     * @return
+     */
     public boolean doesTypeExist(String name)
     {   
         Type atype;
@@ -191,6 +119,12 @@
         return false;
     }
     
+    /**
+     * Checks whether the string represents an anonymous type name.
+     * 
+     * @param type
+     * @return
+     */
     public static boolean isAnonymousType(String type)
     {
         if (type != null)
@@ -199,6 +133,12 @@
         return false;
     }
 
+    /**
+     * Checks to see if the QName represents an anonymous type.
+     * 
+     * @param type
+     * @return
+     */
     public static boolean isAnonymousType(QName type)
     {
         if (type != null)

Modified: webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/info/WSDLInfo.java
URL: http://svn.apache.org/viewvc/webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/info/WSDLInfo.java?rev=687212&r1=687211&r2=687212&view=diff
==============================================================================
--- webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/info/WSDLInfo.java (original)
+++ webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/info/WSDLInfo.java Tue
Aug 19 18:09:11 2008
@@ -381,7 +381,6 @@
                 String typedataLocalpartSanitized = null;
                 String baseTypeLocalpartSanitized = null;
                 
-                Boolean isPointer   = null;
                 String methodSuffix = null;
                 
                 String primitiveXSDType          = null;
@@ -400,7 +399,7 @@
                 String class4qname          = null;
                 String class4qnameSanitized = null;
                 
-                String javaName = TypeMap.getBasicTypeClass4qname(baseEType.getQName());
+                String javaName = CUtils.getPrimitiveBasicTypeForQName(baseEType.getQName());
                 boolean isBaseTypePrimitive = javaName != null;
                 
                 QName primitiveBaseTypeQName = null;
@@ -438,15 +437,17 @@
                 // simple type. If anonymous type, we need to update mapping tables twice:
once
                 // with the anonymous names, and once with the sanitized names. 
                 
-                isPointer = new Boolean(CUtils.isPointerType(primitiveBaseTypeQName));
+                boolean isPointerType = CUtils.isPointerType(primitiveBaseTypeQName);
                 primitiveXSDType = CUtils.getXSDTypeForBasicType(classForPrimitiveType);
 
                 if (!isBaseTypePrimitive)
                 {
                     typedata.setRestrictionBaseType(baseTypeLocalpart);
-                    CUtils.c_isPointerBasedType.put(baseTypeLocalpart, isPointer);
+                    if (isPointerType)
+                        CUtils.c_pointerBasedTypes.add(baseTypeLocalpart);
                 }
-                CUtils.c_isPointerBasedType.put(typedataLocalpart, isPointer);          
         
+                if (isPointerType)
+                    CUtils.c_pointerBasedTypes.add(typedataLocalpart);                  
 
 
                 methodSuffix = (String)CUtils.c_basicTypeToMethodSuffixMapper.get(classForPrimitiveType);
                 CUtils.c_qnameToBasicTypeMapper.put(typedataQName, class4qname);
@@ -466,7 +467,8 @@
 
                 if (typedataQNameSanitized != null)
                 {
-                    CUtils.c_isPointerBasedType.put(typedataLocalpartSanitized, isPointer);

+                    if (isPointerType)
+                        CUtils.c_pointerBasedTypes.add(typedataLocalpartSanitized); 
                     CUtils.c_qnameToBasicTypeMapper.put(typedataQNameSanitized, class4qnameSanitized);
                     CUtils.c_basicTypeToEnumMapper.put(typedataLocalpartSanitized, primitiveXSDType);
                     if (initValueForType != null)
@@ -476,7 +478,8 @@
                 
                 if (baseTypeLocalpartSanitized != null)
                 {
-                    CUtils.c_isPointerBasedType.put(baseTypeLocalpartSanitized, isPointer);
+                    if (isPointerType)
+                        CUtils.c_pointerBasedTypes.add(baseTypeLocalpartSanitized);
                     CUtils.c_basicTypeToEnumMapper.put(baseTypeLocalpartSanitized, primitiveXSDType);
                     if (initValueForType != null)
                         CUtils.c_initValueForBasicType.put(baseTypeLocalpartSanitized, initValueForType);



Mime
View raw message