axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bu...@apache.org
Subject cvs commit: xml-axis/java/test/wsdl/names JavaNames.wsdl
Date Thu, 20 Dec 2001 14:56:47 GMT
butek       01/12/20 06:56:47

  Modified:    java/src/org/apache/axis/providers/java RPCProvider.java
               java/src/org/apache/axis/utils JavaUtils.java
               java/src/org/apache/axis/wsdl/toJava Utils.java
               java/test/wsdl/names JavaNames.wsdl
  Log:
  Fixed a bug found by Andy Carlson (andyslistbox@hotmail.com).  When we put in
  the fixes to handle operation names that were Java keywords, we didn't go far
  enough.  We made sure that, when a operation name like "new" became the Java
  method "_new" we could still map back to "new".  But there are other manglings that
  we do for Java names (like changing "Capitalized" to "capitalized").  The method
  xmlNameToJava must be called in RPCProvider.
  
  I made this fix and I added this case to the JavaNames.wsdl test.
  
  Revision  Changes    Path
  1.31      +4 -3      xml-axis/java/src/org/apache/axis/providers/java/RPCProvider.java
  
  Index: RPCProvider.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/providers/java/RPCProvider.java,v
  retrieving revision 1.30
  retrieving revision 1.31
  diff -u -r1.30 -r1.31
  --- RPCProvider.java	2001/12/07 16:33:03	1.30
  +++ RPCProvider.java	2001/12/20 14:56:47	1.31
  @@ -171,9 +171,10 @@
   			int			numberOfBodyArgs = args.size();
               Method      method = getMethod(jc, mName, args);
   
  -            // If the method wasn't found, maybe the name is a Java keyword and needs mapping...
  -            if (method == null && JavaUtils.isJavaKeyword(mName)) {
  -                mName = JavaUtils.makeNonJavaKeyword(mName);
  +            // If the method wasn't found, maybe it needs some Java mangling (ie., it's
a Java
  +            // keyword or it's capitalized and the java mapping requires lowercase).
  +            if (method == null) {
  +                mName = JavaUtils.xmlNameToJava(mName);
                   method = getMethod(jc, mName, args);
               }
   
  
  
  
  1.19      +47 -0     xml-axis/java/src/org/apache/axis/utils/JavaUtils.java
  
  Index: JavaUtils.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/utils/JavaUtils.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- JavaUtils.java	2001/12/19 21:08:21	1.18
  +++ JavaUtils.java	2001/12/20 14:56:47	1.19
  @@ -229,6 +229,53 @@
           return  keywordPrefix + keyword;
        }
   
  +    /**
  +     * Map an XML name to a valid Java identifier
  +     */
  +    public static String xmlNameToJava(String name)
  +    {
  +        char[] nameArray = name.toCharArray();
  +        int len = name.length();
  +        StringBuffer result = new StringBuffer(len);
  +        
  +        // First character, lower case
  +        int i = 0;
  +        while (i < name.length() 
  +                && !Character.isLetter(nameArray[i])) {
  +            i++;
  +        }
  +        if (i < name.length()) {
  +            result.append(Character.toLowerCase(nameArray[i]));
  +        }
  +        else {
  +            result.append("_" + nameArray[0]);
  +        }
  +        
  +        // The rest of the string
  +        boolean wordStart = false;
  +        for(int j = i + 1; j < len; ++j) {
  +            char c = nameArray[j];
  +
  +            // if this is a bad char, skip it a remember to capitolize next
  +            // good character we encounter
  +            if( !Character.isLetterOrDigit(c)) {
  +                wordStart = true;
  +                continue;
  +            }
  +            result.append( wordStart ? Character.toUpperCase(c) : c );
  +            wordStart = false;
  +        }
  +        
  +        // covert back to a String
  +        String newName = result.toString();
  +        
  +        // check for Java keywords
  +        if (isJavaKeyword(newName))
  +            newName = makeNonJavaKeyword(newName);
  +        
  +        return newName;
  +    } // xmlNameToJava
  +
       // Message resource bundle.
       private static ResourceBundle messages = null;
   
  
  
  
  1.7       +5 -35     xml-axis/java/src/org/apache/axis/wsdl/toJava/Utils.java
  
  Index: Utils.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/Utils.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- Utils.java	2001/12/19 21:08:22	1.6
  +++ Utils.java	2001/12/20 14:56:47	1.7
  @@ -436,41 +436,11 @@
        */
       public static String xmlNameToJava(String name)
       {
  -        char[] nameArray = name.toCharArray();
  -        int len = name.length();
  -        StringBuffer result = new StringBuffer(len);
  -        
  -        // First character, lower case
  -        int i = 0;
  -        while (i < name.length() 
  -                && !Character.isLetter(nameArray[i])) {
  -            i++;
  -        }
  -        result.append( Character.toLowerCase(nameArray[i]) );
  -        
  -        // The rest of the string
  -        boolean wordStart = false;
  -        for(int j = i + 1; j < len; ++j) {
  -            char c = nameArray[j];
  -
  -            // if this is a bad char, skip it a remember to capitolize next
  -            // good character we encounter
  -            if( !Character.isLetterOrDigit(c)) {
  -                wordStart = true;
  -                continue;
  -            }
  -            result.append( wordStart ? Character.toUpperCase(c) : c );
  -            wordStart = false;
  -        }
  -        
  -        // covert back to a String
  -        String newName = result.toString();
  -        
  -        // check for Java keywords
  -        if (JavaUtils.isJavaKeyword(newName))
  -            newName = JavaUtils.makeNonJavaKeyword(newName);
  -        
  -        return newName;
  +        // NOTE:  This method should really go away and all callers should call
  +        // JavaUtils.xmlNameToJava directly.  But there are a lot of them and I wanted
  +        // to keep the changes to a minimum.  Besides, these are static methods so the
should
  +        // be inlined.
  +        return JavaUtils.xmlNameToJava(name);
       }
   
       /**
  
  
  
  1.3       +16 -0     xml-axis/java/test/wsdl/names/JavaNames.wsdl
  
  Index: JavaNames.wsdl
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/wsdl/names/JavaNames.wsdl,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- JavaNames.wsdl	2001/12/07 16:33:04	1.2
  +++ JavaNames.wsdl	2001/12/20 14:56:47	1.3
  @@ -58,6 +58,9 @@
         <input message="tns:GetAddressFromNameRequest"/>
         <output message="tns:GetAddressFromNameResponse"/>
       </operation>
  +    <operation name="Capitalized">
  +      <input message="tns:AddEntryRequest"/>
  +    </operation>
     </portType>
   
     <!-- binding declns -->
  @@ -78,6 +81,19 @@
         </output>
       </operation>
       <operation name="public">
  +      <soap:operation soapAction=""/>
  +      <input>
  +        <soap:body use="encoded"
  +                   namespace="http://names.wsdl.test/javanames"
  +                   encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
  +      </input>
  +      <output>
  +        <soap:body use="encoded"
  +                   namespace="http://names.wsdl.test/javanames"
  +                   encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
  +      </output>
  +    </operation>
  +    <operation name="Capitalized">
         <soap:operation soapAction=""/>
         <input>
           <soap:body use="encoded"
  
  
  

Mime
View raw message