scheu 02/02/08 08:52:12
Modified: java/src/org/apache/axis Constants.java
java/src/org/apache/axis/wsdl/fromJava Types.java
Log:
Enhanced the javaType -> qname processing in Java2WSDL
Revision Changes Path
1.53 +43 -0 xml-axis/java/src/org/apache/axis/Constants.java
Index: Constants.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/Constants.java,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -r1.52 -r1.53
--- Constants.java 7 Feb 2002 13:46:36 -0000 1.52
+++ Constants.java 8 Feb 2002 16:52:12 -0000 1.53
@@ -173,6 +173,49 @@
return null;
}
+ /**
+ * equals
+ * The first QName is the current version of the name. The second qname is
compared
+ * with the first considering all namespace uri versions.
+ * @param first Currently supported QName
+ * @param second any qname
+ * @return true if the qnames represent the same qname (paster namespace uri
versions considered
+ */
+ public static boolean equals(QName first, QName second) {
+ if (first == second) {
+ return true;
+ }
+ if (first==null || second==null) {
+ return false;
+ }
+ if (first.equals(second)) {
+ return true;
+ }
+ if (!first.getLocalPart().equals(second.getLocalPart())) {
+ return false;
+ }
+
+ String namespaceURI = first.getNamespaceURI();
+ String[] search = null;
+ if (namespaceURI.equals(URI_CURRENT_SOAP_ENC))
+ search = URIS_SOAP_ENC;
+ else if (namespaceURI.equals(URI_CURRENT_SOAP_ENV))
+ search = URIS_SOAP_ENV;
+ else if (namespaceURI.equals(URI_CURRENT_SCHEMA_XSD))
+ search = URIS_SCHEMA_XSD;
+ else if (namespaceURI.equals(URI_CURRENT_SCHEMA_XSI))
+ search = URIS_SCHEMA_XSI;
+ else
+ search = new String[] {namespaceURI};
+
+ for (int i=0; i < search.length; i++) {
+ if (search[i].equals(second.getNamespaceURI())) {
+ return true;
+ }
+ }
+ return false;
+ }
+
// Misc SOAP Namespaces
public static final String URI_NEXT_ACTOR =
"http://schemas.xmlsoap.org/soap/actor/next" ;
1.15 +63 -48 xml-axis/java/src/org/apache/axis/wsdl/fromJava/Types.java
Index: Types.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/fromJava/Types.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- Types.java 2 Feb 2002 18:06:19 -0000 1.14
+++ Types.java 8 Feb 2002 16:52:12 -0000 1.15
@@ -196,59 +196,69 @@
}
/**
- * Return the QName of the type
- * @param type input class
+ * Return the QName of the specified javaType
+ * @param javaType input javaType Class
* @return QName
*/
- private javax.xml.rpc.namespace.QName getTypeQName(Class type) {
+ private javax.xml.rpc.namespace.QName getTypeQName(Class javaType) {
javax.xml.rpc.namespace.QName qName = null;
- String typeName = null;
- if (type.isArray()) {
- Class componentType = type.getComponentType();
- // Check for Byte[], byte[] and Object[]
- if (componentType == java.lang.Byte.class) {
- qName = new
javax.xml.rpc.namespace.QName(Constants.URI_CURRENT_SOAP_ENC, "base64");
- } else if (componentType == java.lang.Byte.TYPE) {
- qName = new
javax.xml.rpc.namespace.QName(Constants.URI_CURRENT_SCHEMA_XSD, "base64Binary");
- } else if (componentType == java.lang.Object.class) {
- qName = new
javax.xml.rpc.namespace.QName(Constants.URI_CURRENT_SOAP_ENC, "Array");
- } else {
- // Construct ArrayOf in targetNamespace
- javax.xml.rpc.namespace.QName cqName = getTypeQName(componentType);
- String pre = namespaces.getCreatePrefix(cqName.getNamespaceURI());
- String localPart = "ArrayOf_" + pre + "_" + cqName.getLocalPart();
- qName = new javax.xml.rpc.namespace.QName(targetNamespace,
- localPart);
- }
- } else {
- // Get the QName from the type mapping or create our own.
- javax.xml.rpc.namespace.QName dQName = null;
- if (defaultTM != null) {
- dQName = defaultTM.getTypeQName(type);
- }
- if (tm != null) {
- qName = tm.getTypeQName(type);
- }
- if (qName == null) {
+ // Use the typeMapping information to lookup the qName.
+ javax.xml.rpc.namespace.QName dQName = null;
+ if (defaultTM != null) {
+ dQName = defaultTM.getTypeQName(javaType);
+ }
+ if (tm != null) {
+ qName = tm.getTypeQName(javaType);
+ }
+ if (qName == null) {
+ qName = dQName;
+ } else if (qName != null && qName != dQName) {
+ // If the TM and default TM resulted in different
+ // names, choose qName unless it is a schema namespace.
+ // (i.e. prefer soapenc primitives over schema primitives)
+ if (Constants.isSchemaXSD(qName.getNamespaceURI())) {
qName = dQName;
- } else if (qName != null && qName != dQName) {
- // If the TM and default TM resulted in different
- // names, choose qName unless it is a schema namespace.
- // (i.e. prefer soapenc primitives over schema primitives)
- if (Constants.isSchemaXSD(qName.getNamespaceURI())) {
- qName = dQName;
- }
}
- if (qName == null) {
- String pkg = getPackageNameFromFullName(type.getName());
- String lcl = getLocalNameFromFullName(type.getName());
-
- String ns = namespaces.getCreate(pkg);
- String pre = namespaces.getCreatePrefix(ns);
- String localPart = lcl.replace('$', '_');
- qName = new javax.xml.rpc.namespace.QName(ns, localPart);
+ }
+
+ // If the javaType is an array and the qName is
+ // SOAP_ARRAY, construct the QName using the
+ // QName of the component type
+ if (javaType.isArray() &&
+ qName != null &&
+ Constants.equals(Constants.SOAP_ARRAY, qName)) {
+ Class componentType = javaType.getComponentType();
+ if (componentType != java.lang.Object.class) {
+ // If component namespace uri == targetNamespace
+ // Construct ArrayOf<componentLocalPart>
+ // Else
+ // Construct ArrayOf_<componentPrefix>_<componentLocalPart>
+ javax.xml.rpc.namespace.QName cqName = getTypeQName(componentType);
+ if (targetNamespace.equals(cqName.getNamespaceURI())) {
+ qName = new javax.xml.rpc.namespace.QName(
+ targetNamespace,
+ "ArrayOf" + cqName.getLocalPart());
+ } else {
+ String pre =
namespaces.getCreatePrefix(cqName.getNamespaceURI());
+ qName = new javax.xml.rpc.namespace.QName(
+ targetNamespace,
+ "ArrayOf_" + pre + "_" + cqName.getLocalPart());
+ }
}
+ return qName;
+ }
+
+ // If a qName was not found construct one using the
+ // class name information.
+ if (qName == null) {
+ String pkg = getPackageNameFromFullName(javaType.getName());
+ String lcl = getLocalNameFromFullName(javaType.getName());
+
+ String ns = namespaces.getCreate(pkg);
+ String pre = namespaces.getCreatePrefix(ns);
+ String localPart = lcl.replace('$', '_');
+ qName = new javax.xml.rpc.namespace.QName(ns, localPart);
}
return qName;
@@ -736,13 +746,18 @@
/**
- * Determines if the field is nullable. All non-primitives are Nullable
+ * Determines if the field is nullable. All non-primitives except
+ * for byte[] are nillable.
*
* @param type input Class
* @return true if nullable
*/
private boolean isNullable(Class type) {
- return !type.isPrimitive();
+ if (type.isPrimitive() ||
+ (type.isArray() && type.getComponentType() == byte.class))
+ return false;
+ else
+ return true;
}