ws-axis-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ami...@apache.org
Subject svn commit: r585400 - in /webservices/axis2/trunk/java/modules/adb-codegen: ./ src/org/apache/axis2/schema/ src/org/apache/axis2/schema/template/ src/org/apache/axis2/schema/writer/
Date Wed, 17 Oct 2007 07:03:55 GMT
Author: amilas
Date: Wed Oct 17 00:03:49 2007
New Revision: 585400

URL: http://svn.apache.org/viewvc?rev=585400&view=rev
Log:
added the default value support to ADB

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/template/ADBBeanTemplate.xsl
    webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/writer/JavaBeanWriter.java
    webservices/axis2/trunk/java/modules/adb-codegen/sub-build.xml

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=585400&r1=585399&r2=585400&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
Wed Oct 17 00:03:49 2007
@@ -64,6 +64,8 @@
     protected Map xmlNameJavaNameMap = new HashMap();
     protected List memberTypesKeys = new ArrayList();
 
+    protected Map elementQNameToDefulatValueMap = new HashMap();
+
     protected QName itemTypeQName;
     protected String itemTypeClassName;
     protected boolean isUnion;
@@ -312,6 +314,34 @@
     }
 
     /**
+     * this method registers the defult value agaist the element qname.
+     * @param qname
+     * @param value
+     */
+    public void registerDefaultValue(QName qname,String value){
+        this.elementQNameToDefulatValueMap.put(qname,value);
+    }
+
+    /**
+     *
+     * @param qname
+     * @return is a default value available for this qname
+     */
+    public boolean isDefaultValueAvailable(QName qname){
+        return this.elementQNameToDefulatValueMap.containsKey(qname);
+    }
+
+    /**
+     * gets the default value for qname
+     * @param qname
+     * @return default value for this qname
+     */
+
+    public String getDefaultValueForQName(QName qname){
+        return (String) this.elementQNameToDefulatValueMap.get(qname);
+    }
+
+    /**
      * Gets the schema name for the given QName.
      *
      * @param eltQName
@@ -466,6 +496,7 @@
         this.qNameMaxOccursCountMap.clear();
         this.qNameMinOccursCountMap.clear();
         this.qNameOrderMap.clear();
+        this.elementQNameToDefulatValueMap.clear();
     }
 
     /**

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=585400&r1=585399&r2=585400&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
Wed Oct 17 00:03:49 2007
@@ -421,6 +421,12 @@
                         qName,
                         className);
             }
+
+            // register the default value if present
+            if (xsElt.getDefaultValue() != null){
+                metainf.registerDefaultValue(xsElt.getQName(),xsElt.getDefaultValue());
+            }
+
             if (isBinary(xsElt)) {
                 metainf.addtStatus(xsElt.getQName(),
                             SchemaConstants.BINARY_TYPE);
@@ -1613,6 +1619,10 @@
                     att.addMetaInfo(
                             SchemaConstants.SchemaCompilerInfoHolder.CLASSNAME_KEY,
                             className);
+                    // set the default value
+                    if (att.getDefaultValue() != null){
+                        metainf.registerDefaultValue(att.getQName(),att.getDefaultValue());
+                    }
                     // after
                 } else {
                     XmlSchemaType type = getType(parentSchema, schemaTypeName);
@@ -2022,6 +2032,11 @@
                         if (innerChoiceElementList.contains(referencedQName)){
                             metainfHolder.addtStatus(referencedQName,SchemaConstants.INNER_CHOICE_ELEMENT);
                         }
+                        // register the default value as well
+                        if (elt.getDefaultValue() != null){
+                           metainfHolder.registerDefaultValue(referencedQName,elt.getDefaultValue());
+                        }
+
                     }
                 }
 

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=585400&r1=585399&r2=585400&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
Wed Oct 17 00:03:49 2007
@@ -262,7 +262,17 @@
                         */
 
                         <xsl:if test="not(@inherited)">
-                            protected <xsl:value-of select="$propertyType"/><xsl:text>
</xsl:text><xsl:value-of select="$varName" /> ;
+                            <xsl:choose>
+                                <xsl:when test="@defaultValue">
+                                    protected <xsl:value-of select="$propertyType"/><xsl:text>
</xsl:text><xsl:value-of select="$varName" /> =
+                                    org.apache.axis2.databinding.utils.ConverterUtil.convertTo<xsl:value-of
select="$shortTypeName"/>("<xsl:value-of
+                                        select="@defaultValue"/>");
+                                </xsl:when>
+                                <xsl:otherwise>
+                                    protected <xsl:value-of select="$propertyType"/><xsl:text>
</xsl:text><xsl:value-of select="$varName" /> ;
+                                </xsl:otherwise>
+                            </xsl:choose>
+
                         </xsl:if>
                         <xsl:if test="enumFacet">
                             private static java.util.HashMap _table_ = new java.util.HashMap();

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=585400&r1=585399&r2=585400&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
Wed Oct 17 00:03:49 2007
@@ -713,6 +713,7 @@
                 javaClassNameForElement = metainf.getClassNameForQName(name);
             }
 
+
             if (javaClassNameForElement == null) {
                 javaClassNameForElement = getDefaultClassName();
                 log.warn(SchemaCompilerMessages
@@ -728,6 +729,15 @@
 
             if (PrimitiveTypeFinder.isPrimitive(javaClassNameForElement)) {
                 XSLTUtils.addAttribute(model, "primitive", "yes", property);
+            }
+
+             // add the default value
+            if (metainf.isDefaultValueAvailable(name)){
+                QName schemaQName = metainf.getSchemaQNameForQName(name);
+                if (baseTypeMap.containsKey(schemaQName)){
+                    XSLTUtils.addAttribute(model, "defaultValue",
+                            metainf.getDefaultValueForQName(name), property);
+                }
             }
 
             //in the case the original element is an array but the derived one is not.

Modified: webservices/axis2/trunk/java/modules/adb-codegen/sub-build.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb-codegen/sub-build.xml?rev=585400&r1=585399&r2=585400&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/adb-codegen/sub-build.xml (original)
+++ webservices/axis2/trunk/java/modules/adb-codegen/sub-build.xml Wed Oct 17 00:03:49 2007
@@ -378,6 +378,14 @@
 			<arg file="${testsuite.source.dir}/union2.xsd"/>
 			<arg file="${schema.generated.src.dir}"/>
 		</java>
+        <echo>Compiling default_value.xsd</echo>
+		<java classname="org.apache.axis2.schema.XSD2Java" fork="true">
+			<jvmarg line="${maven.junit.jvmargs}"/>
+			<classpath refid="maven.dependency.classpath"/>
+			<classpath location="${compiled.classes.dir}"/>
+			<arg file="${testsuite.source.dir}/default_value.xsd"/>
+			<arg file="${schema.generated.src.dir}"/>
+		</java>
     </target>
 
 </project>



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org


Mime
View raw message