You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by di...@apache.org on 2005/07/09 19:05:44 UTC
cvs commit: ws-axis/java/src/org/apache/axis/wsdl/symbolTable SchemaUtils.java
dims 2005/07/09 10:05:44
Modified: java/src/org/apache/axis/wsdl/toJava JavaBeanWriter.java
java/src/org/apache/axis/wsdl/symbolTable SchemaUtils.java
Log:
Fix for AXIS-1797 - Base attributes not serialized when simpleContent extends another simpleContent
Revision Changes Path
1.78 +40 -9 ws-axis/java/src/org/apache/axis/wsdl/toJava/JavaBeanWriter.java
Index: JavaBeanWriter.java
===================================================================
RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/wsdl/toJava/JavaBeanWriter.java,v
retrieving revision 1.77
retrieving revision 1.78
diff -u -r1.77 -r1.78
--- JavaBeanWriter.java 13 Jun 2005 02:19:52 -0000 1.77
+++ JavaBeanWriter.java 9 Jul 2005 17:05:44 -0000 1.78
@@ -148,6 +148,9 @@
enableHashCode = false;
}
}
+
+ preprocess();
+
} // ctor
/**
@@ -474,7 +477,8 @@
// See if this class extends another class
String extendsText = "";
- if ((extendType != null) && !type.isSimpleType()
+ if ((extendType != null) && !isUnion()
+ && (!type.isSimpleType() || !extendType.isBaseType())
&& (extendType.getDimensions().length() == 0)) {
extendsText = " extends " + extendType.getName() + " ";
}
@@ -492,13 +496,12 @@
// See if this class extends another class
String implementsText = " implements java.io.Serializable";
- if (type.isSimpleType()) {
+ if (type.isSimpleType() &&
+ (isUnion() || extendType == null || extendType.isBaseType()))
+ {
implementsText += ", org.apache.axis.encoding.SimpleType";
}
- // need to call this to find out whether the type contains any elements
- preprocess();
-
if (isAny) {
implementsText += ", org.apache.axis.encoding.AnyContentType";
}
@@ -724,13 +727,39 @@
// If this is a simple type,need to emit a string
// constructor and a value construtor.
- if (simpleValueTypes.size() == 0) {
+ if (!type.isSimpleType())
return;
- }
pw.println(" // " + Messages.getMessage("needStringCtor"));
- if (isUnion() || simpleValueTypes.get(0).equals("java.lang.String")) {
+ // Simple types without simpleValueTypes are derived classes.
+ // Inherit the simple constructor.
+ if (simpleValueTypes.size() == 0)
+ {
+ if (extendType != null)
+ {
+ // Find the java type of the most base type.
+ TypeEntry baseType = type;
+ while (true)
+ {
+ TypeEntry superType = SchemaUtils.getBaseType(
+ baseType, emitter.getSymbolTable());
+ if (superType == null)
+ break;
+ else
+ baseType = superType;
+ }
+
+ String baseJavaType = baseType.getName();
+
+ pw.println(" public " + className + "("
+ + baseJavaType + " _value) {");
+ pw.println(" super(_value);");
+ pw.println(" }");
+ pw.println();
+ }
+ }
+ else if (isUnion() || simpleValueTypes.get(0).equals("java.lang.String")) {
pw.println(" public " + className
+ "(java.lang.String _value) {");
pw.println(" this._value = _value;");
@@ -1090,7 +1119,9 @@
// Before checking the elements, check equality of the super class
String truth = "true";
- if ((extendType != null) && !type.isSimpleType()) {
+ if ((extendType != null) &&
+ (!type.isSimpleType() || simpleValueTypes.size() == 0))
+ {
truth = "super.equals(obj)";
}
1.60 +23 -2 ws-axis/java/src/org/apache/axis/wsdl/symbolTable/SchemaUtils.java
Index: SchemaUtils.java
===================================================================
RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/wsdl/symbolTable/SchemaUtils.java,v
retrieving revision 1.59
retrieving revision 1.60
diff -u -r1.59 -r1.60
--- SchemaUtils.java 13 Jun 2005 02:19:52 -0000 1.59
+++ SchemaUtils.java 9 Jul 2005 17:05:44 -0000 1.60
@@ -301,18 +301,39 @@
&& Constants.isSchemaXSD(kid.getNamespaceURI())) {
// get the type of the extension/restriction from the "base" attribute
- QName extendsOrRestrictsType =
+ QName extendsOrRestrictsTypeName =
Utils.getTypeQName(children.item(j),
new BooleanHolder(), false);
+ TypeEntry extendsOrRestrictsType =
+ symbolTable.getTypeEntry(extendsOrRestrictsTypeName,
+ false);
+
+ // If this type extends a simple type, then add the
+ // special "value" ElementDecl, else this type is
+ // extending another simpleContent type and will
+ // already have a "value".
+
+ if (extendsOrRestrictsType == null ||
+ extendsOrRestrictsType.isBaseType())
+ {
// Return an element declaration with a fixed name
// ("value") and the correct type.
Vector v = new Vector();
- ElementDecl elem = new ElementDecl(symbolTable.getTypeEntry(extendsOrRestrictsType, false), VALUE_QNAME);
+ ElementDecl elem =
+ new ElementDecl(extendsOrRestrictsType,
+ VALUE_QNAME);
v.add(elem);
return v;
}
+ else
+ {
+ // There can't be any other elements in a
+ // simpleContent node.
+ return null;
+ }
+ }
}
}