axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From James M Snell <jasn...@us.ibm.com>
Subject Re: cvs commit: xml-axis/java/src/org/apache/axis/wsdl/toJava JavaBeanWriter.java JavaGeneratorFactory.java
Date Sun, 02 Mar 2003 03:12:54 GMT
+1.  The fix I committed is a temporary one to get us around compilation 
errors.  Long term, this code needs to be refactored to create nested 
classes. Perhaps we can look at that for 1.2 or 1.3.

- James Snell
     IBM Emerging Technologies
     jasnell@us.ibm.com
     (559) 587-1233 (office)
     (700) 544-9035 (t/l)
     Programming Web Services With SOAP
         O'Reilly & Associates, ISBN 0596000952

     Have I not commanded you? Be strong and courageous. 
     Do not be terrified, do not be discouraged, for the Lord your 
     God will be with you whereever you go.    - Joshua 1:9



"Glen Daniels" <gdaniels@macromedia.com>
03/01/2003 04:53 PM
Please respond to axis-dev


To
<axis-dev@ws.apache.org>
cc

bcc

Subject
Re: cvs commit: xml-axis/java/src/org/apache/axis/wsdl/toJava 
JavaBeanWriter.java JavaGeneratorFactory.java



Long term, the correct mapping here is to an inner class of A called C, 
since
that mirrors the containment relationship of the types in the schema.

--Glen

----- Original Message -----
From: "James M Snell" <jasnell@us.ibm.com>
To: <axis-dev@ws.apache.org>
Cc: <xml-axis-cvs@apache.org>
Sent: Friday, February 28, 2003 12:21 PM
Subject: Re: cvs commit: xml-axis/java/src/org/apache/axis/wsdl/toJava
JavaBeanWriter.java JavaGeneratorFactory.java


> Ok on the underscores.  However, the second thing you backed out with 
this
> should not have been....
>
> <snip>
> -                           // Check to see if this is an anonymous 
type,
> -                           // if it is, replace Axis' ANON_TOKEN with
> -                           // an underscore to make sure we don't run
> -                           // into name collisions with similarly named
> -                           // non-anonymous types
> -                           StringBuffer sb = new 
StringBuffer(localName);
> -                           int aidx = -1;
> -                           while (
> -                             (aidx = sb.toString().indexOf(
> -                               SymbolTable.ANON_TOKEN)) > -1) {
> -                                 sb.replace(aidx,
> aidx+SymbolTable.ANON_TOKEN.length(), "_");
> -                           }
> -                           localName = sb.toString();
> -
> -                           typeQName = new
> QName(typeQName.getNamespaceURI(),
> -                                                 localName);
> -
> +                            // This is an anonymous type name.
> +                            // Axis uses '>' as a nesting token to
> generate
> +                            // unique qnames for anonymous types.
> +                            // Only consider the localName after the 
last
> '>'
> +                            // when generating the java name
> +                            String localName = 
typeQName.getLocalPart();
> +                            localName =
> +                                localName.substring(
> +                                    localName.lastIndexOf(
> +                                        SymbolTable.ANON_TOKEN)+1);
> +                            typeQName = new
> QName(typeQName.getNamespaceURI(),
> +                                                  localName);
> </snip>
>
> This code fixes a very real problem with anonymous types...
>
> Given the XML Schema
>
> <xs:complexType name="a">
>   <xs:sequence>
>     <xs:element name="c">
>       <xs:simpleType>
>         <xs:restriction base="xs:string" />
>       </xs:simpleType>
>     </xs:element>
>   </xs:sequence>
> </xs:complexType>
> <xs:complexType name="c"/>
>
> WSDL2Java will create two classes called C.java which causes a
> IOException.  We need to mangle the name of the anonymous type in order
> for this to work. The new file and classname would be A_c rather than 
just
> c.
>
> If this breaks test cases, then the test cases need to be fixed. Backing
> out the changes I made is not the right solution.  Please restore what I
> did and take a look at the test cases.
>
> - James Snell
>      IBM Emerging Technologies
>      jasnell@us.ibm.com
>      (559) 587-1233 (office)
>      (700) 544-9035 (t/l)
>      Programming Web Services With SOAP
>          O'Reilly & Associates, ISBN 0596000952
>
>      Have I not commanded you? Be strong and courageous.
>      Do not be terrified, do not be discouraged, for the Lord your
>      God will be with you whereever you go.    - Joshua 1:9
>
>
>
> dims@apache.org
> 02/28/2003 07:32 AM
> Please respond to axis-dev
>
>
> To
> xml-axis-cvs@apache.org
> cc
>
> bcc
>
> Subject
> cvs commit: xml-axis/java/src/org/apache/axis/wsdl/toJava
> JavaBeanWriter.java JavaGeneratorFactory.java
>
>
>
> dims        2003/02/28 07:32:34
>
> Modified:    java/src/org/apache/axis/wsdl/toJava JavaBeanWriter.java
> JavaGeneratorFactory.java
> Log:
> Breaks "ant clean all-tests"....Commenting it out till James/Glen gets a
> chance to take a look.
>
> Revision  Changes    Path
> 1.36      +13 -13
> xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaBeanWriter.java
>
> Index: JavaBeanWriter.java
> ===================================================================
> RCS file:
> 
/home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaBeanWriter.java,v
> retrieving revision 1.35
> retrieving revision 1.36
> diff -u -r1.35 -r1.36
> --- JavaBeanWriter.java 28 Feb 2003 00:36:09 -0000      1.35
> +++ JavaBeanWriter.java 28 Feb 2003 15:32:34 -0000      1.36
> @@ -273,7 +273,7 @@
> String variable = (String) names.get(i + 1);
>
> // Declare the bean element
> -            pw.print("    private " + typeName + " " +
> Utils.addUnderscore(variable) + ";");
> +            pw.print("    private " + typeName + " " + variable + ";");
>
> // label the attribute fields.
> if (elements == null || i >= (elements.size()*2))
> @@ -498,14 +498,14 @@
> if (enableGetters) {
> pw.println("    public " + typeName + " " +
> get + capName + "() {");
> -                pw.println("        return " + 
Utils.addUnderscore(name)
> + ";");
> +                pw.println("        return " + name + ";");
> pw.println("    }");
> pw.println();
> }
> if (enableSetters) {
> pw.println("    public void set" + capName + "(" +
> -                           typeName + " " + Utils.addUnderscore(name) +
> ") {");
> -                pw.println("        this." + Utils.addUnderscore(name) 
+
> " = " + Utils.addUnderscore(name) + ";");
> +                           typeName + " " + name + ") {");
> +                pw.println("        this." + name + " = " + name + 
";");
> pw.println("    }");
> pw.println();
> }
> @@ -525,7 +525,7 @@
> if (enableGetters) {
> pw.println("    public " + compName + " " + get + capName +
> "(int i) {");
> -                        pw.println("        return " +
> Utils.addUnderscore(name) + "[i];");
> +                        pw.println("        return " + name + "[i];");
> pw.println("    }");
> pw.println();
> }
> @@ -553,7 +553,7 @@
> pw.println("            this." + name + " = a;");
> pw.println("        }");
> */
> -                        pw.println("        this." +
> Utils.addUnderscore(name) + "[i] = value;");
> +                        pw.println("        this." + name + "[i] =
> value;");
> pw.println("    }");
> pw.println();
> }
> @@ -609,24 +609,24 @@
> variableType.equals("double") ||
> variableType.equals("boolean") ||
> variableType.equals("byte")) {
> -                    pw.print("            " +
> Utils.addUnderscore(variable) + " == other." + get +
> +                    pw.print("            " + variable + " == other." +
> get +
> Utils.capitalizeFirstChar(variable) + "()");
> } else if (variableType.indexOf("[") >=0) {
> // Use java.util.Arrays.equals to compare arrays.
> -                    pw.println("            ((" +
> Utils.addUnderscore(variable) +
> +                    pw.println("            ((" + variable +
> "==null && other." + get +
> Utils.capitalizeFirstChar(variable) + "()==null) || ");
> -                    pw.println("             (" +
> Utils.addUnderscore(variable) + "!=null &&");
> -                    pw.print("              java.util.Arrays.equals(" +
> Utils.addUnderscore(variable) +
> +                    pw.println("             (" + variable + "!=null
> &&");
> +                    pw.print("              java.util.Arrays.equals(" +
> variable +
> ", other." + get +
> Utils.capitalizeFirstChar(variable) + "())))");
>
> } else {
> -                    pw.println("            ((" +
> Utils.addUnderscore(variable) +
> +                    pw.println("            ((" + variable +
> "==null && other." + get +
> Utils.capitalizeFirstChar(variable) + "()==null) || ");
> -                    pw.println("             (" +
> Utils.addUnderscore(variable) + "!=null &&");
> -                    pw.print("              " +
> Utils.addUnderscore(variable) +
> +                    pw.println("             (" + variable + "!=null
> &&");
> +                    pw.print("              " + variable +
> ".equals(other." + get +
> Utils.capitalizeFirstChar(variable) + "())))");
> }
>
>
>
> 1.36      +12 -19
> xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaGeneratorFactory.java
>
> Index: JavaGeneratorFactory.java
> ===================================================================
> RCS file:
>
/home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaGeneratorFactory.ja
va,v
> retrieving revision 1.35
> retrieving revision 1.36
> diff -u -r1.35 -r1.36
> --- JavaGeneratorFactory.java   28 Feb 2003 14:16:01 -0000      1.35
> +++ JavaGeneratorFactory.java   28 Feb 2003 15:32:34 -0000      1.36
> @@ -372,25 +372,18 @@
> // the qName
> tEntry.setName(emitter.getJavaName(typeQName));
> } else {
> -                           String localName = typeQName.getLocalPart();
> -
> -                           // Check to see if this is an anonymous 
type,
> -                           // if it is, replace Axis' ANON_TOKEN with
> -                           // an underscore to make sure we don't run
> -                           // into name collisions with similarly named
> -                           // non-anonymous types
> -                           StringBuffer sb = new 
StringBuffer(localName);
> -                           int aidx = -1;
> -                           while (
> -                             (aidx = sb.toString().indexOf(
> -                               SymbolTable.ANON_TOKEN)) > -1) {
> -                                 sb.replace(aidx,
> aidx+SymbolTable.ANON_TOKEN.length(), "_");
> -                           }
> -                           localName = sb.toString();
> -
> -                           typeQName = new
> QName(typeQName.getNamespaceURI(),
> -                                                 localName);
> -
> +                            // This is an anonymous type name.
> +                            // Axis uses '>' as a nesting token to
> generate
> +                            // unique qnames for anonymous types.
> +                            // Only consider the localName after the 
last
> '>'
> +                            // when generating the java name
> +                            String localName = 
typeQName.getLocalPart();
> +                            localName =
> +                                localName.substring(
> +                                    localName.lastIndexOf(
> +                                        SymbolTable.ANON_TOKEN)+1);
> +                            typeQName = new
> QName(typeQName.getNamespaceURI(),
> +                                                  localName);
> // If there is already an existing type,
> // there will be a collision.
> // If there is an existing anon type,
>
>
>
>



Mime
View raw message