scheu 2002/06/14 09:11:12
Modified: java/src/org/apache/axis/wsdl/toJava JavaEnumTypeWriter.java
JavaImplWriter.java JavaTestCaseWriter.java
java/test/wsdl/types ComprehensiveTypes.wsdl
Log:
This is a fix for
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=9869
This fix is necessary for TCK compliance.
The impl and testcase writers are not generating appropriate
ids for the enum values of ints. Added a public static method
to allow access to the proper names and changed the writers
to invoke the new method.
Also changed the comprehensive types test to add this new
scenario.
Enjoy!
Revision Changes Path
1.10 +30 -12
xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaEnumTypeWriter.java
Index: JavaEnumTypeWriter.java
===================================================================
RCS file:
/home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaEnumTypeWriter.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- JavaEnumTypeWriter.java 13 Jun 2002 22:36:23 -0000 1.9
+++ JavaEnumTypeWriter.java 14 Jun 2002 16:11:12 -0000 1.10
@@ -122,11 +122,8 @@
// Create a list of the literal values.
Vector values = new Vector();
- boolean validJava = true; // Assume all enum values are valid java
identifiers
for (int i=1; i < elements.size(); i++) {
String value = (String) elements.get(i);
- if (!JavaUtils.isJavaId(value))
- validJava = false;
if (baseClass.equals("String"))
value = "\"" + value + "\""; // Surround literal with double quotes
else if (baseClass.equals("Character"))
@@ -145,15 +142,7 @@
}
// Create a list of ids
- Vector ids = new Vector();
- for (int i=1; i < elements.size(); i++) {
- // If any enum values are not valid java, then
- // all of the ids are of the form value<1..N>.
- if (!validJava)
- ids.add("value" + i);
- else
- ids.add(elements.get(i));
- }
+ Vector ids = getEnumValueIds(elements);
// Each object has a private _value_ variable to store the base value
pw.println(" private " + baseType + " _value_;");
@@ -239,4 +228,33 @@
pw.println(" public String toString() { return
String.valueOf(_value_);}");
} // writeFileBody
+ /**
+ * Get the enumeration names for the values.
+ * The name is affected by whether all of the values of the enumeration
+ * can be expressed as valid java identifiers.
+ * @param Vector base and values vector from getEnumerationBaseAndValues
+ * @return Vector names of enum value identifiers.
+ */
+ public static Vector getEnumValueIds(Vector bv) {
+ boolean validJava = true; // Assume all enum values are valid ids
+ // Walk the values looking for invalid ids
+ for (int i=1; i < bv.size() && validJava; i++) {
+ String value = (String) bv.get(i);
+ if (!JavaUtils.isJavaId(value))
+ validJava = false;
+ }
+ // Build the vector of ids
+ Vector ids = new Vector();
+ for (int i=1; i < bv.size(); i++) {
+ // If any enum values are not valid java, then
+ // all of the ids are of the form value<1..N>.
+ if (!validJava) {
+ ids.add("value" + i);
+ }
+ else {
+ ids.add((String) bv.get(i));
+ }
+ }
+ return ids;
+ }
} // class JavaEnumTypeWriter
1.25 +2 -1
xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaImplWriter.java
Index: JavaImplWriter.java
===================================================================
RCS file:
/home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaImplWriter.java,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- JavaImplWriter.java 11 Jun 2002 14:54:01 -0000 1.24
+++ JavaImplWriter.java 14 Jun 2002 16:11:12 -0000 1.25
@@ -212,7 +212,8 @@
if (v != null) {
// This constructed type is an enumeration. Use the first
one.
- String enumeration = (String) v.get(1);
+ String enumeration = (String)
+ JavaEnumTypeWriter.getEnumValueIds(v).get(0);
pw.print(paramType + "." + enumeration);
} else {
// This constructed type is a normal type, instantiate it.
1.30 +2 -1
xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaTestCaseWriter.java
Index: JavaTestCaseWriter.java
===================================================================
RCS file:
/home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaTestCaseWriter.java,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- JavaTestCaseWriter.java 11 Jun 2002 14:54:01 -0000 1.29
+++ JavaTestCaseWriter.java 14 Jun 2002 16:11:12 -0000 1.30
@@ -267,7 +267,8 @@
if (v != null) {
// This constructed type is an enumeration. Use the
first one.
- String enumeration = (String) v.get(1);
+ String enumeration = (String)
+ JavaEnumTypeWriter.getEnumValueIds(v).get(0);
pw.print(paramType + "." + enumeration);
} else {
1.31 +80 -0 xml-axis/java/test/wsdl/types/ComprehensiveTypes.wsdl
Index: ComprehensiveTypes.wsdl
===================================================================
RCS file: /home/cvs/xml-axis/java/test/wsdl/types/ComprehensiveTypes.wsdl,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -r1.30 -r1.31
--- ComprehensiveTypes.wsdl 13 Jun 2002 22:36:23 -0000 1.30
+++ ComprehensiveTypes.wsdl 14 Jun 2002 16:11:12 -0000 1.31
@@ -576,6 +576,10 @@
<part name="enum" type="typens:enum"/>
</message>
+ <message name="enumInt">
+ <part name="enumInt" type="typens:enumInt"/>
+ </message>
+
<message name="array">
<part name="array" type="typens:array"/>
</message>
@@ -650,6 +654,22 @@
<input message="tns:empty"/>
<output message="tns:enum"/>
</operation>
+ <operation name="enumIntIn">
+ <input message="tns:enumInt"/>
+ <output message="tns:empty"/>
+ </operation>
+ <operation name="enumIntInout">
+ <input message="tns:enumInt"/>
+ <output message="tns:enumInt"/>
+ </operation>
+ <operation name="enumIntOut" parameterOrder="enumInt">
+ <input message="tns:empty"/>
+ <output message="tns:enumInt"/>
+ </operation>
+ <operation name="enumIntReturn">
+ <input message="tns:empty"/>
+ <output message="tns:enumInt"/>
+ </operation>
<operation name="arrayIn">
<input message="tns:array"/>
<output message="tns:empty"/>
@@ -1008,6 +1028,66 @@
</output>
</operation>
<operation name="enumReturn">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:body
+ use="encoded"
+ namespace=""
+ encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
+ </input>
+ <output>
+ <soap:body
+ use="encoded"
+ namespace=""
+ encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
+ </output>
+ </operation>
+ <operation name="enumIntIn">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:body
+ use="encoded"
+ namespace=""
+ encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
+ </input>
+ <output>
+ <soap:body
+ use="encoded"
+ namespace=""
+ encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
+ </output>
+ </operation>
+ <operation name="enumIntInout">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:body
+ use="encoded"
+ namespace=""
+ encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
+ </input>
+ <output>
+ <soap:body
+ use="encoded"
+ namespace=""
+ encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
+ </output>
+ </operation>
+ <operation name="enumIntOut">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:body
+ use="encoded"
+ namespace=""
+ encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
+ </input>
+ <output>
+ <soap:body
+ use="encoded"
+ namespace=""
+ encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
+ </output>
+ </operation>
+ <operation name="enumIntReturn">
<soap:operation soapAction=""/>
<input>
<soap:body