You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by di...@apache.org on 2006/11/22 23:39:53 UTC

svn commit: r478353 - /webservices/axis2/branches/java/1_1/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl

Author: dims
Date: Wed Nov 22 14:39:53 2006
New Revision: 478353

URL: http://svn.apache.org/viewvc?view=rev&rev=478353
Log:
- Separate out a method for checking a reader's MTOM awareness
- Don't call convertToString for strings


Modified:
    webservices/axis2/branches/java/1_1/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl

Modified: webservices/axis2/branches/java/1_1/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_1/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl?view=diff&rev=478353&r1=478352&r2=478353
==============================================================================
--- webservices/axis2/branches/java/1_1/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl (original)
+++ webservices/axis2/branches/java/1_1/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl Wed Nov 22 14:39:53 2006
@@ -519,6 +519,20 @@
 
         </xsl:for-each>
 
+     /**
+     * isReaderMTOMAware
+     * @return true if the reader supports MTOM
+     */
+   public boolean isReaderMTOMAware(javax.xml.stream.XMLStreamReader reader) {
+        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;
+        }
+        return isReaderMTOMAware;
+   }
      <!-- ######################################################################################### -->
      <!-- get OMElement methods that allows direct writing -->
      /**
@@ -948,7 +962,14 @@
                                                 } else {
                                                     xmlWriter.writeStartElement("<xsl:value-of select="$propertyName"/>");
                                                 }
-                                                xmlWriter.writeCharacters(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(<xsl:value-of select="$varName"/>[i]));
+                                            <xsl:choose>
+                                                <xsl:when test="$propertyType='java.lang.String[]'">
+                                                    xmlWriter.writeCharacters(<xsl:value-of select="$varName"/>[i]);
+                                                </xsl:when>
+                                                <xsl:otherwise>
+                                                    xmlWriter.writeCharacters(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(<xsl:value-of select="$varName"/>[i]));
+                                                </xsl:otherwise>
+                                            </xsl:choose>
                                                 xmlWriter.writeEndElement();
 
                                             } else {
@@ -1121,6 +1142,9 @@
                                             <xsl:when test="$propertyType='org.apache.axiom.om.OMElement'">
                                                 <xsl:value-of select="$varName"/>.serialize(xmlWriter);
                                             </xsl:when>
+                                            <xsl:when test="$propertyType='java.lang.String'">
+                                                   xmlWriter.writeCharacters(<xsl:value-of select="$varName"/>);
+                                            </xsl:when>
                                             <xsl:otherwise>
                                                    xmlWriter.writeCharacters(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(<xsl:value-of select="$varName"/>));
                                             </xsl:otherwise>
@@ -1256,6 +1280,9 @@
                                             <xsl:when test="$propertyType='org.apache.axiom.om.OMElement'">
                                                 <xsl:value-of select="$varName"/>.serialize(xmlWriter);
                                             </xsl:when>
+                                            <xsl:when test="$propertyType='java.lang.String'">
+                                                       xmlWriter.writeCharacters(<xsl:value-of select="$varName"/>);
+                                            </xsl:when>
                                             <xsl:otherwise>
                                                        xmlWriter.writeCharacters(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(<xsl:value-of select="$varName"/>));
                                             </xsl:otherwise>
@@ -1749,15 +1776,6 @@
 
                 </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) and not($simple)">
                     <!-- Skip the outer start element in order to process the subelements. -->
                     reader.next();
@@ -1963,7 +1981,7 @@
                                                   } else {
                                                 </xsl:if>
 
-                                                    if (isReaderMTOMAware
+                                                    if (isReaderMTOMAware(reader)
                                                             &amp;&amp;
                                                             java.lang.Boolean.TRUE.equals(reader.getProperty(org.apache.axiom.om.OMConstants.IS_BINARY)))
                                                     {
@@ -2018,7 +2036,7 @@
                                                             </xsl:if>
 
                                                                 <xsl:if test="not($simple)">reader.next();</xsl:if>
-                                                                if (isReaderMTOMAware
+                                                                if (isReaderMTOMAware(reader)
                                                                         &amp;&amp;
                                                                         java.lang.Boolean.TRUE.equals(reader.getProperty(org.apache.axiom.om.OMConstants.IS_BINARY)))
                                                                 {
@@ -2216,7 +2234,7 @@
                                 <!-- start of the simple types handling for binary content-->
                                 <xsl:when test="@binary">
                                     <xsl:if test="not($simple)">reader.next();</xsl:if>
-                                    if (isReaderMTOMAware
+                                    if (isReaderMTOMAware(reader)
                                             &amp;&amp;
                                             java.lang.Boolean.TRUE.equals(reader.getProperty(org.apache.axiom.om.OMConstants.IS_BINARY)))
                                     {
@@ -3053,15 +3071,6 @@
 
                 </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();
@@ -3330,7 +3339,7 @@
                                 <!-- end of OMelement handling -->
                                 <!-- start of the simple types handling for binary content-->
                                 <xsl:when test="@binary">
-                                    if (isReaderMTOMAware
+                                    if (isReaderMTOMAware(reader)
                                             &amp;&amp;
                                             java.lang.Boolean.TRUE.equals(reader.getProperty(org.apache.axiom.om.OMConstants.IS_BINARY)))
                                     {
@@ -3432,6 +3441,21 @@
 
             return object;
         }
+
+        /**
+        * isReaderMTOMAware
+        * @return true if the reader supports MTOM
+        */
+      public boolean isReaderMTOMAware(javax.xml.stream.XMLStreamReader reader) {
+           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;
+           }
+           return isReaderMTOMAware;
+      }
 
      public static javax.xml.stream.XMLStreamReader getPullParser(java.lang.Object beanObject, javax.xml.namespace.QName qName){
 



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