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 ch...@apache.org on 2005/11/23 04:29:16 UTC

svn commit: r348351 - in /webservices/axis2/trunk/java/modules/codegen: src/org/apache/axis2/databinding/utils/ADBPullParser.java test/org/apache/axis2/databinding/utils/ADBPullParserTest.java

Author: chinthaka
Date: Tue Nov 22 19:29:05 2005
New Revision: 348351

URL: http://svn.apache.org/viewcvs?rev=348351&view=rev
Log:
Adding a way to add attributes to the ADBPullParser. Now one can give two Strings as the key and the value.

Modified:
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/utils/ADBPullParser.java
    webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/utils/ADBPullParserTest.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=348351&r1=348350&r2=348351&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 Nov 22 19:29:05 2005
@@ -163,6 +163,7 @@
                                 Key             Value
                                null            OMAttribute[]
                                QName           String
+                               String          String
                   </pre>
      * @return XMLStreamReader
      */
@@ -365,6 +366,10 @@
                     QName qName = (QName) key;
                     checkNamespaceList(qName.getNamespaceURI(), qName.getPrefix());
                     attributesList.add(qName);
+                    attributesList.add(attributes[i + 1]);
+                }else if (key instanceof String) {
+                    String keyString = (String) key;
+                    attributesList.add(new QName(keyString));
                     attributesList.add(attributes[i + 1]);
                 }
             }

Modified: webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/utils/ADBPullParserTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/utils/ADBPullParserTest.java?rev=348351&r1=348350&r2=348351&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/utils/ADBPullParserTest.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/utils/ADBPullParserTest.java Tue Nov 22 19:29:05 2005
@@ -572,6 +572,36 @@
         }
     }
 
+    public void testUnQualifiedAttributes() {
+
+        String expectedXML = "<ns1:testElementText xmlns:ns1=\"http://testElementText.org\" MyUnQualifiedAttribute=\"MyAttributeValue\">" +
+                "<ns2:QualifiedElement xmlns:ns2=\"http://testQElementText.org\">" +
+                "This is some Text for the element</ns2:QualifiedElement></ns1:testElementText>";
+        try {
+            ArrayList properties = new ArrayList();
+            properties.add(new QName("http://testQElementText.org", "QualifiedElement", "ns2"));
+            properties.add("This is some Text for the element");
+
+            String[] attributes = new String[2];
+            attributes[0] = "MyUnQualifiedAttribute";
+            attributes[1] = "MyAttributeValue";
+
+
+            XMLStreamReader pullParser = ADBPullParser.createPullParser(new QName("http://testElementText.org", "testElementText", "ns1"), properties.toArray(), attributes);
+
+            String actualXML = getStringXML(pullParser);
+            System.out.println("actualXML = " + actualXML);
+
+            assertXMLEqual(newDocument(expectedXML), newDocument(actualXML));
+        } catch (ParserConfigurationException e) {
+            fail("Error has occurred " + e);
+        } catch (SAXException e) {
+            fail("Error has occurred " + e);
+        } catch (IOException e) {
+            fail("Error has occurred " + e);
+        }
+    }
+
     public void testComplexScenarioOne() {
         /*
            <apache:Project xmlns:axis2="http://ws.apache.org/namespaces/axis2" xmlns:apache="http://www.apache.org/" xmlns:myAttr="mailto:myAttributes@axis2.org" myAttr:name="Apache Axis2">