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 aj...@apache.org on 2006/04/05 06:47:57 UTC
svn commit: r391484 - in /webservices/axis2/trunk/java/modules:
adb/src/org/apache/axis2/databinding/utils/
adb/src/org/apache/axis2/databinding/utils/reader/
codegen/src/org/apache/axis2/schema/template/
Author: ajith
Date: Tue Apr 4 21:47:56 2006
New Revision: 391484
URL: http://svn.apache.org/viewcvs?rev=391484&view=rev
Log:
Fixing minor issues in Codegen
1. Introduced a new key for the OMElement
2. The state machines had a wrong QName check for the nil status!
3. The arrays of ADBBeans and OMElements are now handled in expanded array forms
Added:
webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/reader/OMElementKey.java
Modified:
webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/Constants.java
webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/SimpleArrayReaderStateMachine.java
webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/SimpleElementReaderStateMachine.java
webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/reader/ADBXMLStreamReaderImpl.java
webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl
Modified: webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/Constants.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/Constants.java?rev=391484&r1=391483&r2=391484&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/Constants.java (original)
+++ webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/Constants.java Tue Apr 4 21:47:56 2006
@@ -1,6 +1,9 @@
package org.apache.axis2.databinding.utils;
import org.apache.axis2.databinding.utils.reader.OMAttribKey;
+import org.apache.axis2.databinding.utils.reader.OMElementKey;
+
+import javax.xml.namespace.QName;
/*
* Copyright 2004,2005 The Apache Software Foundation.
*
@@ -21,6 +24,8 @@
static String NIL="nil";
static String TRUE="true";
+ static String XSI_NAMESPACE ="http://www.w3.org/2001/XMLSchema-instance";
static Object OM_ATTRIBUTE_KEY = new OMAttribKey();
+ static Object OM_ELEMENT_KEY = new OMElementKey();
}
Modified: webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/SimpleArrayReaderStateMachine.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/SimpleArrayReaderStateMachine.java?rev=391484&r1=391483&r2=391484&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/SimpleArrayReaderStateMachine.java (original)
+++ webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/SimpleArrayReaderStateMachine.java Tue Apr 4 21:47:56 2006
@@ -71,7 +71,7 @@
//test for the nillable attribute
if (currentState==START_ELEMENT_FOUND_STATE &&
nillable){
- if (TRUE.equals(reader.getAttributeValue("",NIL))){
+ if (TRUE.equals(reader.getAttributeValue(XSI_NAMESPACE,NIL))){
list.add(null);
//force the state to be null found
currentState= NULLED_STATE;
Modified: webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/SimpleElementReaderStateMachine.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/SimpleElementReaderStateMachine.java?rev=391484&r1=391483&r2=391484&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/SimpleElementReaderStateMachine.java (original)
+++ webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/SimpleElementReaderStateMachine.java Tue Apr 4 21:47:56 2006
@@ -81,7 +81,7 @@
//test for the nillable attribute
if (currentState==START_ELEMENT_FOUND_STATE &&
nillable){
- if (TRUE.equals(reader.getAttributeValue("",NIL))){
+ if (TRUE.equals(reader.getAttributeValue(XSI_NAMESPACE,NIL))){
text = null;
//force the state to be null found
currentState= NULLED_STATE;
Modified: webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/reader/ADBXMLStreamReaderImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/reader/ADBXMLStreamReaderImpl.java?rev=391484&r1=391483&r2=391484&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/reader/ADBXMLStreamReaderImpl.java (original)
+++ webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/reader/ADBXMLStreamReaderImpl.java Tue Apr 4 21:47:56 2006
@@ -38,11 +38,23 @@
* The common types of name value pairs we'll come across are
* 1. String name/QName name - String value
* 2. String name/QName name - String[] value
- * 3. null - OMElement[] value
+ * 3. OMElementkey - OMElement value
+ * 4. QName name/String name - ADBBean value
+ * 5. QName name/String name - Java bean
+ *
+ * As for the attributes, these are the possible combinations in the
+ * array
+ * 1. String name/QName name - String value
+ * 2. OMAttributeKey - OMAttribute
+ *
+ * Note that certain array methods have been deliberately removed to avoid
+ * complications. The generated code will take the trouble to lay the
+ * elements of the array in the correct order
+ *
* <p/>
* Hence there will be a parser impl that knows how to handle these types, and
* this parent parser will always delegate these tasks to the child pullparasers
- * in effect this is one huge state machine that has only three states and delegates
+ * in effect this is one huge state machine that has only a few states and delegates
* things down to the child parsers whenever possible
* <p/>
* the possible inputs for this class
@@ -840,6 +852,10 @@
}
} else if (propPointer instanceof QName) {
propertyQName = (QName) propPointer;
+ } else if (propPointer instanceof OMElementKey) {
+ // ah - in this case there's nothing to be done
+ //about the propertyQName in this case - we'll just leave
+ //it as it is
} else {
//oops - we've no idea what kind of key this is
throw new XMLStreamException(
Added: webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/reader/OMElementKey.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/reader/OMElementKey.java?rev=391484&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/reader/OMElementKey.java (added)
+++ webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/reader/OMElementKey.java Tue Apr 4 21:47:56 2006
@@ -0,0 +1,23 @@
+package org.apache.axis2.databinding.utils.reader;
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * A dummy class that creates nothing but a key for the
+ * OMElement when it is passed to the ADBPullparser
+ */
+public class OMElementKey {
+}
Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl?rev=391484&r1=391483&r2=391484&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl Tue Apr 4 21:47:56 2006
@@ -237,7 +237,7 @@
<xsl:if test="$min=0 or $choice"> if (<xsl:value-of select="$settingTracker"/>){</xsl:if>
<xsl:choose>
- <xsl:when test="@ours or @default or @array">
+ <xsl:when test="(@ours or @default) and not(@array)">
elementList.add(new javax.xml.namespace.QName("<xsl:value-of select="$namespace"/>",
"<xsl:value-of select="$propertyName"/>"));
<!-- Arraylist can handle null's -->
@@ -254,13 +254,56 @@
</xsl:otherwise>
</xsl:choose>
</xsl:when>
- <!-- handle arrays -->
+ <xsl:when test="(@ours or @default) and @array">
+ <xsl:choose>
+ <xsl:when test="@nillable">
+ // this property is nillable
+ if (<xsl:value-of select="$varName"/>!=null){
+ <!--this barcket needs to be closed!-->
+ </xsl:when>
+ <xsl:otherwise>
+ if (<xsl:value-of select="$varName"/>==null){
+ throw new RuntimeException("<xsl:value-of select="$propertyName"/> cannot be null!!");
+ }
+ </xsl:otherwise>
+ </xsl:choose>
+ for (int i = 0;i < <xsl:value-of select="$varName"/>.length;i++){
+ elementList.add(new javax.xml.namespace.QName("<xsl:value-of select="$namespace"/>",
+ "<xsl:value-of select="$propertyName"/>"));
+ elementList.add(<xsl:value-of select="$varName"/>[i]);
+ }
+ <!--we've opened a bracket for the nulls - fix it here-->
+ <xsl:if test="@nillable">}</xsl:if>
+ </xsl:when>
+ <!-- handle non ADB arrays -->
+ <xsl:when test="@array">
+ <xsl:choose>
+ <xsl:when test="@nillable">
+ // this property is nillable
+ if (<xsl:value-of select="$varName"/>!=null){
+ <!--this barcket needs to be closed!-->
+ </xsl:when>
+ <xsl:otherwise>
+ if (<xsl:value-of select="$varName"/>==null){
+ throw new RuntimeException("<xsl:value-of select="$propertyName"/> cannot be null!!");
+ }
+ </xsl:otherwise>
+ </xsl:choose>
+ for (int i = 0;i < <xsl:value-of select="$varName"/>.length;i++){
+ elementList.add(new javax.xml.namespace.QName("<xsl:value-of select="$namespace"/>",
+ "<xsl:value-of select="$propertyName"/>"));
+ elementList.add(
+ org.apache.axis2.databinding.utils.ConverterUtil.convertToString(<xsl:value-of select="$varName"/>[i]));
+ }
+ <!--we've opened a bracket for the nulls - fix it here-->
+ <xsl:if test="@nillable">}</xsl:if>
+ </xsl:when>
<!-- handle any-->
<xsl:when test="@any">
- <!--todo Not sure whether this is right-->
- elementList.add(null);
+ elementList.add(org.apache.axis2.databinding.utils.Constants.OM_ELEMENT_KEY);
elementList.add(<xsl:value-of select="$varName"/>);
</xsl:when>
+ <!-- the usual case!!!!-->
<xsl:otherwise>
elementList.add(new javax.xml.namespace.QName("<xsl:value-of select="$namespace"/>",
"<xsl:value-of select="$propertyName"/>"));
@@ -342,7 +385,7 @@
org.apache.axis2.databinding.utils.reader.ADBXMLStreamReader.ELEMENT_TEXT,
org.apache.axis2.databinding.utils.ConverterUtil.convertToString(<xsl:value-of select="$varName"/>)
},
- new Object[]{});</xsl:otherwise>
+ null);</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>