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/03/11 11:31:05 UTC

svn commit: r385049 - in /webservices/axis2/trunk/java/modules: adb/src/org/apache/axis2/databinding/utils/ codegen/src/org/apache/axis2/schema/ codegen/src/org/apache/axis2/schema/template/

Author: ajith
Date: Sat Mar 11 02:31:04 2006
New Revision: 385049

URL: http://svn.apache.org/viewcvs?rev=385049&view=rev
Log:
1. Added a NullablePullParser.java that can handle the null values at the element level.
2. Updated the ADBBeanTemplate.xsl and the related classes to support a add method to the any array type. This needs to be extended to other types as well. 
3. Fixed some minor bugs in the SchemaCompiler.java

Added:
    webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/NullablePullParser.java
Modified:
    webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/ConverterUtil.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/BeanWriterMetaInfoHolder.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/SchemaCompiler.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/SchemaConstants.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/ConverterUtil.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/ConverterUtil.java?rev=385049&r1=385048&r2=385049&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/ConverterUtil.java (original)
+++ webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/ConverterUtil.java Sat Mar 11 02:31:04 2006
@@ -685,4 +685,21 @@
         return returnArray;
     }
 
+    /**
+     * 
+     * @param array
+     * @return
+     */
+    public static List toList(Object[] array){
+        if (array==null){
+            return new ArrayList();
+        }else{
+            ArrayList list =  new ArrayList();
+            for (int i = 0; i < array.length; i++) {
+                list.add(array[i]);
+            }
+            return list;
+        }
+    }
+
 }

Added: webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/NullablePullParser.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/NullablePullParser.java?rev=385049&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/NullablePullParser.java (added)
+++ webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/NullablePullParser.java Sat Mar 11 02:31:04 2006
@@ -0,0 +1,264 @@
+package org.apache.axis2.databinding.utils;
+
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.Location;
+import javax.xml.namespace.QName;
+import javax.xml.namespace.NamespaceContext;
+/*
+ * 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.
+ */
+
+public class NullablePullParser implements XMLStreamReader {
+
+    private QName outerQName = null;
+
+    private static final int INIT_STATE = 0;
+    private static final int START_ELEMENT_STATE = 1;
+    private static final int END_ELEMENT_STATE = 2;
+    private static final int FINISHED_STATE = 3;
+
+    private static final QName NIL_QNAME = new QName("http://www.w3.org/2001/XMLSchema-instance","nil","xsi");
+    private static final String NIL_VALUE_TRUE ="true";
+
+    private int currentState = INIT_STATE;
+
+    public NullablePullParser(QName outerQName) {
+        this.outerQName = outerQName;
+    }
+
+    public Object getProperty(String string) throws IllegalArgumentException {
+        throw new UnsupportedOperationException();
+    }
+
+    public int next() throws XMLStreamException {
+        int returnEvent = START_DOCUMENT;
+        switch(currentState){
+            case INIT_STATE:
+                currentState = START_ELEMENT_STATE;
+                returnEvent =  START_ELEMENT;
+                break;
+            case START_ELEMENT_STATE:
+                currentState = END_ELEMENT_STATE;
+                returnEvent =  END_ELEMENT;
+                break;
+            case END_ELEMENT_STATE:
+                currentState = FINISHED_STATE;
+                returnEvent =  END_DOCUMENT;
+                break;
+            case FINISHED_STATE:
+                throw new XMLStreamException("parser completed!");
+        }
+
+        return returnEvent;
+    }
+
+    public void require(int i, String string, String string1) throws XMLStreamException {
+        //nothing
+    }
+
+    public String getElementText() throws XMLStreamException {
+        return null;
+    }
+
+    public int nextTag() throws XMLStreamException {
+        throw new UnsupportedOperationException();
+    }
+
+    public boolean hasNext() throws XMLStreamException {
+        return (currentState!=END_ELEMENT_STATE);
+
+    }
+
+    public void close() throws XMLStreamException {
+        //do nothing
+    }
+
+    public String getNamespaceURI(String string) {
+        if (outerQName.getPrefix()!=null &&
+                outerQName.getPrefix().equals(string)){
+            return outerQName.getNamespaceURI();
+        }else{
+            return null;
+        }
+    }
+
+    public boolean isStartElement() {
+        return (currentState==START_ELEMENT_STATE);
+    }
+
+    public boolean isEndElement() {
+        return (currentState==END_ELEMENT_STATE);
+    }
+
+    public boolean isCharacters() {
+        return false;
+    }
+
+    public boolean isWhiteSpace() {
+        return false;
+    }
+
+    public String getAttributeValue(String string, String string1) {
+        if (string== null){//null namespace - ignore it
+            if (NIL_QNAME.getLocalPart().equals(string1)){
+                return NIL_VALUE_TRUE;
+            }
+        }
+        return null;
+    }
+
+    public int getAttributeCount() {
+        return 1;
+    }
+
+    public QName getAttributeName(int i) {
+        return (i==1)? NIL_QNAME:null;
+    }
+
+    public String getAttributeNamespace(int i) {
+        return (i==1)? NIL_QNAME.getNamespaceURI():null;
+    }
+
+    public String getAttributeLocalName(int i) {
+        return (i==1)? NIL_QNAME.getLocalPart():null;
+    }
+
+    public String getAttributePrefix(int i) {
+        return (i==1)? NIL_QNAME.getPrefix():null;
+    }
+
+    public String getAttributeType(int i) {
+        throw new UnsupportedOperationException();
+    }
+
+    public String getAttributeValue(int i) {
+        return (i==1)? NIL_VALUE_TRUE:null;
+    }
+
+    public boolean isAttributeSpecified(int i) {
+        return (i == 1);
+    }
+
+    public int getNamespaceCount() {
+        return 0;
+    }
+
+    public String getNamespacePrefix(int i) {
+        return null;
+    }
+
+    public String getNamespaceURI(int i) {
+        return null;
+    }
+
+    public NamespaceContext getNamespaceContext() {
+        throw new UnsupportedOperationException();
+    }
+
+    public int getEventType() {
+        int returnEvent = START_DOCUMENT;
+        switch(currentState){
+            case INIT_STATE:
+                returnEvent =  START_DOCUMENT;
+                break;
+            case START_ELEMENT_STATE:
+                returnEvent =  START_ELEMENT;
+                break;
+            case END_ELEMENT_STATE:
+                returnEvent =  END_ELEMENT;
+                break;
+            case FINISHED_STATE:
+               returnEvent = END_DOCUMENT;
+        }
+       return returnEvent;
+    }
+
+    public String getText() {
+        return null;
+    }
+
+    public char[] getTextCharacters() {
+        return new char[0];  //To change body of implemented methods use File | Settings | File Templates.
+    }
+
+    public int getTextCharacters(int i, char[] chars, int i1, int i2) throws XMLStreamException {
+        return 0;
+    }
+
+    public int getTextStart() {
+        return 0;
+    }
+
+    public int getTextLength() {
+        return 0;
+    }
+
+    public String getEncoding() {
+        return null;
+    }
+
+    public boolean hasText() {
+        return false;
+    }
+
+    public Location getLocation() {
+        throw new UnsupportedOperationException();
+    }
+
+    public QName getName() {
+        return outerQName;
+    }
+
+    public String getLocalName() {
+        return outerQName.getLocalPart();
+    }
+
+    public boolean hasName() {
+        return true;
+    }
+
+    public String getNamespaceURI() {
+        return outerQName.getNamespaceURI();
+    }
+
+    public String getPrefix() {
+        return outerQName.getPrefix();
+    }
+
+    public String getVersion() {
+        throw new UnsupportedOperationException();
+    }
+
+    public boolean isStandalone() {
+        throw new UnsupportedOperationException();
+    }
+
+    public boolean standaloneSet() {
+        throw new UnsupportedOperationException();
+    }
+
+    public String getCharacterEncodingScheme() {
+        throw new UnsupportedOperationException();
+    }
+
+    public String getPITarget() {
+        throw new UnsupportedOperationException();
+    }
+
+    public String getPIData() {
+        throw new UnsupportedOperationException();
+    }
+}

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/BeanWriterMetaInfoHolder.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/BeanWriterMetaInfoHolder.java?rev=385049&r1=385048&r2=385049&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/BeanWriterMetaInfoHolder.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/BeanWriterMetaInfoHolder.java Sat Mar 11 02:31:04 2006
@@ -221,7 +221,8 @@
      */
     public boolean getAttributeStatusForQName(QName qName) {
         Integer attribState = (Integer) specialTypeFlagMap.get(qName);
-        return attribState != null && attribState.equals(SchemaConstants.ATTRIBUTE_TYPE);
+        return attribState != null && (attribState.equals(SchemaConstants.ATTRIBUTE_TYPE)
+                || attribState.equals(SchemaConstants.ANY_ATTRIBUTE_TYPE));
     }
 
     /**
@@ -242,8 +243,10 @@
      * @return Returns boolean.
      */
     public boolean getArrayStatusForQName(QName qName) {
-        Integer anyState = (Integer) specialTypeFlagMap.get(qName);
-        return anyState != null && anyState.equals(SchemaConstants.ANY_ARRAY_TYPE);
+        Integer state = (Integer) specialTypeFlagMap.get(qName);
+        return state != null && (
+                state.equals(SchemaConstants.ARRAY_TYPE) ||
+                state.equals(SchemaConstants.ANY_ARRAY_TYPE));
     }
 
     /**
@@ -254,7 +257,8 @@
      */
     public boolean getAnyAttributeStatusForQName(QName qName) {
         Integer anyState = (Integer) specialTypeFlagMap.get(qName);
-        return anyState != null && anyState.equals(SchemaConstants.ANY_ATTRIBUTE_TYPE);
+        return anyState != null &&
+                anyState.equals(SchemaConstants.ANY_ATTRIBUTE_TYPE);
     }
 
     /**

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/SchemaCompiler.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/SchemaCompiler.java?rev=385049&r1=385048&r2=385049&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/SchemaCompiler.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/SchemaCompiler.java Sat Mar 11 02:31:04 2006
@@ -4,6 +4,7 @@
 import org.apache.axis2.schema.util.SchemaPropertyLoader;
 import org.apache.axis2.schema.writer.BeanWriter;
 import org.apache.ws.commons.om.OMElement;
+import org.apache.ws.commons.om.OMAttribute;
 import org.apache.ws.commons.schema.XmlSchema;
 import org.apache.ws.commons.schema.XmlSchemaAll;
 import org.apache.ws.commons.schema.XmlSchemaAny;
@@ -99,6 +100,8 @@
     public static final String DEFAULT_CLASS_NAME = OMElement.class.getName();
     public static final String DEFAULT_CLASS_ARRAY_NAME = "org.apache.ws.commons.om.OMElement[]";
 
+    public static final String DEFAULT_ATTRIB_CLASS_NAME = OMAttribute.class.getName();
+    public static final String DEFAULT_ATTRIB_ARRAY_CLASS_NAME = "org.apache.ws.commons.om.OMAttribute[]";
 
 
 
@@ -545,7 +548,7 @@
         //somehow the xml schema parser does not seem to pickup the any attribute!!
         XmlSchemaAnyAttribute anyAtt = complexType.getAnyAttribute();
         if (anyAtt != null) {
-            processAnyAttribute(metaInfHolder);
+            processAnyAttribute(metaInfHolder,anyAtt);
         }
 
         //process content ,either  complex or simple
@@ -704,12 +707,14 @@
      * Handle any attribute
      * @param metainf
      */
-    private void processAnyAttribute(BeanWriterMetaInfoHolder metainf) {
+    private void processAnyAttribute(BeanWriterMetaInfoHolder metainf,XmlSchemaAnyAttribute anyAtt) {
 
         //The best thing we can do here is to add a set of OMAttributes
+        //since attributes do not have the notion of minoccurs/maxoccurs the
+        //safest option here is to have an OMAttribute array
         metainf.registerMapping(new QName(EXTRA_ATTRIBUTE_FIELD_NAME),
                 null,
-                OMElement[].class.getName(),
+                DEFAULT_ATTRIB_ARRAY_CLASS_NAME,
                 SchemaConstants.ANY_ATTRIBUTE_TYPE);
 
     }
@@ -792,15 +797,16 @@
                     elementOrderMap.put(xsElt, new Integer(i));
                 }
 
-                //handle xsd:any ! We place an OMElement in the generated class
+                //handle xsd:any ! We place an OMElement (or an array of OMElements) in the generated class
             } else if (item instanceof XmlSchemaAny) {
                 XmlSchemaAny any = (XmlSchemaAny) item;
-                processAny(any, processedElementTypeMap);
+                processedElementTypeMap.put(new QName(ANY_ELEMENT_FIELD_NAME),any);
                 //any can also be inside a sequence
                 if (order) {
                     elementOrderMap.put(any, new Integer(i));
                 }
-                processedElementArrayStatusMap.put(any, Boolean.FALSE);
+                //we do not register the array status for the any type
+                processedElementArrayStatusMap.put(any,isArray(any) ? Boolean.TRUE : Boolean.FALSE);
             } else {
                 //there may be other types to be handled here. Add them
                 //when we are ready
@@ -828,7 +834,7 @@
                             elt.getSchemaTypeName()
                             , clazzName,
                             ((Boolean) processedElementArrayStatusMap.get(elt)).booleanValue() ?
-                                    SchemaConstants.ANY_ARRAY_TYPE :
+                                    SchemaConstants.ARRAY_TYPE :
                                     SchemaConstants.ELEMENT_TYPE);
                 }else{ //probably this is referenced
                     clazzName = (String)processedElementRefMap.get(elt.getRefName());
@@ -837,7 +843,7 @@
                             parentSchema.getElementByName(elt.getRefName()).getSchemaTypeName()
                             , clazzName,
                             ((Boolean) processedElementArrayStatusMap.get(elt)).booleanValue() ?
-                                    SchemaConstants.ANY_ARRAY_TYPE :
+                                    SchemaConstants.ARRAY_TYPE :
                                     SchemaConstants.ELEMENT_TYPE);
                 }
 
@@ -867,12 +873,17 @@
                 //for the constant. However the problem occurs if the users
                 //uses the same name for an element decalration
                 QName anyElementFieldName = new QName(ANY_ELEMENT_FIELD_NAME);
+
+                //this can be an array or a single element
+                boolean isArray =  ((Boolean) processedElementArrayStatusMap.get(any)).booleanValue();
                 metainfHolder.registerMapping(anyElementFieldName,
                         null,
-                        DEFAULT_CLASS_NAME,
-                        SchemaConstants.ANY);
+                        isArray?DEFAULT_CLASS_ARRAY_NAME:DEFAULT_CLASS_NAME,
+                        isArray?SchemaConstants.ANY_ARRAY_TYPE:SchemaConstants.ANY);
+
                 metainfHolder.addMaxOccurs(anyElementFieldName,any.getMaxOccurs());
                 metainfHolder.addMinOccurs(anyElementFieldName,any.getMinOccurs());
+
                 if (order) {
                     //record the order in the metainf holder for the any
                     Integer integer = (Integer) elementOrderMap.get(any);
@@ -888,16 +899,6 @@
 
         //set the ordered flag in the metainf holder
         metainfHolder.setOrdered(order);
-    }
-
-    /**
-     * process the 'any'
-     *
-     * @param any
-     * @param metainf
-     */
-    private void processAny(XmlSchemaAny any, Map processedElementTypeMap) {
-        processedElementTypeMap.put(new QName(ANY_ELEMENT_FIELD_NAME),any);
     }
 
     /**

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/SchemaConstants.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/SchemaConstants.java?rev=385049&r1=385048&r2=385049&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/SchemaConstants.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/SchemaConstants.java Sat Mar 11 02:31:04 2006
@@ -84,8 +84,9 @@
     public static final Integer ANY = new Integer(1);
     public static final Integer ELEMENT_TYPE = new Integer(2);
     public static final Integer ANY_ATTRIBUTE_TYPE = new Integer(3);
-    public static final Integer ANY_ARRAY_TYPE = new Integer(4);
+    public static final Integer ARRAY_TYPE = new Integer(4);
     public static final Integer ANY_TYPE = new Integer(5);
+    public static final Integer ANY_ARRAY_TYPE = new Integer(6);
 
 
     public static class SchemaPropertyNames{

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=385049&r1=385048&r2=385049&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 Sat Mar 11 02:31:04 2006
@@ -81,9 +81,11 @@
         <xsl:for-each select="property">
             <!-- Write only the NOT inherited properties-->
             <xsl:if test="not(@inherited)">
+
             <xsl:variable name="propertyType"><xsl:value-of select="@type"></xsl:value-of></xsl:variable>
             <xsl:variable name="propertyName"><xsl:value-of select="@name"></xsl:value-of></xsl:variable>
             <xsl:variable name="javaName"><xsl:value-of select="@javaname"></xsl:value-of></xsl:variable>
+
             <xsl:variable name="min"><xsl:value-of select="@minOccurs"/></xsl:variable>
             <xsl:variable name="varName">local<xsl:value-of select="$javaName"/></xsl:variable>
             <xsl:variable name="settingTracker">local<xsl:value-of select="$javaName"/>Tracker</xsl:variable>
@@ -94,56 +96,121 @@
             <xsl:if test="@attribute">* This was an Attribute!</xsl:if>
             <xsl:if test="@array">* This was an Array!</xsl:if>
             */
+
             protected <xsl:value-of select="$propertyType"/><xsl:text> </xsl:text><xsl:value-of select="$varName" /> ;
-            <!-- Generate a tracker only if the min occurs is zero, which means if the user does
-                 not bother to set that value, we do not send it -->
-            <xsl:if test="$min=0 or $choice">
-            /*  This tracker boolean wil be used to detect whether the user called the set method
-                for this attribute. It will be used to determine whether to include this field
-                in the serialized XML
-            */
-            protected boolean <xsl:value-of select="$settingTracker"/> = false ;
-            </xsl:if>
+           <!-- Generate a tracker only if the min occurs is zero, which means if the user does
+                not bother to set that value, we do not send it -->
+           <xsl:if test="$min=0 or $choice">
+           /*  This tracker boolean wil be used to detect whether the user called the set method
+               for this attribute. It will be used to determine whether to include this field
+               in the serialized XML
+           */
+           protected boolean <xsl:value-of select="$settingTracker"/> = false ;
+           </xsl:if>
+
+           /**
+           * Auto generated getter method
+           * @return <xsl:value-of select="$propertyType"/>
+           */
+           public  <xsl:value-of select="$propertyType"/><xsl:text> </xsl:text>get<xsl:value-of select="$javaName"/>(){
+               return <xsl:value-of select="$varName"/>;
+           }
+
+           <!-- When generating the setters, we have to cater differently for the array!-->
+            <xsl:choose>
+               <xsl:when test="@array">
+                   <xsl:variable name="basePropertyType"><xsl:value-of select="@arrayBaseType"/></xsl:variable>
+
+
+                   <!-- generate the validator Method-->
+                  /**
+                   * validate the array for <xsl:value-of select="$javaName"/>
+                   */
+                  protected void validate<xsl:value-of select="$javaName"/>(<xsl:value-of select="$propertyType"/> param){
+                     <xsl:if test="not(@unbound)">
+                          if (param.length &gt; <xsl:value-of select="@maxOccurs"/>){
+                            throw new java.lang.RuntimeException();
+                          }
+                      </xsl:if>
+                      <xsl:if test="@minOccurs">
+                          if (param.length &lt; <xsl:value-of select="@minOccurs"/>){
+                            throw new java.lang.RuntimeException();
+                          }
+                      </xsl:if>
+                  }
+
+
+                 /**
+                  * Auto generated setter method
+                  * @param param <xsl:value-of select="$javaName"/>
+                  */
+                  public void set<xsl:value-of select="$javaName"/>(<xsl:value-of select="$propertyType"/> param){
+                   <!-- call the validator-->
+                   validate<xsl:value-of select="$javaName"/>(param);
+
+                   <xsl:if test="$choice">
+                       clearAllSettingTrackers();
+                   </xsl:if>
+                   <xsl:if test="$min=0 or $choice">
+                   //update the setting tracker
+                   <xsl:value-of select="$settingTracker"/> = true;
+                   </xsl:if>
+                  this.<xsl:value-of select="$varName"/>=param;
+                  }
+
+                   <!-- we special case the 'any' scenario and generate a convenience
+                       method for adding elements one by one to the array. The
+                       current implementation is somewhat in-efficient but
+                       gets the job done-->
+                 <xsl:if test="@any">
+                 /**
+                 * Auto generated add method for the array for convenience
+                 * @param param <xsl:value-of select="$basePropertyType"/>
+                 */
+                 public void add<xsl:value-of select="$javaName"/>(<xsl:value-of select="$basePropertyType"/> param){
+                   if (<xsl:value-of select="$varName"/> == null){
+                       <xsl:value-of select="$varName"/> = new <xsl:value-of select="$propertyType"/>{};
+                   }
+                   java.util.List list =
+                        org.apache.axis2.databinding.utils.ConverterUtil.toList(<xsl:value-of select="$varName"/>);
+                   list.add(param);
+                   this.<xsl:value-of select="$varName"/> =
+                     (<xsl:value-of select="$propertyType"/>)list.toArray(
+                        new <xsl:value-of select="$basePropertyType"/>[list.size()]);
+
+                 }
+                     <!-- end of special casing for any-->
+                 </xsl:if>
+               </xsl:when>
+                <!-- Non array setter method-->
+                <xsl:otherwise>
+                    /**
+                   * Auto generated setter method
+                   * @param param <xsl:value-of select="$javaName"/>
+                   */
+                   public void set<xsl:value-of select="$javaName"/>(<xsl:value-of select="$propertyType"/> param){
+                    <xsl:if test="$choice">
+                        clearAllSettingTrackers();
+                    </xsl:if>
+                    <xsl:if test="$min=0 or $choice">
+                    //update the setting tracker
+                    <xsl:value-of select="$settingTracker"/> = true;
+                    </xsl:if>
+                   this.<xsl:value-of select="$varName"/>=param;
+                   }
 
-            /**
-            * Auto generated getter method
-            * @return <xsl:value-of select="$propertyType"/>
-            */
-            public  <xsl:value-of select="$propertyType"/><xsl:text> </xsl:text>get<xsl:value-of select="$javaName"/>(){
-                return <xsl:value-of select="$varName"/>;
-            }
 
-            /**
-            * Auto generated setter method
-            * @param param <xsl:value-of select="$javaName"/>
-            */
-            public void set<xsl:value-of select="$javaName"/>(<xsl:value-of select="$propertyType"/> param){
-            <!--Add the validation code. For now we only add the validation code for arrays-->
-            <xsl:if test="@array">
-                <xsl:if test="not(@unbound)">
-                    if (param.length &gt; <xsl:value-of select="@maxOccurs"></xsl:value-of>){
-                     throw new java.lang.RuntimeException();
-                    }
-                </xsl:if>
-                <xsl:if test="@minOccurs">
-                    if (param.length &lt; <xsl:value-of select="@minOccurs"></xsl:value-of>){
-                     throw new java.lang.RuntimeException();
-                    }
-                </xsl:if>
-            </xsl:if>
 
-             <xsl:if test="$choice">
-                 clearAllSettingTrackers();
-             </xsl:if>
-             <xsl:if test="$min=0 or $choice">
-             //update the setting tracker
-             <xsl:value-of select="$settingTracker"/> = true;
-             </xsl:if>
-            this.<xsl:value-of select="$varName"/>=param;
-            }
+
+                </xsl:otherwise>
+            </xsl:choose>
+
 
              <!-- end of xsl:if for not(@inherited) -->
             </xsl:if>
+
+
+
         </xsl:for-each>
 
         /**
@@ -185,6 +252,7 @@
                                 </xsl:otherwise>
                             </xsl:choose>
                         </xsl:when>
+                        <!-- handle arrays -->
                         <!-- handle any-->
                          <xsl:when test="@any">
                              <!--todo Not sure whether this is right-->
@@ -232,21 +300,46 @@
             <xsl:otherwise>
                 <!-- if the element is associated with a type, then its gonna be only one -->
                 //We can safely assume an element has only one type associated with it
+                <xsl:variable name="varName">local<xsl:value-of select="property/@javaname"/></xsl:variable>
+                <xsl:variable name="nillable"><xsl:value-of select="property/@nillable"/></xsl:variable>
+                <xsl:variable name="primitive"><xsl:value-of select="property/@primitive"/></xsl:variable>
 
                 <xsl:choose>
                     <!-- This better be only one!!-->
                     <xsl:when test="property/@ours">
-                        <xsl:variable name="varName">local<xsl:value-of select="property/@javaname"/></xsl:variable>
-                        return <xsl:value-of select="$varName"/>.getPullParser(MY_QNAME);
+
+                        <xsl:choose>
+                            <xsl:when test="$nillable">
+                                if (<xsl:value-of select="$varName"/>==null){
+                                   return new org.apache.axis2.databinding.utils.NullablePullParser(MY_QNAME);
+                                }else{
+                                   return <xsl:value-of select="$varName"/>.getPullParser(MY_QNAME);
+                                }
+                            </xsl:when>
+                            <xsl:otherwise>return <xsl:value-of select="$varName"/>.getPullParser(MY_QNAME);</xsl:otherwise>
+                        </xsl:choose>
                     </xsl:when>
                     <xsl:otherwise>
-                        <xsl:variable name="varName">local<xsl:value-of select="property/@javaname"/></xsl:variable>
-                        return org.apache.axis2.databinding.utils.ADBPullParser.createPullParser(MY_QNAME,
+                        <xsl:choose>
+                            <xsl:when test="$nillable and not($primitive)">
+                                if (<xsl:value-of select="$varName"/>==null){
+                                      return new org.apache.axis2.databinding.utils.NullablePullParser(MY_QNAME);
+                                }else{
+                                   return org.apache.axis2.databinding.utils.ADBPullParser.createPullParser(MY_QNAME,
+                                       new Object[]{
+                                       org.apache.axis2.databinding.utils.ADBPullParser.ELEMENT_TEXT,
+                                       org.apache.axis2.databinding.utils.ConverterUtil.convertToString(<xsl:value-of select="$varName"/>)
+                                       },
+                                       new Object[]{});
+                                }
+                            </xsl:when>
+                            <xsl:otherwise> return org.apache.axis2.databinding.utils.ADBPullParser.createPullParser(MY_QNAME,
                             new Object[]{
                             org.apache.axis2.databinding.utils.ADBPullParser.ELEMENT_TEXT,
                             org.apache.axis2.databinding.utils.ConverterUtil.convertToString(<xsl:value-of select="$varName"/>)
                             },
-                            new Object[]{});
+                            new Object[]{});</xsl:otherwise>
+                        </xsl:choose>
                     </xsl:otherwise>
                 </xsl:choose>
             </xsl:otherwise>