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/05/31 13:35:36 UTC
svn commit: r410497 [3/6] - in /webservices/axis2/trunk/java/modules:
adb-codegen/ adb-codegen/src/ adb-codegen/src/org/
adb-codegen/src/org/apache/ adb-codegen/src/org/apache/axis2/
adb-codegen/src/org/apache/axis2/schema/ adb-codegen/src/org/apache/a...
Added: 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=410497&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl (added)
+++ webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl Wed May 31 04:35:30 2006
@@ -0,0 +1,815 @@
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+ <xsl:output method="text"/>
+
+ <!-- cater for the multiple classes - wrappped mode -->
+ <xsl:template match="/beans">
+ <xsl:variable name="name"><xsl:value-of select="@name"/></xsl:variable>
+ /**
+ * <xsl:value-of select="$name"/>.java
+ *
+ * This file was auto-generated from WSDL
+ * by the Apache Axis2 version: #axisVersion# #today#
+ */
+
+ package <xsl:value-of select="@package"/>;
+
+ /**
+ * <xsl:value-of select="$name"/> wrapped bean classes
+ */
+ public class <xsl:value-of select="$name"/>{
+
+ <xsl:apply-templates/>
+
+ }
+ </xsl:template>
+
+ <!--cater for the multiple classes - unwrappped mode -->
+ <xsl:template match="/">
+ <xsl:apply-templates/>
+ </xsl:template>
+
+ <!-- this is the common template -->
+ <xsl:template match="bean">
+
+ <xsl:variable name="name"><xsl:value-of select="@name"/></xsl:variable>
+ <xsl:variable name="choice" select="@choice"/>
+ <xsl:variable name="ordered" select="@ordered"/>
+ <xsl:variable name="unordered" select="not($ordered)"/> <!-- for convenience -->
+ <xsl:variable name="isType" select="@type"/>
+ <xsl:variable name="anon" select="@anon"/>
+ <!-- write the class header. this should be done only when unwrapped -->
+
+ <xsl:if test="not(not(@unwrapped) or (@skip-write))">
+ /**
+ * <xsl:value-of select="$name"/>.java
+ *
+ * This file was auto-generated from WSDL
+ * by the Apache Axis2 version: #axisVersion# #today#
+ */
+
+ package <xsl:value-of select="@package"/>;
+ /**
+ * <xsl:value-of select="$name"/> bean class
+ */
+ </xsl:if>
+ public <xsl:if test="not(@unwrapped) or (@skip-write)">static</xsl:if> class <xsl:value-of select="$name"/> <xsl:if test="@extension"> extends <xsl:value-of select="@extension"/></xsl:if>
+ implements org.apache.axis2.databinding.ADBBean{
+ <xsl:choose>
+ <xsl:when test="@type">/* This type was generated from the piece of schema that had
+ name = <xsl:value-of select="@originalName"/>
+ Namespace URI = <xsl:value-of select="@nsuri"/>
+ Namespace Prefix = <xsl:value-of select="@nsprefix"/>
+ */
+ </xsl:when>
+ <xsl:otherwise>
+ public static final javax.xml.namespace.QName MY_QNAME = new javax.xml.namespace.QName(
+ "<xsl:value-of select="@nsuri"/>",
+ "<xsl:value-of select="@originalName"/>",
+ "<xsl:value-of select="@nsprefix"/>");
+
+ </xsl:otherwise>
+ </xsl:choose>
+
+ <xsl:if test="$choice">
+ /** Whenever a new property is set ensure all others are unset
+ * There can be only one choice and the last one wins
+ */
+ private void clearAllSettingTrackers() {
+ <xsl:for-each select="property">
+ local<xsl:value-of select="@javaname"/>Tracker = false;
+ </xsl:for-each>
+ }
+ </xsl:if>
+
+
+ <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>
+
+
+ /**
+ * field for <xsl:value-of select="$javaName"/>
+ <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>
+
+ /**
+ * 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, this is specifiacally for validating the arrays-->
+ /**
+ * 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 > <xsl:value-of select="@maxOccurs"/>){
+ throw new java.lang.RuntimeException();
+ }
+ </xsl:if>
+ <xsl:if test="$min!=0">
+ if (param.length < <xsl:value-of select="$min"/>){
+ 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">
+ <!-- the updating of setting tracker for null values should
+ happen if the attribute is marked as nillable. Else
+ the user can set a null value and it is never marked
+ as set
+ -->
+ <xsl:choose>
+ <xsl:when test="not(@nillable) and not(@primitive)">
+ if (param !=null){
+ //update the setting tracker
+ <xsl:value-of select="$settingTracker"/> = true;
+ }
+ </xsl:when>
+ <xsl:otherwise>
+ //update the setting tracker
+ <xsl:value-of select="$settingTracker"/> = true;
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:if>
+ this.<xsl:value-of select="$varName"/>=param;
+ }
+
+ <!-- we special case the 'array' scenario and generate a convenience
+ method for adding elements one by one to the array. The
+ current implementation is somewhat inefficient but
+ gets the job done.Since a primitive cannot be
+ treated as an object it has to be ignored!
+
+ -->
+ <xsl:if test="not(@primitive)">
+ /**
+ * 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"/>{};
+ }
+
+ <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>
+
+ 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()]);
+
+ }
+ </xsl:if>
+ <!-- end of special casing for the array-->
+
+ </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;
+ }
+ </xsl:otherwise>
+ </xsl:choose>
+
+
+ <!-- end of xsl:if for not(@inherited) -->
+ </xsl:if>
+
+
+
+ </xsl:for-each>
+
+ /**
+ * databinding method to get an XML representation of this object
+ *
+ */
+ public javax.xml.stream.XMLStreamReader getPullParser(javax.xml.namespace.QName qName){
+
+
+ <xsl:choose>
+ <xsl:when test="@type or @anon">
+ java.util.ArrayList elementList = new java.util.ArrayList();
+ java.util.ArrayList attribList = new java.util.ArrayList();
+
+ <xsl:for-each select="property[not(@attribute)]">
+ <xsl:variable name="propertyName"><xsl:value-of select="@name"/></xsl:variable>
+ <xsl:variable name="varName">local<xsl:value-of select="@javaname"/></xsl:variable>
+ <xsl:variable name="min"><xsl:value-of select="@minOccurs"/></xsl:variable>
+ <xsl:variable name="namespace"><xsl:value-of select="@nsuri"/></xsl:variable>
+ <xsl:variable name="settingTracker">local<xsl:value-of select="@javaname"/>Tracker</xsl:variable>
+
+
+ <xsl:if test="$min=0 or $choice"> if (<xsl:value-of select="$settingTracker"/>){</xsl:if>
+ <xsl:choose>
+ <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 -->
+ <xsl:choose>
+ <xsl:when test="@nillable">
+ elementList.add(<xsl:value-of select="$varName"/>==null?null:
+ <xsl:value-of select="$varName"/>);
+ </xsl:when>
+ <xsl:otherwise>
+ if (<xsl:value-of select="$varName"/>==null){
+ throw new RuntimeException("<xsl:value-of select="$propertyName"/> cannot be null!!");
+ }
+ elementList.add(<xsl:value-of select="$varName"/>);
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <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 - Not any however -->
+ <xsl:when test="@array and not(@any)">
+ <xsl:choose>
+ <xsl:when test="@nillable">
+ // this property is nillable
+ if (<xsl:value-of select="$varName"/>!=null){
+ <!--this bracket 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 non ADB arrays - Any case - any may not be
+ nillable -->
+ <xsl:when test="@array and @any">
+ 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:when>
+ <!-- handle any - non array case-->
+ <xsl:when test="@any">
+ elementList.add(org.apache.axis2.databinding.utils.Constants.OM_ELEMENT_KEY);
+ elementList.add(<xsl:value-of select="$varName"/>);
+ </xsl:when>
+ <!-- handle binary - Since it is a Datahandler, we can just add it to the list
+ and the ADB pullparser would handle it right-->
+ <xsl:when test="@binary">
+ elementList.add(new javax.xml.namespace.QName("<xsl:value-of select="$namespace"/>",
+ "<xsl:value-of select="$propertyName"/>"));
+ 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"/>"));
+ <xsl:choose>
+ <xsl:when test="@nillable and not(@primitive)">
+ elementList.add(<xsl:value-of select="$varName"/>==null?null:
+ org.apache.axis2.databinding.utils.ConverterUtil.convertToString(<xsl:value-of select="$varName"/>));
+ </xsl:when>
+ <xsl:otherwise>
+ elementList.add(
+ org.apache.axis2.databinding.utils.ConverterUtil.convertToString(<xsl:value-of select="$varName"/>));
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:otherwise>
+ </xsl:choose>
+ <xsl:if test="$min=0 or $choice">}</xsl:if>
+ </xsl:for-each>
+
+ <xsl:for-each select="property[@attribute]">
+ <xsl:variable name="propertyName"><xsl:value-of select="@name"/></xsl:variable>
+ <xsl:variable name="varName">local<xsl:value-of select="@javaname"/></xsl:variable>
+ <xsl:variable name="namespace"><xsl:value-of select="@nsuri"/></xsl:variable>
+ <xsl:choose>
+ <xsl:when test="@any and not(@array)">
+ attribList.add(org.apache.axis2.databinding.utils.Constants.OM_ATTRIBUTE_KEY);
+ attribList.add(<xsl:value-of select="$varName"/>);
+ </xsl:when>
+ <xsl:when test="@any and @array">
+ for (int i=0;i <<xsl:value-of select="$varName"/>.length;i++){
+ attribList.add(org.apache.axis2.databinding.utils.Constants.OM_ATTRIBUTE_KEY);
+ attribList.add(<xsl:value-of select="$varName"/>[i]);
+ }
+ </xsl:when>
+ <xsl:otherwise>
+ attribList.add(
+ new javax.xml.namespace.QName("<xsl:value-of select="$namespace"/>","<xsl:value-of select="$propertyName"/>"));
+ attribList.add(
+ org.apache.axis2.databinding.utils.ConverterUtil.convertToString(<xsl:value-of select="$varName"/>));
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:for-each>
+
+ return new org.apache.axis2.databinding.utils.reader.ADBXMLStreamReaderImpl(qName, elementList.toArray(), attribList.toArray());
+ <!-- end of when for type & anon -->
+ </xsl:when>
+ <!-- Not a type and not anon. So it better be only one inclusion-->
+ <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:choose>
+ <xsl:when test="$nillable">
+ if (<xsl:value-of select="$varName"/>==null){
+ return new org.apache.axis2.databinding.utils.reader.NullXMLStreamReader(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:choose>
+ <xsl:when test="$nillable and not($primitive)">
+ if (<xsl:value-of select="$varName"/>==null){
+ return new org.apache.axis2.databinding.utils.reader.NullXMLStreamReader(MY_QNAME);
+ }else{
+ return new org.apache.axis2.databinding.utils.reader.ADBXMLStreamReaderImpl(MY_QNAME,
+ new Object[]{
+ org.apache.axis2.databinding.utils.reader.ADBXMLStreamReader.ELEMENT_TEXT,
+ org.apache.axis2.databinding.utils.ConverterUtil.convertToString(<xsl:value-of select="$varName"/>)
+ },
+ null);
+ }
+ </xsl:when>
+ <xsl:otherwise> return new org.apache.axis2.databinding.utils.reader.ADBXMLStreamReaderImpl(MY_QNAME,
+ new Object[]{
+ org.apache.axis2.databinding.utils.reader.ADBXMLStreamReader.ELEMENT_TEXT,
+ org.apache.axis2.databinding.utils.ConverterUtil.convertToString(<xsl:value-of select="$varName"/>)
+ },
+ null);</xsl:otherwise>
+ </xsl:choose>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:otherwise>
+ </xsl:choose>
+
+ }
+
+
+
+ /**
+ * Factory class that keeps the parse method
+ */
+ public static class Factory{
+
+
+ // This is horrible, but the OM implementation of getElementText() does not obey the proper contract. Specifically, it does
+ // does not advance the reader to the END_ELEMENT. This bug is triggered by calls to getElementText() unpredictably, e.g. it
+ // happens with outer (document) elements, but not with inner elements. The root bug is in OMStAXWrapper.java, which is now part
+ // of commons and so cannot just be fixed in axis2. This method should be removed and the calls to it below replaced with
+ // simple calls to getElementText() as soon as this serious bug can be fixed.
+
+ private static java.lang.String getElementTextProperly(javax.xml.stream.XMLStreamReader reader) throws java.lang.Exception {
+ java.lang.String value = reader.getElementText();
+ while (!reader.isEndElement())
+ reader.next();
+ return value;
+ }
+
+ /**
+ * static method to create the object
+ * Precondition: If this object is an element, the current or next start element starts this object and any intervening reader events are ignorable
+ * If this object is not an element, it is a complex type and the reader is at the event just after the outer start element
+ * Postcondition: If this object is an element, the reader is positioned at its end element
+ * If this object is a complex type, the reader is positioned at the end element of its outer element
+ */
+ public static <xsl:value-of select="$name"/> parse(javax.xml.stream.XMLStreamReader reader) throws java.lang.Exception{
+ <xsl:value-of select="$name"/> object = new <xsl:value-of select="$name"/>();
+ int event;
+ try {
+ <!-- Advance to our start element, or if we are a complex type, to our first property start element or the outer end element if no properties -->
+ while (!reader.isStartElement() && !reader.isEndElement())
+ reader.next();
+
+ <xsl:if test="@nillable">
+ if ("true".equals(reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance","nil"))){
+ // Skip the element and report the null value. It cannot have subelements.
+ while (!reader.isEndElement())
+ reader.next();
+ return null;
+ }
+ </xsl:if>
+
+ <!-- populate attributes here!!!. The attributes are part of an element, not part of a type -->
+ <xsl:for-each select="property[@attribute]">
+ <xsl:variable name="propertyName"><xsl:value-of select="@name"/></xsl:variable>
+ <xsl:variable name="propertyType"><xsl:value-of select="@type"/></xsl:variable>
+ <xsl:variable name="shortTypeName"><xsl:value-of select="@shorttypename"/></xsl:variable>
+ <xsl:variable name="javaName"><xsl:value-of select="@javaname"></xsl:value-of></xsl:variable>
+ <xsl:variable name="namespace"><xsl:value-of select="@nsuri"/></xsl:variable>
+ <xsl:variable name="attribName">tempAttrib<xsl:value-of select="$propertyName"/></xsl:variable>
+
+ 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){
+ object.set<xsl:value-of select="$javaName"/>(
+ org.apache.axis2.databinding.utils.ConverterUtil.convertTo<xsl:value-of select="$shortTypeName"/>(
+ <xsl:value-of select="$attribName"/>));
+ }
+
+ </xsl:for-each>
+
+ boolean isReaderMTOMAware = false;
+ <!-- workaround for the issues in the wstx reader!-->
+ try{
+ isReaderMTOMAware = java.lang.Boolean.TRUE.equals(reader.getProperty(org.apache.axiom.om.OMConstants.IS_DATA_HANDLERS_AWARE));
+ }catch(java.lang.IllegalArgumentException e){
+ isReaderMTOMAware = false;
+ }
+
+
+ <xsl:if test="$isType or $anon">
+ <!-- Skip the outer start element in order to process the subelements. -->
+ reader.next();
+ </xsl:if>
+ <!-- If we are not a type and not an element with anonymous type, then we are an element with one property for our named type. -->
+ <!-- Our single named-type property applies to our entire outer element, so don't skip it. -->
+ <!-- First loop creates arrayLists for handling arrays -->
+ <xsl:for-each select="property[not(@attribute)]">
+ <xsl:if test="@array">
+ java.util.ArrayList list<xsl:value-of select="position()"/> = new java.util.ArrayList();
+ </xsl:if>
+ </xsl:for-each>
+
+ <xsl:if test="property[not(@attribute)]">
+ <xsl:if test="$unordered"> <!-- Properties can be in any order -->
+ while(!reader.isEndElement()) {
+ if (reader.isStartElement()){
+ </xsl:if>
+ </xsl:if>
+
+ <!-- Now reloop and populate the code -->
+ <xsl:for-each select="property[not(@attribute)]">
+ <xsl:variable name="propertyName"><xsl:value-of select="@name"/></xsl:variable>
+ <xsl:variable name="propertyType"><xsl:value-of select="@type"/></xsl:variable>
+ <xsl:variable name="shortTypeName"><xsl:value-of select="@shorttypename"/></xsl:variable>
+ <xsl:variable name="javaName"><xsl:value-of select="@javaname"></xsl:value-of></xsl:variable>
+ <xsl:variable name="listName">list<xsl:value-of select="position()"/></xsl:variable>
+ <xsl:variable name="loopBoolName">loopDone<xsl:value-of select="position()"/></xsl:variable>
+ <xsl:variable name="startQname">startQname<xsl:value-of select="position()"/></xsl:variable>
+ <xsl:variable name="stateMachineName">stateMachine<xsl:value-of select="position()"/></xsl:variable>
+ <xsl:variable name="builderName">builder<xsl:value-of select="position()"/></xsl:variable>
+ <xsl:variable name="basePropertyType"><xsl:value-of select="@arrayBaseType"/></xsl:variable>
+ <xsl:variable name="namespace"><xsl:value-of select="@nsuri"/></xsl:variable>
+ <xsl:variable name="min"><xsl:value-of select="@minOccurs"/></xsl:variable>
+
+ <xsl:variable name="propQName">new javax.xml.namespace.QName("<xsl:value-of select="$namespace"/>","<xsl:value-of select="$propertyName"/>")</xsl:variable>
+
+ <xsl:choose>
+ <xsl:when test="$unordered"> <!-- One property per iteration if unordered -->
+ <xsl:if test="position()>1">
+ else
+ </xsl:if>
+ </xsl:when>
+ <xsl:otherwise>
+ <!-- If sequence, advance to start of next property or to end of outer element -->
+ while (!reader.isStartElement() && !reader.isEndElement()) reader.next();
+ </xsl:otherwise>
+ </xsl:choose>
+ if (reader.isStartElement() && <xsl:value-of select="$propQName"/>.equals(reader.getName())){
+ <xsl:choose>
+ <xsl:when test="@array">
+ <!-- We must be a named type or element with anonymous type. -->
+ <!-- Elements with a named type have a single simple (non-array) property for their type -->
+ // Process the array and step past its final element's end.
+ <xsl:variable name="basePropertyType"><xsl:value-of select="@arrayBaseType"/></xsl:variable>
+ <xsl:choose>
+ <xsl:when test="@ours">
+ <xsl:value-of select="$listName"/>.add(<xsl:value-of select="$basePropertyType"/>.Factory.parse(reader));
+ //loop until we find a start element that is not part of this array
+ boolean <xsl:value-of select="$loopBoolName"/> = false;
+ while(!<xsl:value-of select="$loopBoolName"/>){
+ // We should be at the end element, but make sure
+ while (!reader.isEndElement())
+ reader.next();
+ // Step out of this element
+ reader.next();
+ // Step to next element event.
+ while (!reader.isStartElement() && !reader.isEndElement())
+ reader.next();
+ if (reader.isEndElement()){
+ //two continuous end elements means we are exiting the xml structure
+ <xsl:value-of select="$loopBoolName"/> = true;
+ } else {
+ if (<xsl:value-of select="$propQName"/>.equals(reader.getName())){
+ <xsl:value-of select="$listName"/>.add(<xsl:value-of select="$basePropertyType"/>.Factory.parse(reader));
+ }else{
+ <xsl:value-of select="$loopBoolName"/> = true;
+ }
+ }
+ }
+ // call the converter utility to convert and set the array
+ object.set<xsl:value-of select="$javaName"/>((<xsl:value-of select="$propertyType"/>)
+ org.apache.axis2.databinding.utils.ConverterUtil.convertToArray(
+ <xsl:value-of select="$basePropertyType"/>.class,
+ <xsl:value-of select="$listName"/>));
+ </xsl:when>
+ <!-- End of Array handling of ADB classes -->
+ <xsl:when test="@default">
+ boolean <xsl:value-of select="$loopBoolName"/>=false;
+ javax.xml.namespace.QName <xsl:value-of select="$startQname"/> = new javax.xml.namespace.QName(
+ "<xsl:value-of select="$namespace"/>",
+ "<xsl:value-of select="$propertyName"/>");
+
+ while (!<xsl:value-of select="$loopBoolName"/>){
+ event = reader.getEventType();
+ if (javax.xml.stream.XMLStreamConstants.START_ELEMENT == event
+ && <xsl:value-of select="$startQname"/>.equals(reader.getName())){
+
+ <!-- if-block that handles nillable -->
+ <xsl:if test="@nillable">
+ if ("true".equals(reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance","nil"))){
+ <xsl:value-of select="$listName"/>.add(null);
+ }else{
+ </xsl:if>
+
+ // We need to wrap the reader so that it produces a fake START_DOCUEMENT event
+ org.apache.axis2.databinding.utils.NamedStaxOMBuilder <xsl:value-of select="$builderName"/>
+ = new org.apache.axis2.databinding.utils.NamedStaxOMBuilder(
+ new org.apache.axis2.util.StreamWrapper(reader), <xsl:value-of select="$startQname"/>);
+
+ <xsl:value-of select="$listName"/>.add(<xsl:value-of select="$builderName"/>.getOMElement());
+ <xsl:if test="@nillable">}</xsl:if>
+ } else if (javax.xml.stream.XMLStreamConstants.START_ELEMENT == event &&
+ !<xsl:value-of select="$startQname"/>.equals(reader.getName())){
+ <xsl:value-of select="$loopBoolName"/> = true;
+ }else if (javax.xml.stream.XMLStreamConstants.END_ELEMENT == event &&
+ !<xsl:value-of select="$startQname"/>.equals(reader.getName())){
+ <xsl:value-of select="$loopBoolName"/> = true;
+ }else if (javax.xml.stream.XMLStreamConstants.END_DOCUMENT == event){
+ <xsl:value-of select="$loopBoolName"/> = true;
+ }else{
+ reader.next();
+ }
+
+ }
+
+ object.set<xsl:value-of select="$javaName"/>((<xsl:value-of select="$propertyType"/>)
+ org.apache.axis2.databinding.utils.ConverterUtil.convertToArray(
+ <xsl:value-of select="$basePropertyType"/>.class,<xsl:value-of select="$listName"/>));
+
+ </xsl:when>
+ <!-- End of Array handling of default class - that is the OMElement -->
+ <xsl:otherwise>
+ <xsl:value-of select="$listName"/>.add(getElementTextProperly(reader));
+ //loop until we find a start element that is not part of this array
+ boolean <xsl:value-of select="$loopBoolName"/> = false;
+ while(!<xsl:value-of select="$loopBoolName"/>){
+ // Ensure we are at the EndElement
+ while (!reader.isEndElement()){
+ reader.next();
+ }
+ // Step out of this element
+ reader.next();
+ // Step to next element event.
+ while (!reader.isStartElement() && !reader.isEndElement())
+ reader.next();
+ if (reader.isEndElement()){
+ //two continuous end elements means we are exiting the xml structure
+ <xsl:value-of select="$loopBoolName"/> = true;
+ } else {
+ if (<xsl:value-of select="$propQName"/>.equals(reader.getName())){
+ <xsl:value-of select="$listName"/>.add(getElementTextProperly(reader));
+ }else{
+ <xsl:value-of select="$loopBoolName"/> = true;
+ }
+ }
+ }
+ // call the converter utility to convert and set the array
+ object.set<xsl:value-of select="$javaName"/>((<xsl:value-of select="$propertyType"/>)
+ org.apache.axis2.databinding.utils.ConverterUtil.convertToArray(
+ <xsl:value-of select="$basePropertyType"/>.class,
+ <xsl:value-of select="$listName"/>));
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:when test="@ours">
+ object.set<xsl:value-of select="$javaName"/>(<xsl:value-of select="$propertyType"/>.Factory.parse(reader));
+ <xsl:if test="$isType or $anon"> <!-- This is a subelement property to be consumed -->
+ reader.next();
+ </xsl:if>
+ </xsl:when>
+ <!-- start of any handling. Any can also be @default so we need to handle the any case before default! -->
+ <xsl:when test="@any">
+ <!--No concerns of being nillable here. if it's ours and if the nillable attribute was present
+ we would have outputted a null already-->
+ <!--This can be any element and we may not know the name. so we pick the name of the element from the parser-->
+ //use the QName from the parser as the name for the builder
+ javax.xml.namespace.QName <xsl:value-of select="$startQname"/> = reader.getName();
+
+ // We need to wrap the reader so that it produces a fake START_DOCUMENT event
+ // this is needed by the builder classes
+ org.apache.axis2.databinding.utils.NamedStaxOMBuilder <xsl:value-of select="$builderName"/> =
+ new org.apache.axis2.databinding.utils.NamedStaxOMBuilder(
+ new org.apache.axis2.util.StreamWrapper(reader),<xsl:value-of select="$startQname"/>);
+ object.set<xsl:value-of select="$javaName"/>(<xsl:value-of select="$builderName"/>.getOMElement());
+ <xsl:if test="$isType or $anon"> <!-- This is a subelement property to be consumed -->
+ reader.next();
+ </xsl:if>
+ </xsl:when>
+ <!-- end of adb type handling code -->
+ <!-- start of OMelement handling -->
+ <xsl:when test="@default">
+ boolean <xsl:value-of select="$loopBoolName"/> = false;
+ javax.xml.namespace.QName <xsl:value-of select="$startQname"/> = new javax.xml.namespace.QName(
+ "<xsl:value-of select="$namespace"/>",
+ "<xsl:value-of select="$propertyName"/>");
+
+ while(!<xsl:value-of select="$loopBoolName"/>){
+ if (reader.isStartElement() && <xsl:value-of select="$startQname"/>.equals(reader.getName())){
+ <xsl:value-of select="$loopBoolName"/> = true;
+ }else{
+ reader.next();
+ }
+ }
+
+ <!-- todo put the code here for nillable -->
+ // We need to wrap the reader so that it produces a fake START_DOCUEMENT event
+ // this is needed by the builder classes
+ org.apache.axis2.databinding.utils.NamedStaxOMBuilder <xsl:value-of select="$builderName"/> =
+ new org.apache.axis2.databinding.utils.NamedStaxOMBuilder(
+ new org.apache.axis2.util.StreamWrapper(reader),<xsl:value-of select="$startQname"/>);
+ object.set<xsl:value-of select="$javaName"/>(<xsl:value-of select="$builderName"/>.getOMElement());
+ <xsl:if test="$isType or $anon"> <!-- This is a subelement property to be consumed -->
+ reader.next();
+ </xsl:if>
+ </xsl:when>
+ <!-- end of OMelement handling -->
+ <!-- start of the simple types handling for binary content-->
+ <xsl:when test="@binary">
+ if (isReaderMTOMAware
+ &&
+ java.lang.Boolean.TRUE.equals(reader.getProperty(org.apache.axiom.om.OMConstants.IS_BINARY))){
+ //MTOM aware reader - get the datahandler directly and put it in the object
+ object.set<xsl:value-of select="$javaName"/>(
+ (javax.activation.DataHandler)reader.getProperty(org.apache.axiom.om.OMConstants.DATA_HANDLER));
+ }else{
+ //Do the usual conversion
+ java.lang.String content = getElementTextProperly(reader);
+ object.set<xsl:value-of select="$javaName"/>(
+ org.apache.axis2.databinding.utils.ConverterUtil.convertTo<xsl:value-of select="$shortTypeName"/>(content));
+
+ }
+
+ <xsl:if test="$isType or $anon"> <!-- This is a subelement property to be consumed -->
+ reader.next();
+ </xsl:if>
+ </xsl:when>
+ <!-- start of the simple types handling -->
+ <xsl:otherwise>
+ java.lang.String content = getElementTextProperly(reader);
+ object.set<xsl:value-of select="$javaName"/>(
+ org.apache.axis2.databinding.utils.ConverterUtil.convertTo<xsl:value-of select="$shortTypeName"/>(content));
+ <xsl:if test="$isType or $anon"> <!-- This is a subelement property to be consumed -->
+ reader.next();
+ </xsl:if>
+ </xsl:otherwise>
+ </xsl:choose>
+
+ } // End of if for expected property start element
+
+ <xsl:if test="$ordered and $min!=0">
+ else{
+ // A start element we are not expecting indicates an invalid parameter was passed
+ throw new java.lang.RuntimeException("Unexpected subelement " + reader.getLocalName());
+ }
+ </xsl:if>
+ </xsl:for-each>
+
+ <xsl:if test="$ordered"> <!-- pick up trailing cruft after final property before outer endElement and verify no trailing properties -->
+ while (!reader.isStartElement() && !reader.isEndElement())
+ reader.next();
+ if (reader.isStartElement())
+ // A start element we are not expecting indicates a trailing invalid property
+ throw new java.lang.RuntimeException("Unexpected subelement " + reader.getLocalName());
+ </xsl:if>
+
+ <xsl:if test="property[not(@attribute)]"> <!-- this if is needed to skip all this when there are no propoerties-->
+ <xsl:if test="$unordered">
+ else{
+ // A start element we are not expecting indicates an invalid parameter was passed
+ throw new java.lang.RuntimeException("Unexpected subelement " + reader.getLocalName());
+ }
+ } else reader.next(); <!-- At neither a start nor an end element, skip it -->
+ } // end of while loop
+ </xsl:if>
+ </xsl:if>
+
+
+ } catch (javax.xml.stream.XMLStreamException e) {
+ throw new java.lang.Exception(e);
+ }
+
+ return object;
+ }
+
+ }//end of factory class
+
+ <!-- end of template for choice/all -->
+
+ }
+ <!-- end of main template -->
+ </xsl:template>
+
+
+</xsl:stylesheet>
Added: webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/template/PlainBeanTemplate.xsl
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/template/PlainBeanTemplate.xsl?rev=410497&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/template/PlainBeanTemplate.xsl (added)
+++ webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/template/PlainBeanTemplate.xsl Wed May 31 04:35:30 2006
@@ -0,0 +1,109 @@
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+ <xsl:output method="text"/>
+
+ <!-- cater for the multiple classes - wrappped mode -->
+ <xsl:template match="/beans">
+ <xsl:variable name="name"><xsl:value-of select="@name"/></xsl:variable>
+ /**
+ * <xsl:value-of select="$name"/>.java
+ *
+ * This file was auto-generated from WSDL
+ * by the Apache Axis2 version: #axisVersion# #today#
+ */
+
+ package <xsl:value-of select="@package"/>;
+
+ /**
+ * <xsl:value-of select="$name"/> wrapped bean classes
+ */
+ public class <xsl:value-of select="$name"/>{
+
+ <xsl:apply-templates/>
+
+ }
+ </xsl:template>
+
+ <!--cater for the multiple classes - unwrappped mode -->
+ <xsl:template match="/">
+ <xsl:apply-templates/>
+ </xsl:template>
+
+
+ <xsl:template match="bean">
+ /**
+ * <xsl:value-of select="@name"/>.java
+ *
+ * This file was auto-generated from WSDL
+ * by the Apache Axis2 version: #axisVersion# #today#
+ */
+ package <xsl:value-of select="@package"/>;
+ <xsl:variable name="name"><xsl:value-of select="@name"/></xsl:variable>
+
+ /**
+ * <xsl:value-of select="$name"/> bean class
+ */
+
+ public class <xsl:value-of select="$name"/> <xsl:if test="@extension"> extends <xsl:value-of select="@extension"/></xsl:if>{
+
+ <xsl:choose>
+ <xsl:when test="@type">/* This type was generated from the piece of schema that had
+ name = <xsl:value-of select="@originalName"/>
+ Namespace URI = <xsl:value-of select="@nsuri"/>
+ Namespace Prefix = <xsl:value-of select="@nsprefix"/>
+ */
+ </xsl:when>
+ <xsl:otherwise>
+ public static final javax.xml.namespace.QName MY_QNAME = new javax.xml.namespace.QName(
+ "<xsl:value-of select="@nsuri"/>",
+ "<xsl:value-of select="@originalName"/>",
+ "<xsl:value-of select="@nsprefix"/>");
+
+ </xsl:otherwise>
+ </xsl:choose>
+
+
+ <xsl:for-each select="property">
+ <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="varName">local<xsl:value-of select="$javaName"/></xsl:variable>
+ /**
+ * field for <xsl:value-of select="$javaName"/>
+ <xsl:if test="@attribute">* This was an Attribute!</xsl:if>
+ <xsl:if test="@array">* This was an Array!</xsl:if>
+
+ */
+ private <xsl:value-of select="$propertyType"/><xsl:text> </xsl:text><xsl:value-of select="$varName" /> ;
+
+ /**
+ * 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 > <xsl:value-of select="@maxOccurs"></xsl:value-of>){
+ throw new java.lang.RuntimeException();
+ }
+ </xsl:if>
+ <xsl:if test="@minOccurs">
+ if (param.length < <xsl:value-of select="@minOccurs"></xsl:value-of>){
+ throw new java.lang.RuntimeException();
+ }
+ </xsl:if>
+ </xsl:if>
+ this.<xsl:value-of select="$varName"/>=param;
+ }
+ </xsl:for-each>
+ }
+ </xsl:template>
+</xsl:stylesheet>
\ No newline at end of file
Added: webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/typemap/JavaTypeMap.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/typemap/JavaTypeMap.java?rev=410497&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/typemap/JavaTypeMap.java (added)
+++ webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/typemap/JavaTypeMap.java Wed May 31 04:35:30 2006
@@ -0,0 +1,213 @@
+package org.apache.axis2.schema.typemap;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axis2.databinding.types.Day;
+import org.apache.axis2.databinding.types.Duration;
+import org.apache.axis2.databinding.types.Entities;
+import org.apache.axis2.databinding.types.Entity;
+import org.apache.axis2.databinding.types.HexBinary;
+import org.apache.axis2.databinding.types.IDRef;
+import org.apache.axis2.databinding.types.IDRefs;
+import org.apache.axis2.databinding.types.Id;
+import org.apache.axis2.databinding.types.Language;
+import org.apache.axis2.databinding.types.Month;
+import org.apache.axis2.databinding.types.MonthDay;
+import org.apache.axis2.databinding.types.NCName;
+import org.apache.axis2.databinding.types.NMToken;
+import org.apache.axis2.databinding.types.NMTokens;
+import org.apache.axis2.databinding.types.Name;
+import org.apache.axis2.databinding.types.NegativeInteger;
+import org.apache.axis2.databinding.types.NonNegativeInteger;
+import org.apache.axis2.databinding.types.NonPositiveInteger;
+import org.apache.axis2.databinding.types.NormalizedString;
+import org.apache.axis2.databinding.types.Notation;
+import org.apache.axis2.databinding.types.PositiveInteger;
+import org.apache.axis2.databinding.types.Time;
+import org.apache.axis2.databinding.types.Token;
+import org.apache.axis2.databinding.types.URI;
+import org.apache.axis2.databinding.types.UnsignedByte;
+import org.apache.axis2.databinding.types.UnsignedInt;
+import org.apache.axis2.databinding.types.UnsignedLong;
+import org.apache.axis2.databinding.types.UnsignedShort;
+import org.apache.axis2.databinding.types.Year;
+import org.apache.axis2.databinding.types.YearMonth;
+import org.apache.axis2.schema.SchemaConstants;
+
+import javax.xml.namespace.QName;
+import java.math.BigDecimal;
+import java.util.HashMap;
+import java.util.Map;
+/*
+ * 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.
+ */
+
+/**
+ * The java type map. uses a static map for caching
+ * Most code from Axis 1 Codebase
+ */
+public class JavaTypeMap implements TypeMap {
+
+ public Map getTypeMap() {
+ return typeMap;
+ }
+
+ private static Map typeMap = new HashMap();
+
+ static {
+ // If SOAP 1.1 over the wire, map wrapper classes to XSD primitives.
+ addTypemapping(SchemaConstants.XSD_STRING,
+ java.lang.String.class.getName());
+
+ // The XSD Primitives are mapped to java primitives.
+ addTypemapping(SchemaConstants.XSD_BOOLEAN, boolean.class.getName());
+ addTypemapping(SchemaConstants.XSD_DOUBLE, double.class.getName());
+ addTypemapping(SchemaConstants.XSD_FLOAT, float.class.getName());
+ addTypemapping(SchemaConstants.XSD_INT, int.class.getName());
+ addTypemapping(SchemaConstants.XSD_INTEGER,
+ java.math.BigInteger.class.getName());
+ addTypemapping(SchemaConstants.XSD_LONG, long.class.getName());
+ addTypemapping(SchemaConstants.XSD_SHORT, short.class.getName());
+ addTypemapping(SchemaConstants.XSD_BYTE, byte.class.getName());
+ addTypemapping(SchemaConstants.XSD_ANY, OMElement.class.getName());
+ addTypemapping(SchemaConstants.XSD_DECIMAL, BigDecimal.class.getName());
+
+ //anytype is mapped to the OMElement instead of the java.lang.Object
+ addTypemapping(SchemaConstants.XSD_ANYTYPE,
+ OMElement.class.getName());
+
+ //Qname maps to jax rpc QName class
+ addTypemapping(SchemaConstants.XSD_QNAME,
+ javax.xml.namespace.QName.class.getName());
+
+ //xsd Date is mapped to the java.util.date!
+ addTypemapping(SchemaConstants.XSD_DATE,
+ java.util.Date.class.getName());
+
+ // Mapping for xsd:time. Map to Axis type Time
+ addTypemapping(SchemaConstants.XSD_TIME,
+ Time.class.getName());
+ addTypemapping(SchemaConstants.XSD_DATETIME,
+ java.util.Calendar.class.getName());
+
+ //as for the base 64 encoded binary stuff we map it to a javax.
+ // activation.Datahandler object
+ addTypemapping(SchemaConstants.XSD_BASE64,
+ javax.activation.DataHandler.class.getName());
+
+ addTypemapping(SchemaConstants.XSD_HEXBIN,
+ HexBinary.class.getName());
+
+ // These are the g* types (gYearMonth, etc) which map to Axis types
+ addTypemapping(SchemaConstants.XSD_YEARMONTH,
+ YearMonth.class.getName());
+ addTypemapping(SchemaConstants.XSD_YEAR,
+ Year.class.getName());
+ addTypemapping(SchemaConstants.XSD_MONTH,
+ Month.class.getName());
+ addTypemapping(SchemaConstants.XSD_DAY,
+ Day.class.getName());
+ addTypemapping(SchemaConstants.XSD_MONTHDAY,
+ MonthDay.class.getName());
+
+ // xsd:token
+ addTypemapping(SchemaConstants.XSD_TOKEN, Token.class.getName());
+
+ // a xsd:normalizedString
+ addTypemapping(SchemaConstants.XSD_NORMALIZEDSTRING,
+ NormalizedString.class.getName());
+
+ // a xsd:unsignedLong
+ addTypemapping(SchemaConstants.XSD_UNSIGNEDLONG,
+ UnsignedLong.class.getName());
+
+ // a xsd:unsignedInt
+ addTypemapping(SchemaConstants.XSD_UNSIGNEDINT,
+ UnsignedInt.class.getName());
+
+ // a xsd:unsignedShort
+ addTypemapping(SchemaConstants.XSD_UNSIGNEDSHORT,
+ UnsignedShort.class.getName());
+
+ // a xsd:unsignedByte
+ addTypemapping(SchemaConstants.XSD_UNSIGNEDBYTE,
+ UnsignedByte.class.getName());
+
+ // a xsd:nonNegativeInteger
+ addTypemapping(SchemaConstants.XSD_NONNEGATIVEINTEGER,
+ NonNegativeInteger.class.getName());
+
+ // a xsd:negativeInteger
+ addTypemapping(SchemaConstants.XSD_NEGATIVEINTEGER,
+ NegativeInteger.class.getName());
+
+ // a xsd:positiveInteger
+ addTypemapping(SchemaConstants.XSD_POSITIVEINTEGER,
+ PositiveInteger.class.getName());
+
+ // a xsd:nonPositiveInteger
+ addTypemapping(SchemaConstants.XSD_NONPOSITIVEINTEGER,
+ NonPositiveInteger.class.getName());
+
+ // a xsd:Name
+ addTypemapping(SchemaConstants.XSD_NAME, Name.class.getName());
+
+ // a xsd:NCName
+ addTypemapping(SchemaConstants.XSD_NCNAME, NCName.class.getName());
+
+ // a xsd:ID
+ addTypemapping(SchemaConstants.XSD_ID, Id.class.getName());
+
+ // a xml:lang
+ // addTypemapping(SchemaConstants.XML_LANG,Language.class.getName());
+
+ // a xsd:language
+ addTypemapping(SchemaConstants.XSD_LANGUAGE, Language.class.getName());
+
+ // a xsd:NmToken
+ addTypemapping(SchemaConstants.XSD_NMTOKEN, NMToken.class.getName());
+
+ // a xsd:NmTokens
+ addTypemapping(SchemaConstants.XSD_NMTOKENS, NMTokens.class.getName());
+
+ // a xsd:NOTATION
+ addTypemapping(SchemaConstants.XSD_NOTATION, Notation.class.getName());
+
+ // a xsd:XSD_ENTITY
+ addTypemapping(SchemaConstants.XSD_ENTITY, Entity.class.getName());
+
+ // a xsd:XSD_ENTITIES
+ addTypemapping(SchemaConstants.XSD_ENTITIES, Entities.class.getName());
+
+ // a xsd:XSD_IDREF
+ addTypemapping(SchemaConstants.XSD_IDREF, IDRef.class.getName());
+
+ // a xsd:XSD_XSD_IDREFS
+ addTypemapping(SchemaConstants.XSD_IDREFS, IDRefs.class.getName());
+
+ // a xsd:Duration
+ addTypemapping(SchemaConstants.XSD_DURATION, Duration.class.getName());
+
+ // a xsd:anyURI
+ addTypemapping(SchemaConstants.XSD_ANYURI, URI.class.getName());
+
+
+ }
+
+ private static void addTypemapping(QName name, String str) {
+ typeMap.put(name, str);
+ }
+
+
+}
Added: webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/typemap/TypeMap.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/typemap/TypeMap.java?rev=410497&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/typemap/TypeMap.java (added)
+++ webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/typemap/TypeMap.java Wed May 31 04:35:30 2006
@@ -0,0 +1,26 @@
+package org.apache.axis2.schema.typemap;
+
+import java.util.Map;
+/*
+ * 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.
+ */
+
+/**
+ * This is a typemapper for the bean writer
+ */
+public interface TypeMap {
+
+ public Map getTypeMap();
+}
Added: webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/util/PrimitiveTypeFinder.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/util/PrimitiveTypeFinder.java?rev=410497&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/util/PrimitiveTypeFinder.java (added)
+++ webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/util/PrimitiveTypeFinder.java Wed May 31 04:35:30 2006
@@ -0,0 +1,55 @@
+package org.apache.axis2.schema.util;
+
+import java.util.ArrayList;
+import java.util.List;
+/*
+ * 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 simple utiliy to find whether a given class name is
+ * primitive or not
+ */
+public class PrimitiveTypeFinder {
+
+ private static List primitiveClassNameList;
+
+ static{
+ primitiveClassNameList = new ArrayList();
+ //add the java primitive class names
+ primitiveClassNameList.add(int.class.getName());
+ primitiveClassNameList.add(long.class.getName());
+ primitiveClassNameList.add(byte.class.getName());
+ primitiveClassNameList.add(double.class.getName());
+ primitiveClassNameList.add(boolean.class.getName());
+ primitiveClassNameList.add(float.class.getName());
+ primitiveClassNameList.add(short.class.getName());
+ primitiveClassNameList.add(char.class.getName());
+
+ }
+
+ /**
+ *
+ * @param className
+ * @return
+ */
+ public static boolean isPrimitive(String className){
+ //if an array type is passed, strip out the [] part
+ if (className.indexOf("[]")!=-1){
+ className = className.substring(0,className.indexOf("[]"));
+ }
+ return primitiveClassNameList.contains(className);
+ }
+}
Added: webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/util/SchemaPropertyLoader.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/util/SchemaPropertyLoader.java?rev=410497&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/util/SchemaPropertyLoader.java (added)
+++ webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/util/SchemaPropertyLoader.java Wed May 31 04:35:30 2006
@@ -0,0 +1,80 @@
+package org.apache.axis2.schema.util;
+
+import org.apache.axis2.schema.SchemaCompiler;
+import org.apache.axis2.schema.SchemaConstants;
+import org.apache.axis2.schema.typemap.TypeMap;
+import org.apache.axis2.schema.writer.BeanWriter;
+
+import java.util.Properties;
+/*
+ * 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.
+ */
+
+/**
+ * Loads the properties for the schema compiler.
+ */
+public class SchemaPropertyLoader {
+ private static String beanTemplate = null;
+ private static BeanWriter beanWriterInstance = null;
+ private static TypeMap typeMapperInstance = null;
+ private static Properties propertyMap;
+
+ static {
+ try {
+ //load the properties
+ Properties props = new Properties();
+ props.load(SchemaCompiler.class.getResourceAsStream(SchemaConstants.SchemaPropertyNames.SCHEMA_COMPILER_PROPERTIES));
+
+ String beanWriterClassName = props.getProperty(SchemaConstants.SchemaPropertyNames.BEAN_WRITER_KEY);
+ if (beanWriterClassName != null) {
+ beanWriterInstance = (BeanWriter) Class.forName(beanWriterClassName).newInstance();
+ }
+
+ String typeMapperClassName = props.getProperty(SchemaConstants.SchemaPropertyNames.BEAN_WRITER_TYPEMAP_KEY);
+ if (typeMapperClassName != null) {
+ typeMapperInstance = (TypeMap) Class.forName(typeMapperClassName).newInstance();
+ }
+
+ beanTemplate = props.getProperty(SchemaConstants.SchemaPropertyNames.BEAN_WRITER_TEMPLATE_KEY);
+
+ //set the props as the property map
+ propertyMap = props;
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+
+
+ }
+
+ /**
+ * Exposes the whole property set
+ * @return Returns Properties.
+ */
+ public static Properties getPropertyMap() {
+ return propertyMap;
+ }
+
+ public static String getBeanTemplate() {
+ return beanTemplate;
+ }
+
+ public static BeanWriter getBeanWriterInstance() {
+ return beanWriterInstance;
+ }
+
+ public static TypeMap getTypeMapperInstance() {
+ return typeMapperInstance;
+ }
+}
Added: webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/writer/BeanWriter.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/writer/BeanWriter.java?rev=410497&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/writer/BeanWriter.java (added)
+++ webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/writer/BeanWriter.java Wed May 31 04:35:30 2006
@@ -0,0 +1,98 @@
+package org.apache.axis2.schema.writer;
+
+import javax.xml.namespace.QName;
+import org.apache.axis2.schema.BeanWriterMetaInfoHolder;
+import org.apache.axis2.schema.CompilerOptions;
+import org.apache.axis2.schema.SchemaCompilationException;
+import org.apache.ws.commons.schema.XmlSchemaComplexType;
+import org.apache.ws.commons.schema.XmlSchemaElement;
+import org.apache.ws.commons.schema.XmlSchemaSimpleType;
+
+import java.io.IOException;
+import java.util.Map;
+/*
+ * 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.
+ */
+
+/**
+ * The bean writer interface. The schema compiler expects one of these to be
+ * presented to it and calls the appropriate methods
+ */
+public interface BeanWriter {
+
+
+ /**
+ * Initializes the writer with compiler options.
+ *
+ * @param options
+ * @throws IOException
+ */
+ public void init(CompilerOptions options) throws SchemaCompilationException;
+
+ /**
+ * Writes a wrapped class. This will have effect only if the CompilerOptions wrapclassses
+ * returns true.
+ */
+ public void writeBatch() throws SchemaCompilationException;
+
+ /**
+ * Gets a map of models. This is useful for tight integrations where the internal workings
+ * of the schema compiler may be exposed.
+ */
+ public Map getModelMap();
+
+ /** Make the fully qualified class name for an element or named type
+ * @param qName the qualified Name for this element or type in the schema
+ * @return the appropriate fully qualified class name to use in generated code
+ */
+ public String makeFullyQualifiedClassName(QName qName);
+
+ /**
+ * Write a complex type
+ *
+ * @param complexType
+ * @param typeMap
+ * @param metainf
+ * @param fullyQualifiedClassName the name returned by makeFullyQualifiedClassName() or null if it wasn't called
+ * @return Returns String.
+ * @throws SchemaCompilationException
+ */
+ public String write(XmlSchemaComplexType complexType, Map typeMap, BeanWriterMetaInfoHolder metainf, String fullyQualifiedClassName)
+ throws SchemaCompilationException;
+
+ /**
+ * Write a element
+ *
+ * @param element
+ * @param typeMap
+ * @param metainf
+ * @return Returns String.
+ * @throws SchemaCompilationException
+ */
+ public String write(XmlSchemaElement element, Map typeMap, BeanWriterMetaInfoHolder metainf) throws SchemaCompilationException;
+
+
+ /**
+ * Write a simple type
+ *
+ * @param simpleType
+ * @param typeMap
+ * @param metainf
+ * @return Returns String.
+ * @throws SchemaCompilationException
+ */
+ public String write(XmlSchemaSimpleType simpleType, Map typeMap, BeanWriterMetaInfoHolder metainf) throws SchemaCompilationException;
+
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org