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 ch...@apache.org on 2005/10/18 15:01:22 UTC

svn commit: r326098 - /webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/utils/ADBPullParser.java

Author: chinthaka
Date: Tue Oct 18 06:01:13 2005
New Revision: 326098

URL: http://svn.apache.org/viewcvs?rev=326098&view=rev
Log:
Fixing the build. My code was in an intermediate state when I got this complaint. So some code is commented out. Will fix them also soon, but the build should be successful now.

Modified:
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/utils/ADBPullParser.java

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/utils/ADBPullParser.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/utils/ADBPullParser.java?rev=326098&r1=326097&r2=326098&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/utils/ADBPullParser.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/utils/ADBPullParser.java Tue Oct 18 06:01:13 2005
@@ -11,9 +11,7 @@
 import javax.xml.stream.XMLStreamConstants;
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamReader;
-import java.util.Stack;
 import java.util.HashMap;
-import java.util.ArrayList;
 
 /*
  * Copyright 2004,2005 The Apache Software Foundation.
@@ -60,7 +58,7 @@
     // a pointer to the children list of current location
     private int currentIndex = 0;
 
-    private ArrayList declaredNamespaces;
+    private HashMap declaredNamespaces;
 
     /**
      * This namespace map will contain uri as the key and the prefix as the value, so that I can check
@@ -82,39 +80,39 @@
         namespaceMap = new HashMap();
     }
 
-     /**
-     * @param properties - this should contain all the stuff that stax events should be generated.
+    /**
+     * @param properties    - this should contain all the stuff that stax events should be generated.
      *                      Lets take an example of a bean.
-*                      <pre> <Person>
-     *                          <Name>FooOne</Name>
-     *                          <DependentOne>
-     *                              <Name>FooTwo</Name>
-     *                              <Age>25</Age>
-     *                              <Sex>Male</Sex>
-     *                          </DependentOne>
-     *                      </Person>
-     *
-     *                      so the mapping bean for this is
-     *                      class Person {
-     *                          String Name;
-     *                          Dependent dependentOne;
-     *                      }
-     *
-     *                      class Dependent {
-     *                          String name;
-     *                          int age;
-     *                          String sex;
-     *                      }
-     *
-     *                      So if one needs to generate pull events out of a Person bean, the array he needs
-     *                      to pass is like this.
-     *                      ---------------------------------------------------------------------------------------------------
-     *                      | "Name" | "FooOne" | QName("DependentOne") | Dependent object| null | Array of Dependent objects |
-     *                      ---------------------------------------------------------------------------------------------------
-     *                      This DependentObject can either be an ADBBean, OMElement or a POJO. If its an ADBBean
-     *                      We directly get the pull parser from that. If not we create a reflection based
-     *                      pull parser for that java bean.
-     *  </pre>
+     *                      <pre> <Person>
+     *                                                                                         <Name>FooOne</Name>
+     *                                                                                         <DependentOne>
+     *                                                                                             <Name>FooTwo</Name>
+     *                                                                                             <Age>25</Age>
+     *                                                                                             <Sex>Male</Sex>
+     *                                                                                         </DependentOne>
+     *                                                                                     </Person>
+     *                      <p/>
+     *                                                                                     so the mapping bean for this is
+     *                                                                                     class Person {
+     *                                                                                         String Name;
+     *                                                                                         Dependent dependentOne;
+     *                                                                                     }
+     *                      <p/>
+     *                                                                                     class Dependent {
+     *                                                                                         String name;
+     *                                                                                         int age;
+     *                                                                                         String sex;
+     *                                                                                     }
+     *                      <p/>
+     *                                                                                     So if one needs to generate pull events out of a Person bean, the array he needs
+     *                                                                                     to pass is like this.
+     *                                                                                     ---------------------------------------------------------------------------------------------------
+     *                                                                                     | "Name" | "FooOne" | QName("DependentOne") | Dependent object| null | Array of Dependent objects |
+     *                                                                                     ---------------------------------------------------------------------------------------------------
+     *                                                                                     This DependentObject can either be an ADBBean, OMElement or a POJO. If its an ADBBean
+     *                                                                                     We directly get the pull parser from that. If not we create a reflection based
+     *                                                                                     pull parser for that java bean.
+     *                                                                 </pre>
      * @param adbBeansQName
      * @return XMLStreamReader
      */
@@ -170,8 +168,7 @@
             // then this is just the start element
             currentIndex++;
             parserInformation = new ParserInformation(this.elementQName);
-            namespaceMap.put(elementQName.getNamespaceURI(), elementQName.getPrefix());
-            handleAttributes();
+            handleNamespaces();
             return XMLStreamConstants.START_ELEMENT;
         } else if (properties == null || properties.length + 1 == currentIndex) {
             // this is the end of this element
@@ -210,15 +207,25 @@
 
     }
 
-    private void handleAttributes() {
+    private void handleNamespaces() {
         // by this time all the attributes related methods can be called.
         // now need to extract namespace from them and attach them to the element itself.
+        String elementNSUri = this.elementQName.getNamespaceURI();
+        if (namespaceMap.get(elementNSUri) == null) {
+            String prefix = this.elementQName.getPrefix();
+            namespaceMap.put(elementNSUri, prefix);
+            if (declaredNamespaces == null) declaredNamespaces = new HashMap();
+            declaredNamespaces.put(elementNSUri, prefix);
+        }
         if (attributes != null) {
             for (int i = 0; i < attributes.length; i++) {
                 OMAttribute attribute = attributes[i];
                 if (namespaceMap.get(attribute.getQName().getNamespaceURI()) == null) {
-                    namespaceMap.put(attribute.getQName().getNamespaceURI(), attribute.getQName().getPrefix());
-
+                    String namespaceURI = attribute.getQName().getNamespaceURI();
+                    String prefix = attribute.getQName().getPrefix();
+                    namespaceMap.put(namespaceURI, prefix);
+                    if (declaredNamespaces == null) declaredNamespaces = new HashMap();
+                    declaredNamespaces.put(namespaceURI, prefix);
                 }
             }
         }
@@ -242,7 +249,9 @@
     }
 
     public int getNamespaceCount() {
-        return 0;  //To change body of implemented methods use File | Settings | File Templates.
+//        if (accessingChildPullParser) return childPullParser.getNamespaceCount();
+//        return declaredNamespaces == null ? 0 : declaredNamespaces.size();
+        return 0;
     }
 
     public String getText() {
@@ -376,8 +385,12 @@
         throw new UnsupportedOperationException("Yet to be implemented !!");
     }
 
-    public String getNamespaceURI(String string) {
-        throw new UnsupportedOperationException("Yet to be implemented !!");
+    public String getNamespaceURI(String namespaceURI) {
+
+//        if(accessingChildPullParser) return childPullParser.getNamespaceURI(namespaceURI);
+//        if(declaredNamespaces != null) return declaredNamespaces.get(namespaceURI);
+//        return this.elementQName.getNamespaceURI();
+        return namespaceURI;
     }
 
     public boolean isStartElement() {