Return-Path: Delivered-To: apmail-xml-axis-dev-archive@xml.apache.org Received: (qmail 86758 invoked by uid 500); 13 Dec 2001 20:54:02 -0000 Mailing-List: contact axis-dev-help@xml.apache.org; run by ezmlm Precedence: bulk Reply-To: axis-dev@xml.apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list axis-dev@xml.apache.org Received: (qmail 86749 invoked by uid 500); 13 Dec 2001 20:54:01 -0000 Delivered-To: apmail-xml-axis-cvs@apache.org Date: 13 Dec 2001 20:54:01 -0000 Message-ID: <20011213205401.17625.qmail@icarus.apache.org> From: scheu@apache.org To: xml-axis-cvs@apache.org Subject: cvs commit: xml-axis/java/test/wsdl/types ComprehensiveTypes.wsdl X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N scheu 01/12/13 12:54:01 Modified: java/src/org/apache/axis/utils JavaUtils.java java/src/org/apache/axis/wsdl/toJava JavaTestCaseWriter.java TypeEntry.java UndefinedDelegate.java Utils.java java/test build_functional_tests.xml java/test/wsdl/types ComprehensiveTypes.wsdl Log: Added more complicated forward reference testing to Comprehensive Tests. This resulted in a couple of fixes to WSDL2Java. Revision Changes Path 1.14 +36 -0 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.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- JavaUtils.java 2001/12/07 16:33:03 1.13 +++ JavaUtils.java 2001/12/13 20:54:00 1.14 @@ -243,4 +243,40 @@ messages = ResourceBundle.getBundle("org.apache.axis.utils.resources"); } // initializeMessages + /** + * replace: + * Like String.replace except that the old new items are strings. + * + * @param name string + * @param oldt old text to replace + * @param newt new text to use + * @return replacement string + **/ + public static final String replace (String name, + String oldT, String newT) { + + if (name == null) return ""; + + // Create a string buffer that is twice initial length. + // This is a good starting point. + StringBuffer sb = new StringBuffer(name.length()* 2); + + int len = oldT.length (); + try { + int start = 0; + int i = name.indexOf (oldT, start); + + while (i >= 0) { + sb.append(name.substring(start, i)); + sb.append(newT); + start = i+len; + i = name.indexOf(oldT, start); + } + if (start < name.length()) + sb.append(name.substring(start)); + } catch (NullPointerException e) { + } + + return new String(sb); + } } 1.4 +1 -2 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.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- JavaTestCaseWriter.java 2001/12/13 17:11:56 1.3 +++ JavaTestCaseWriter.java 2001/12/13 20:54:00 1.4 @@ -241,8 +241,7 @@ pw.print("new byte[0]"); } else if (paramType.endsWith("[]")) { pw.print("new " - + paramType.substring(0, paramType.length() - 1) - + "0]"); + + JavaUtils.replace(paramType, "[]", "[0]")); } else { // We have some constructed type. 1.3 +53 -28 xml-axis/java/src/org/apache/axis/wsdl/toJava/TypeEntry.java Index: TypeEntry.java =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/TypeEntry.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- TypeEntry.java 2001/12/13 18:25:48 1.2 +++ TypeEntry.java 2001/12/13 20:54:00 1.3 @@ -182,12 +182,63 @@ /** + * Query Java Mapping Name + */ + public String getJavaName() { + return name; + } + + /** + * Query Java Mapping Name + */ + public Node getNode() { + return node; + } + + /** + * Returns the Java Base Type Name. + * For example if the Type represents a schema integer, "int" is returned. + * If this is a user defined type, null is returned. + */ + public String getBaseType() { + if (isBaseType) { + return name; + } + else { + return null; + } + } + + /** + * getUndefinedTypeRef returns the Undefined TypeEntry that this entry depends on or NULL. + */ + protected TypeEntry getUndefinedTypeRef() { + if (this instanceof Undefined) + return this; + if (undefined && refType != null) { + if (refType.undefined) { + TypeEntry uType = refType; + while (!(uType instanceof Undefined)) { + uType = uType.refType; + } + return uType; + } + } + return null; + } + + /** * UpdateUndefined is called when the ref TypeEntry is finally known. + * @param oldRef The TypeEntry representing the Undefined TypeEntry + * @param newRef The replacement TypeEntry + * @return true if TypeEntry is changed in any way. */ protected boolean updateUndefined(TypeEntry oldRef, TypeEntry newRef) throws IOException { + boolean changedState = false; // Replace refType with the new one if applicable if (refType == oldRef) { refType = newRef; + changedState = true; // Detect a loop TypeEntry te = refType; while(te != null && te != this) { @@ -206,39 +257,13 @@ // Update information if refType is now defined if (refType != null && undefined && refType.undefined==false) { undefined = false; + changedState = true; setName(refType.getName() + dims); isBaseType = (refType.getBaseType() != null && dims.equals("")); } - return undefined; - } - - /** - * Query Java Mapping Name - */ - public String getJavaName() { - return name; - } - - /** - * Query Java Mapping Name - */ - public Node getNode() { - return node; + return changedState; } - /** - * Returns the Java Base Type Name. - * For example if the Type represents a schema integer, "int" is returned. - * If this is a user defined type, null is returned. - */ - public String getBaseType() { - if (isBaseType) { - return name; - } - else { - return null; - } - } /** * Get string representation. 1.2 +12 -1 xml-axis/java/src/org/apache/axis/wsdl/toJava/UndefinedDelegate.java Index: UndefinedDelegate.java =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/UndefinedDelegate.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- UndefinedDelegate.java 2001/12/13 17:33:17 1.1 +++ UndefinedDelegate.java 2001/12/13 20:54:00 1.2 @@ -89,16 +89,27 @@ * referrant TypeEntry's that were registered. */ public void update(TypeEntry def) throws IOException { - // Process list until every TypeEntry is defined boolean done = false; while (!done) { done = true; // Assume this is the last pass // Call updatedUndefined for all items on the list + // updateUndefined returns true if the state of the te TypeEntry + // is changed. The outer loop is traversed until there are no more + // state changes. for (int i=0; i < list.size() ; i++) { TypeEntry te = (TypeEntry) list.elementAt(i); if (te.updateUndefined(undefinedType, def)) done = false; // Items still undefined, need another pass + } + } + // It is possible that the def TypeEntry depends on an Undefined type. + // If so, register all of the entries with the undefined type. + TypeEntry uType = def.getUndefinedTypeRef(); + if (uType != null) { + for (int i=0; i < list.size() ; i++) { + TypeEntry te = (TypeEntry) list.elementAt(i); + ((Undefined)uType).register(te); } } } 1.4 +5 -1 xml-axis/java/src/org/apache/axis/wsdl/toJava/Utils.java Index: Utils.java =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/Utils.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- Utils.java 2001/12/13 17:33:17 1.3 +++ Utils.java 2001/12/13 20:54:00 1.4 @@ -308,9 +308,10 @@ QName qName= getNodeTypeRefQName(node, "type"); // If the node has "type" and "maxOccurs" then the type is really - // a collection. There is qname in the wsdl which we can use to represent + // a collection. There is no qname in the wsdl which we can use to represent // the collection, so we need to invent one. // The local part of the qname is changed to [minOccurs, maxOccurs] + // The namespace uri is changed to the targetNamespace of this node if (qName != null) { String maxOccursValue = getAttribute(node, "maxOccurs"); String minOccursValue = getAttribute(node, "minOccurs"); @@ -324,6 +325,9 @@ String localPart = qName.getLocalPart(); localPart += "[" + minOccursValue + "," + maxOccursValue + "]"; qName.setLocalPart(localPart); + String namespace = getScopedAttribute(node, "targetNamespace"); + if (namespace != null) + qName.setNamespaceURI(namespace); } } 1.27 +3 -2 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.26 retrieving revision 1.27 diff -u -r1.26 -r1.27 --- build_functional_tests.xml 2001/12/11 13:16:38 1.26 +++ build_functional_tests.xml 2001/12/13 20:54:01 1.27 @@ -24,6 +24,7 @@ + @@ -84,7 +85,7 @@ - + @@ -207,7 +208,7 @@ - + 1.5 +112 -1 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.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- ComprehensiveTypes.wsdl 2001/12/13 17:11:57 1.4 +++ ComprehensiveTypes.wsdl 2001/12/13 20:54:01 1.5 @@ -5,6 +5,7 @@ targetNamespace="comprehensive.types.test" xmlns:tns="comprehensive.types.test" xmlns:typens="comprehensive.types" + xmlns:typens2="comprehensive.types.test2" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" @@ -53,6 +54,8 @@ + + @@ -65,7 +68,7 @@ - + @@ -76,7 +79,47 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -115,6 +158,10 @@ + + + + @@ -169,6 +216,21 @@ + + @@ -359,6 +421,55 @@ encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> + + +