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 2006/08/18 22:06:23 UTC
svn commit: r432708 - in
/webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema:
BeanWriterMetaInfoHolder.java SchemaCompiler.java SchemaConstants.java
template/ADBBeanTemplate.xsl writer/JavaBeanWriter.java
Author: dims
Date: Fri Aug 18 13:06:22 2006
New Revision: 432708
URL: http://svn.apache.org/viewvc?rev=432708&view=rev
Log:
- Fix for AXIS2-1045 Support for attribute use flag
- Fix for AXIS2-1041 WSDL2Java ADB codegen: Handling of anyAttributes
- Fix for AXIS2-1029 NullPointerException: Handling of custom attribute types
- Fix for AXIS2-1021 WSDL2Java ADB wrong array code generation
Modified:
webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/BeanWriterMetaInfoHolder.java
webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/SchemaCompiler.java
webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/SchemaConstants.java
webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl
webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/writer/JavaBeanWriter.java
Modified: webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/BeanWriterMetaInfoHolder.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/BeanWriterMetaInfoHolder.java?rev=432708&r1=432707&r2=432708&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/BeanWriterMetaInfoHolder.java (original)
+++ webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/BeanWriterMetaInfoHolder.java Fri Aug 18 13:06:22 2006
@@ -369,6 +369,18 @@
}
/**
+ * Gets whether a given QName has the optional attribute status.
+ *
+ * @param qName QName of attribute
+ * @return Returns <code>true</code> if attribute has optional status
+ */
+ public boolean getOptionalAttributeStatusForQName(QName qName) {
+ Integer state = (Integer) specialTypeFlagMap.get(qName);
+ return state != null && getStatus(state.intValue(),
+ SchemaConstants.OPTIONAL_TYPE);
+ }
+
+ /**
* Clears the whole set of tables.
*/
public void clearTables() {
Modified: webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/SchemaCompiler.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/SchemaCompiler.java?rev=432708&r1=432707&r2=432708&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/SchemaCompiler.java (original)
+++ webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/SchemaCompiler.java Fri Aug 18 13:06:22 2006
@@ -696,13 +696,13 @@
if (processedElementRefMap.get(name)!=null){
className =(String)processedElementRefMap.get(name);
- if (isArray) {
+ //if (isArray) {
//append the square braces that say this is an array
//hope this works for all cases!!!!!!!
//todo this however is a thing that needs to be
//todo fixed to get complete language support
- className = className + "[]";
- }
+ // className = className + "[]";
+ //}
}
return className;
@@ -1278,6 +1278,12 @@
if (att.getQName() != null) {
metainf.registerMapping(att.getQName(),schemaTypeName,
baseSchemaTypeMap.get(schemaTypeName).toString(), SchemaConstants.ATTRIBUTE_TYPE);
+
+ // add optional attribute status if set
+ String use = att.getUse().getValue();
+ if (use.indexOf("optional") != -1) {
+ metainf.addtStatus(att.getQName(), SchemaConstants.OPTIONAL_TYPE);
+ }
}
}
} else if (att.getRefName() != null) {
@@ -1296,8 +1302,19 @@
if (attribute.getName().equals(att.getRefName().getLocalPart())) {
QName attrTypeName = attribute.getSchemaTypeName();
+ Object type = baseSchemaTypeMap.get(attrTypeName);
+ if (type != null) {
metainf.registerMapping(attrQname,attrQname,
- baseSchemaTypeMap.get(attrTypeName).toString(), SchemaConstants.ATTRIBUTE_TYPE);
+ type.toString(), SchemaConstants.ATTRIBUTE_TYPE);
+
+ // add optional attribute status if set
+ String use = att.getUse().getValue();
+ if (use.indexOf("optional") != -1) {
+ metainf.addtStatus(att.getQName(), SchemaConstants.OPTIONAL_TYPE);
+ }
+ } else {
+ // TODO: This is no standard type - handle custom types here!
+ }
}
}
}
Modified: webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/SchemaConstants.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/SchemaConstants.java?rev=432708&r1=432707&r2=432708&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/SchemaConstants.java (original)
+++ webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/SchemaConstants.java Fri Aug 18 13:06:22 2006
@@ -88,7 +88,7 @@
public static final int ARRAY_TYPE = 0x04;
public static final int ANY_TYPE = 0x08;
public static final int BINARY_TYPE = 0x10;
-
+ public static final int OPTIONAL_TYPE = 0x20;
public static class SchemaPropertyNames{
Modified: webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl?rev=432708&r1=432707&r2=432708&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl (original)
+++ webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl Fri Aug 18 13:06:22 2006
@@ -504,12 +504,14 @@
xmlWriter);
</xsl:when>
<xsl:when test="@any and @array">
+ if (<xsl:value-of select="$varName"/> != null) {
for (int i=0;i <<xsl:value-of select="$varName"/>.length;i++){
writeAttribute(<xsl:value-of select="$varName"/>[i].getNamespace().getName(),
<xsl:value-of select="$varName"/>[i].getLocalName(),
<xsl:value-of select="$varName"/>[i].getAttributeValue(),
xmlWriter);
}
+ }
</xsl:when>
<!-- there can never be attribute arrays in the normal case-->
<xsl:otherwise>
@@ -1159,6 +1161,9 @@
</xsl:if>
<!-- populate attributes here!!!. The attributes are part of an element, not part of a type -->
+ // Note all attributes that were handled. Used to differ normal attributes
+ // from anyAttributes.
+ java.util.Vector handledAttributes = new java.util.Vector();
<xsl:for-each select="property[@attribute]">
<xsl:variable name="propertyName" select="@name"/>
<xsl:variable name="propertyType" select="@type"/>
@@ -1169,6 +1174,8 @@
<xsl:variable name="namespace" select="@nsuri"/>
<xsl:variable name="attribName">tempAttrib<xsl:value-of select="$propertyName"/></xsl:variable>
+ <xsl:if test="$propertyName != 'extraAttributes'">
+ // handle attribute "<xsl:value-of select="$propertyName"/>"
java.lang.String <xsl:value-of select="$attribName"/> =
reader.getAttributeValue("<xsl:value-of select="$namespace"/>","<xsl:value-of select="$propertyName"/>");
if (<xsl:value-of select="$attribName"/>!=null){
@@ -1176,6 +1183,30 @@
org.apache.axis2.databinding.utils.ConverterUtil.convertTo<xsl:value-of select="$shortTypeName"/>(
<xsl:value-of select="$attribName"/>));
}
+ handledAttributes.add("<xsl:value-of select="$propertyName"/>");
+ </xsl:if>
+
+ <!-- Handle anyAttributes here -->
+ <xsl:if test="$propertyName = 'extraAttributes'">
+ // now run through all any or extra attributes
+ // which were not reflected until now
+ for (int i=0; i < reader.getAttributeCount(); i++) {
+ if (!handledAttributes.contains(reader.getAttributeLocalName(i))) {
+ // this is an anyAttribute and we create
+ // an OMAttribute for this
+ org.apache.axiom.om.impl.llom.OMAttributeImpl attr =
+ new org.apache.axiom.om.impl.llom.OMAttributeImpl(
+ reader.getAttributeLocalName(i),
+ new org.apache.axiom.om.impl.dom.NamespaceImpl(
+ reader.getAttributeNamespace(i), reader.getAttributePrefix(i)),
+ reader.getAttributeValue(i),
+ org.apache.axiom.om.OMAbstractFactory.getOMFactory());
+
+ // and add it to the extra attributes
+ object.addExtraAttributes(attr);
+ }
+ }
+ </xsl:if>
</xsl:for-each>
@@ -1780,6 +1811,14 @@
}
</xsl:when>
<!-- there can never be attribute arrays in the normal case-->
+ <xsl:when test="@optional">
+ // optional attribute <xsl:value-of select="$propertyName"/>
+ if (<xsl:value-of select="$varName"/> != null) {
+ writeAttribute("<xsl:value-of select="$namespace"/>",
+ "<xsl:value-of select="$propertyName"/>",
+ org.apache.axis2.databinding.utils.ConverterUtil.convertToString(<xsl:value-of select="$varName"/>), xmlWriter);
+ }
+ </xsl:when>
<xsl:otherwise>
writeAttribute("<xsl:value-of select="$namespace"/>",
"<xsl:value-of select="$propertyName"/>",
Modified: webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/writer/JavaBeanWriter.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/writer/JavaBeanWriter.java?rev=432708&r1=432707&r2=432708&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/writer/JavaBeanWriter.java (original)
+++ webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/writer/JavaBeanWriter.java Fri Aug 18 13:06:22 2006
@@ -611,6 +611,10 @@
XSLTUtils.addAttribute(model, "nillable", "yes", property);
}
+ if (metainf.getOptionalAttributeStatusForQName(name)) {
+ XSLTUtils.addAttribute(model, "optional", "yes", property);
+ }
+
String shortTypeName;
if (metainf.getSchemaQNameForQName(name) != null) {
// see whether the QName is a basetype
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org