axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gdani...@apache.org
Subject cvs commit: xml-axis/java/src/org/apache/axis/encoding/ser BeanSerializer.java
Date Sun, 17 Mar 2002 16:25:08 GMT
gdaniels    02/03/17 08:25:08

  Modified:    java/src/org/apache/axis/utils JavaUtils.java
               java/src/org/apache/axis/wsdl/toJava
                        JavaComplexTypeWriter.java
               java/test build_functional_tests.xml
               java/src/org/apache/axis/encoding/ser BeanSerializer.java
  Log:
  Fix naming confusion (hopefully for the last time) with xml -> Java property
  names and metadata.
  
  1) Don't try to uppercase the first char of field names when dealing with
     metadata descriptors, so now the names match what the Property
     Descriptors tell us in the BeanSerializer/Deserializer.
  
  2) Follow the bean Introspector pattern for naming properties in
     xmlNameToJava() - if the first char is uppercase and the second
     char is ALSO uppercase, leave it alone.  In other words:
  
     MyID -> myID
     ID -> ID
  
  3) Deal with boolean types and null obj values in the generated equals()
     methods correctly
  
  We might want to merge these changes over to beta1 and refresh the bits,
  since this fixes potentially major problems with literal XML.
  
  Also exclude Interop3TestCase from the func tests since it's not really
  a TestCase and it was breaking my build - this should either be called
  something else or turned into a real test case - Russell, what was your
  intent here?
  
  Revision  Changes    Path
  1.35      +6 -1      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.34
  retrieving revision 1.35
  diff -u -r1.34 -r1.35
  --- JavaUtils.java	12 Mar 2002 17:41:06 -0000	1.34
  +++ JavaUtils.java	17 Mar 2002 16:25:08 -0000	1.35
  @@ -459,7 +459,12 @@
               // because toLowerCase will lowercase some characters that
               // isUpperCase will return false for.  Like \u2160, Roman
               // numeral one.
  -            if (Character.isUpperCase(nameArray[i])) {
  +
  +            // Don't lowercase if this is the first character and the 2nd
  +            // character is also uppercase, to follow Introspector rules.
  +            if (Character.isUpperCase(nameArray[i]) &&
  +                ((i != 0) ||
  +                    (nameLen > 1 && Character.isLowerCase(nameArray[1])))) {
                   result.append(Character.toLowerCase(nameArray[i]));
               }
               else {
  
  
  
  1.23      +16 -18    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.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- JavaComplexTypeWriter.java	15 Mar 2002 01:14:11 -0000	1.22
  +++ JavaComplexTypeWriter.java	17 Mar 2002 16:25:08 -0000	1.23
  @@ -121,8 +121,7 @@
                   if (elementMappings == null)
                       elementMappings = new HashMap();
   
  -                elementMappings.put(Utils.capitalizeFirstChar(javaName),
  -                                    new QName("", elemName));
  +                elementMappings.put(javaName, new QName("", elemName));
               }
               names.add(type.getName());
               names.add(javaName);
  @@ -186,9 +185,9 @@
               String capName = Utils.capitalizeFirstChar(name);
   
               String get = "get";
  -            //if (typeName.equals("boolean") ||
  -            //    typeName.startsWith("boolean["))
  -            //    get = "is"
  +            if (typeName.equals("boolean") ||
  +                typeName.startsWith("boolean["))
  +                get = "is";
   
               pw.println("    public " + typeName + " " + get + capName + "() {");
               pw.println("        return " + name + ";");
  @@ -240,12 +239,6 @@
           // if we have attributes, create metadata function which returns the
           // list of properties that are attributes instead of elements
   
  -        // Glen 3/7/02 : This is now using the type metadata model which
  -        // provides for arbitrary mapping of XML elements or attributes
  -        // <-> Java fields.  We need to generalize this to support element
  -        // mappings as well, but right now this is just to keep the attribute
  -        // mechanism working.
  -
           if (attributes != null || elementMappings != null) {
               boolean wroteFieldType = false;
               pw.println("    // " + JavaUtils.getMessage("typeMeta"));
  @@ -257,9 +250,7 @@
               if (attributes != null) {
                   for (int i = 0; i < attributes.size(); i += 2) {
                       String attrName = (String) attributes.get(i + 1);
  -                    String fieldName =
  -                            Utils.capitalizeFirstChar(
  -                                    Utils.xmlNameToJava(attrName));
  +                    String fieldName = Utils.xmlNameToJava(attrName);
                       pw.print("        ");
                       if (!wroteFieldType) {
                           pw.print("org.apache.axis.description.FieldDesc ");
  @@ -326,6 +317,7 @@
           pw.println("    public boolean equals(Object obj) {");
           pw.println("        // compare elements");
           pw.println("        " +  className + " other = (" + className + ") obj;");
  +        pw.println("        if (obj == null) return false;");
           pw.println("        if (this == obj) return true;");
           pw.println("        if (! (obj instanceof " + className + ")) return false;");
           if (names.size() == 0) {
  @@ -335,7 +327,11 @@
               for (int i = 0; i < names.size(); i += 2) {
                   String variableType = (String) names.get(i);
                   String variable = (String) names.get(i + 1);
  -                
  +                String get = "get";
  +
  +                if (variableType.equals("boolean"))
  +                    get = "is";
  +
                   if (variableType.equals("int") ||
                           variableType.equals("long") ||
                           variableType.equals("short") ||
  @@ -343,13 +339,15 @@
                           variableType.equals("double") ||
                           variableType.equals("boolean") ||
                           variableType.equals("byte")) {
  -                    pw.print("            " + variable + " == other.get" + 
  +                    pw.print("            " + variable + " == other." + get +
                               Utils.capitalizeFirstChar(variable) + "()");
                   } else {
  -                    pw.println("            ((" + variable + "==null && other.get"
+
  +                    pw.println("            ((" + variable +
  +                               "==null && other." + get +
                                  Utils.capitalizeFirstChar(variable) + "()==null) || ");
                       pw.println("             (" + variable + "!=null &&");
  -                    pw.print("              " + variable + ".equals(other.get" + 
  +                    pw.print("              " + variable +
  +                             ".equals(other." + get +
                                Utils.capitalizeFirstChar(variable) + "())))");
                   }
                   if (i == (names.size() - 2))
  
  
  
  1.37      +1 -0      xml-axis/java/test/build_functional_tests.xml
  
  Index: build_functional_tests.xml
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/build_functional_tests.xml,v
  retrieving revision 1.36
  retrieving revision 1.37
  diff -u -r1.36 -r1.37
  --- build_functional_tests.xml	27 Feb 2002 17:22:56 -0000	1.36
  +++ build_functional_tests.xml	17 Mar 2002 16:25:08 -0000	1.37
  @@ -99,6 +99,7 @@
                   has its own test class collecting all the tests -->
                 <include name="**/FunctionalTests.class" />
                 <include name="**/*TestCase.class" />
  +              <exclude name="**/Interop3TestCase.class"/>
           </fileset>
         </batchtest>
       </junit>
  
  
  
  1.21      +4 -1      xml-axis/java/src/org/apache/axis/encoding/ser/BeanSerializer.java
  
  Index: BeanSerializer.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/ser/BeanSerializer.java,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- BeanSerializer.java	14 Mar 2002 21:36:07 -0000	1.20
  +++ BeanSerializer.java	17 Mar 2002 16:25:08 -0000	1.21
  @@ -347,6 +347,7 @@
                           writeAttribute(types, attrName.getLocalPart(),
                                          field.getType(),
                                          complexType);
  +                        continue;
                       } else {
                           QName xmlName = typeDesc.getElementNameForField(
                                   field.getName());
  @@ -356,9 +357,11 @@
                                   // schema for this correctly?
                               }
                               name = xmlName.getLocalPart();
  +                            writeField(types, name, field.getType(),
  +                                       field.getIndexed(), all);
  +                            continue;
                           }
                       }
  -                    return true;
                   }
               }
   
  
  
  

Mime
View raw message