Ack!
Fixed. -- Tom Jordahl -----Original Message----- From: Russell Butek [mailto:[EMAIL PROTECTED]] Sent: Friday, April 19, 2002 4:57 PM To: [EMAIL PROTECTED] Subject: Re: cvs commit: xml-axis/java/src/org/apache/axis/wsdl/toJava JavaBeanWriter.java Tom, this broke the build. See tests test/wsdl/refattr and test/wsdl/types Russell Butek [EMAIL PROTECTED] [EMAIL PROTECTED] on 04/19/2002 02:31:23 PM Please respond to [EMAIL PROTECTED] To: [EMAIL PROTECTED] cc: Subject: cvs commit: xml-axis/java/src/org/apache/axis/wsdl/toJava JavaBeanWriter.java tomj 02/04/19 12:31:23 Modified: java/src/org/apache/axis/wsdl/toJava JavaBeanWriter.java Log: Fix bug 7557: SimpleTypes derived from primitive types did not work. Fix up the constructor and the toString code emitted for SimpleTypes to do the right thing for primative types. Per the bug report suggestion, add a value constructor for SimpleType beans. Revision Changes Path 1.8 +31 -7 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.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- JavaBeanWriter.java 19 Apr 2002 19:14:57 -0000 1.7 +++ JavaBeanWriter.java 19 Apr 2002 19:31:23 -0000 1.8 @@ -150,11 +150,18 @@ pw.println("public " + abstractText + "class " + className + extendsText + " implements java.io.Serializable" + implementsText + " {"); + // Define the member element of the bean for (int i = 0; i < names.size(); i += 2) { + String typeName = (String) names.get(i); String variable = (String) names.get(i + 1); - if (variable.equals("value")) - valueType = (String) names.get(i); - pw.print(" private " + names.get(i) + " " + variable + ";"); + + if (type.isSimpleType() && variable.equals("value")) { + valueType = typeName; + } + + // Declare the bean element + pw.print(" private " + typeName + " " + variable + ";"); + // label the attribute fields. if (elements == null || i >= (elements.size()*2)) pw.println(" // attribute"); @@ -162,12 +169,15 @@ pw.println(); } + // Define the default constructor pw.println(); pw.println(" public " + className + "() {"); pw.println(" }"); pw.println(); int j = 0; + + // Define getters and setters for the bean elements for (int i = 0; i < names.size(); i += 2, j++) { String typeName = (String) names.get(i); String name = (String) names.get(i + 1); @@ -226,21 +236,35 @@ } // if this is a simple type, we need to emit a toString and a string - // constructor + // constructor and throw in a value construtor too. if (type.isSimpleType() && valueType != null) { // emit contructors and toString(). + pw.println(" public " + className + "(" + valueType + " value) {"); + pw.println(" this.value = value;"); + pw.println(" }"); + pw.println(); + pw.println(" // " + JavaUtils.getMessage ("needStringCtor")); pw.println(" public " + className + "(java.lang.String value) {"); - pw.println(" this.value = new " + valueType + "(value);"); + // Make sure we wrap base types with its Object type + String wrapper = JavaUtils.getWrapper(valueType); + if (wrapper != null) { + pw.println(" this.value = new " + wrapper + "(value)." + valueType + "Value();"); + } else { + pw.println(" this.value = new " + valueType + "(value);"); + } pw.println(" }"); pw.println(); pw.println(" // " + JavaUtils.getMessage ("needToString")); pw.println(" public String toString() {"); - pw.println(" return value.toString();"); + if (wrapper != null) { + pw.println(" return new " + wrapper + "(value).toString();"); + } else { + pw.println(" return value.toString();"); + } pw.println(" }"); pw.println(); } - writeEqualsMethod(); writeHashCodeMethod();