gdaniels 2002/12/31 08:00:13
Modified: java/src/org/apache/axis/encoding/ser BeanSerializer.java
java/src/org/apache/axis/description ElementDesc.java
FieldDesc.java
java/src/org/apache/axis/wsdl/toJava
JavaBeanHelperWriter.java
Log:
Prepping to fix up some of the array/collection issues and clean up
the metadata model...
Add explicit minOccurs/maxOccurs to ElementDesc, and key
isMinOccursZero off of that. Split out attributes and elements in a
nicer way when writing JavaBeans, which will allow us to set this
stuff later.
Revision Changes Path
1.63 +2 -2
xml-axis/java/src/org/apache/axis/encoding/ser/BeanSerializer.java
Index: BeanSerializer.java
===================================================================
RCS file:
/home/cvs/xml-axis/java/src/org/apache/axis/encoding/ser/BeanSerializer.java,v
retrieving revision 1.62
retrieving revision 1.63
diff -u -r1.62 -r1.63
--- BeanSerializer.java 11 Dec 2002 22:38:15 -0000 1.62
+++ BeanSerializer.java 31 Dec 2002 16:00:11 -0000 1.63
@@ -181,7 +181,7 @@
} else {
qname = field.getXmlName();
}
- isOmittable = field.isMinOccursIs0();
+ isOmittable = field.isMinOccursZero();
xmlType = field.getXmlType();
}
}
@@ -389,7 +389,7 @@
propName,
fieldType,
propertyDescriptor[i].isIndexed(),
- field.isMinOccursIs0(),
+ field.isMinOccursZero(),
all, isAnonymous);
}
} else {
1.2 +25 -0 xml-axis/java/src/org/apache/axis/description/ElementDesc.java
Index: ElementDesc.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/description/ElementDesc.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ElementDesc.java 8 Mar 2002 05:04:53 -0000 1.1
+++ ElementDesc.java 31 Dec 2002 16:00:12 -0000 1.2
@@ -61,7 +61,32 @@
* @author Glen Daniels ([EMAIL PROTECTED])
*/
public class ElementDesc extends FieldDesc {
+ /** The minOccurs value from the schema */
+ private int minOccurs = 1;
+ /** The maxOccurs value from the schema */
+ private int maxOccurs = 1;
+
public ElementDesc() {
super(true);
+ }
+
+ public boolean isMinOccursZero() {
+ return minOccurs == 0;
+ }
+
+ public int getMinOccurs() {
+ return minOccurs;
+ }
+
+ public void setMinOccurs(int minOccurs) {
+ this.minOccurs = minOccurs;
+ }
+
+ public int getMaxOccurs() {
+ return maxOccurs;
+ }
+
+ public void setMaxOccurs(int maxOccurs) {
+ this.maxOccurs = maxOccurs;
}
}
1.8 +9 -1 xml-axis/java/src/org/apache/axis/description/FieldDesc.java
Index: FieldDesc.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/description/FieldDesc.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- FieldDesc.java 19 Sep 2002 20:25:13 -0000 1.7
+++ FieldDesc.java 31 Dec 2002 16:00:12 -0000 1.8
@@ -155,10 +155,18 @@
/**
* Check if this field can be omitted.
*/
- public boolean isMinOccursIs0() {
+ public boolean isMinOccursZero() {
return minOccursIs0;
}
+ /**
+ *
+ *
+ * @param minOccursIs0
+ * @deprecated this functionality, which is only relevant to ElementDescs,
+ * now lives in ElementDesc and is more flexible (you can set
+ * minOccurs and maxOccurs as you please)
+ */
public void setMinOccursIs0(boolean minOccursIs0) {
this.minOccursIs0 = minOccursIs0;
}
1.29 +23 -21
xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaBeanHelperWriter.java
Index: JavaBeanHelperWriter.java
===================================================================
RCS file:
/home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaBeanHelperWriter.java,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- JavaBeanHelperWriter.java 11 Dec 2002 22:38:30 -0000 1.28
+++ JavaBeanHelperWriter.java 31 Dec 2002 16:00:12 -0000 1.29
@@ -231,9 +231,9 @@
// Add attribute and element field descriptors
if (attributes != null || elementMetaData != null) {
- boolean wroteFieldType = false;
-
if (attributes != null) {
+ boolean wroteAttrDecl = false;
+
for (int i = 0; i < attributes.size(); i += 2) {
TypeEntry te = (TypeEntry) attributes.get(i);
QName attrName = (QName) attributes.get(i + 1);
@@ -242,21 +242,23 @@
fieldName = getAsFieldName(fieldName);
QName attrXmlType = te.getQName();
pw.print(" ");
- if (!wroteFieldType) {
- pw.print("org.apache.axis.description.FieldDesc ");
- wroteFieldType = true;
- }
- pw.println("field = new
org.apache.axis.description.AttributeDesc();");
- pw.println(" field.setFieldName(\"" + fieldName +
"\");");
- pw.println(" field.setXmlName(" +
Utils.getNewQName(attrName) + ");");
+ if (!wroteAttrDecl) {
+ pw.print("org.apache.axis.description.AttributeDesc ");
+ wroteAttrDecl = true;
+ }
+ pw.println("attrField = new
org.apache.axis.description.AttributeDesc();");
+ pw.println(" attrField.setFieldName(\"" + fieldName +
"\");");
+ pw.println(" attrField.setXmlName(" +
Utils.getNewQName(attrName) + ");");
if (attrXmlType != null) {
- pw.println(" field.setXmlType(" +
Utils.getNewQName(attrXmlType) + ");");
+ pw.println(" attrField.setXmlType(" +
Utils.getNewQName(attrXmlType) + ");");
}
- pw.println(" typeDesc.addFieldDesc(field);");
+ pw.println(" typeDesc.addFieldDesc(attrField);");
}
}
if (elementMetaData != null) {
+ boolean wroteElemDecl = false;
+
for (int i=0; i<elementMetaData.size(); i++) {
ElementDecl elem = (ElementDecl) elementMetaData.elementAt(i);
@@ -281,20 +283,20 @@
}
pw.print(" ");
- if (!wroteFieldType) {
- pw.print("org.apache.axis.description.FieldDesc ");
- wroteFieldType = true;
- }
- pw.println("field = new
org.apache.axis.description.ElementDesc();");
- pw.println(" field.setFieldName(\"" + fieldName +
"\");");
- pw.println(" field.setXmlName(" +
Utils.getNewQName(xmlName) + ");");
+ if (!wroteElemDecl) {
+ pw.print("org.apache.axis.description.ElementDesc ");
+ wroteElemDecl = true;
+ }
+ pw.println("elemField = new
org.apache.axis.description.ElementDesc();");
+ pw.println(" elemField.setFieldName(\"" + fieldName +
"\");");
+ pw.println(" elemField.setXmlName(" +
Utils.getNewQName(xmlName) + ");");
if (xmlType != null) {
- pw.println(" field.setXmlType(" +
Utils.getNewQName(xmlType) + ");");
+ pw.println(" elemField.setXmlType(" +
Utils.getNewQName(xmlType) + ");");
}
if (elem.getMinOccursIs0()) {
- pw.println(" field.setMinOccursIs0(true);");
+ pw.println(" elemField.setMinOccurs(0);");
}
- pw.println(" typeDesc.addFieldDesc(field);");
+ pw.println(" typeDesc.addFieldDesc(elemField);");
}
}
}