axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t...@apache.org
Subject cvs commit: xml-axis/java/src/org/apache/axis/wsdl/toJava JavaComplexTypeWriter.java
Date Thu, 28 Feb 2002 19:00:40 GMT
tomj        02/02/28 11:00:40

  Modified:    java/src/org/apache/axis/wsdl/toJava
                        JavaComplexTypeWriter.java
  Log:
  Improve generated equals() function and handle beans with no elements.
  
  Revision  Changes    Path
  1.13      +27 -21    xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaComplexTypeWriter.java
  
  Index: JavaComplexTypeWriter.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaComplexTypeWriter.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- JavaComplexTypeWriter.java	28 Feb 2002 17:32:08 -0000	1.12
  +++ JavaComplexTypeWriter.java	28 Feb 2002 19:00:40 -0000	1.13
  @@ -260,28 +260,34 @@
           pw.println("    public boolean equals(Object obj) {");
           pw.println("        // compare elements");
           pw.println("        " +  className + " other = (" + className + ") obj;");
  -        pw.println("        return");
  -        for (int i = 0; i < names.size(); i += 2) {
  -            String variableType = (String) names.get(i);
  -            String variable = (String) names.get(i + 1);
  -            
  -            if (variableType.equals("int") ||
  -                variableType.equals("long") ||
  -                variableType.equals("short") ||
  -                variableType.equals("float") ||
  -                variableType.equals("double") ||
  -                variableType.equals("boolean") ||
  -                variableType.equals("byte")) {
  -                pw.print("            " + variable + " == other.get" + 
  -                        Utils.capitalizeFirstChar(variable) + "()");
  -            } else {
  -                pw.print("            " + variable + ".equals(other.get" + 
  -                        Utils.capitalizeFirstChar(variable) + "())");
  +        pw.println("        if (this == obj) return true;");
  +        pw.println("        if (! obj instanceof " + className + ") return false;");
  +        if (names.size() == 0) {
  +            pw.println("        return true;");
  +        } else {
  +            pw.println("        return");
  +            for (int i = 0; i < names.size(); i += 2) {
  +                String variableType = (String) names.get(i);
  +                String variable = (String) names.get(i + 1);
  +                
  +                if (variableType.equals("int") ||
  +                        variableType.equals("long") ||
  +                        variableType.equals("short") ||
  +                        variableType.equals("float") ||
  +                        variableType.equals("double") ||
  +                        variableType.equals("boolean") ||
  +                        variableType.equals("byte")) {
  +                    pw.print("            " + variable + " == other.get" + 
  +                            Utils.capitalizeFirstChar(variable) + "()");
  +                } else {
  +                    pw.print("            " + variable + ".equals(other.get" + 
  +                            Utils.capitalizeFirstChar(variable) + "())");
  +                }
  +                if (i == (names.size() - 2))
  +                    pw.println(";");
  +                else
  +                    pw.println(" &&");
               }
  -            if (i == (names.size() - 2))
  -                pw.println(";");
  -            else
  -                pw.println(" &&");
           }
           pw.println("    }");
   
  
  
  

Mime
View raw message