Author: chinthaka
Date: Wed Apr  5 00:18:20 2006
New Revision: 391553

URL: http://svn.apache.org/viewcvs?rev=391553&view=rev
Log:
More and more performance improvements .......


Modified:
    
webservices/commons/trunk/modules/axiom/src/org/apache/axiom/om/impl/builder/StAXOMBuilder.java
    
webservices/commons/trunk/modules/axiom/src/org/apache/axiom/om/impl/dom/ElementImpl.java
    
webservices/commons/trunk/modules/axiom/src/org/apache/axiom/om/impl/llom/OMElementImpl.java
    
webservices/commons/trunk/modules/axiom/test/org/apache/axiom/om/impl/serializer/PreserveEnvelopeTest.java

Modified: 
webservices/commons/trunk/modules/axiom/src/org/apache/axiom/om/impl/builder/StAXOMBuilder.java
URL: 
http://svn.apache.org/viewcvs/webservices/commons/trunk/modules/axiom/src/org/apache/axiom/om/impl/builder/StAXOMBuilder.java?rev=391553&r1=391552&r2=391553&view=diff
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/src/org/apache/axiom/om/impl/builder/StAXOMBuilder.java
 (original)
+++ 
webservices/commons/trunk/modules/axiom/src/org/apache/axiom/om/impl/builder/StAXOMBuilder.java
 Wed Apr  5 00:18:20 2006
@@ -301,42 +301,35 @@
         String prefix = parser.getPrefix();
 
 
-        OMNamespace namespace = null;
-        if (namespaceURI != null && namespaceURI.length() > 0) {
-            
-
-            // prefix being null means this elements has a default namespace 
or it has inherited
-            // a default namespace from its parent
-            namespace = node.findNamespace(namespaceURI, prefix);
-            if (namespace == null) {
-                if (prefix == null || "".equals(prefix)) {
-                    namespace = node.declareDefaultNamespace(namespaceURI);
-                } else {
-                    namespace = node.declareNamespace(namespaceURI, prefix);
-                }
-            }
-            node.setNamespaceWithNoFindInCurrentScope(namespace);
-        }
-
-
         int namespaceCount = parser.getNamespaceCount();
         String nsprefix;
         String namespaceURIFromParser;
         for (int i = 0; i < namespaceCount; i++) {
             nsprefix = parser.getNamespacePrefix(i);
-            //if the namespace is not defined already when we write the start 
tag declare it
 
+            //if the namespace is not defined already when we write the start 
tag declare it
             // check whether this is the default namespace and make sure we 
have not declared that earlier
             namespaceURIFromParser = parser.getNamespaceURI(i);
-            if (nsprefix == null && namespace != null && 
!namespaceURIFromParser.equals(namespace.getName()))
-            {
+            if (nsprefix == null || "".equals(nsprefix)) {
                 node.declareDefaultNamespace(parser.getNamespaceURI(i));
-            } else if (nsprefix != null && !"".equals(nsprefix) && 
!nsprefix.equals(prefix)) {
+            } else {
+                node.declareNamespace(namespaceURIFromParser, nsprefix);
+            }
+        }
 
-                node.declareNamespace(parser.getNamespaceURI(i),
-                        parser.getNamespacePrefix(i));
+        if (namespaceURI != null && namespaceURI.length() > 0) {
+            OMNamespace namespace = node.findNamespace(namespaceURI, prefix);
+            if (namespace == null) {
+                if (prefix == null || "".equals(prefix)) {
+                    namespace = node.declareDefaultNamespace(namespaceURI);
+                } else {
+                    namespace = node.declareNamespace(namespaceURI, prefix);
+                }
             }
+            node.setNamespaceWithNoFindInCurrentScope(namespace);
         }
+
+
     }
 
 

Modified: 
webservices/commons/trunk/modules/axiom/src/org/apache/axiom/om/impl/dom/ElementImpl.java
URL: 
http://svn.apache.org/viewcvs/webservices/commons/trunk/modules/axiom/src/org/apache/axiom/om/impl/dom/ElementImpl.java?rev=391553&r1=391552&r2=391553&view=diff
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/src/org/apache/axiom/om/impl/dom/ElementImpl.java
 (original)
+++ 
webservices/commons/trunk/modules/axiom/src/org/apache/axiom/om/impl/dom/ElementImpl.java
 Wed Apr  5 00:18:20 2006
@@ -823,15 +823,15 @@
                     return omNamespace;
                 }
             }
-            return null;
+
         } else {
             OMNamespace namespace = (OMNamespace) namespaces.get(prefix);
             if (namespace != null && 
uri.equalsIgnoreCase(namespace.getName())) {
                 return namespace;
-            } else {
-                return null;
             }
         }
+
+        return null;
     }
 
     /**

Modified: 
webservices/commons/trunk/modules/axiom/src/org/apache/axiom/om/impl/llom/OMElementImpl.java
URL: 
http://svn.apache.org/viewcvs/webservices/commons/trunk/modules/axiom/src/org/apache/axiom/om/impl/llom/OMElementImpl.java?rev=391553&r1=391552&r2=391553&view=diff
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/src/org/apache/axiom/om/impl/llom/OMElementImpl.java
 (original)
+++ 
webservices/commons/trunk/modules/axiom/src/org/apache/axiom/om/impl/llom/OMElementImpl.java
 Wed Apr  5 00:18:20 2006
@@ -398,6 +398,11 @@
         }
 
         if (prefix == null || "".equals(prefix)) {
+
+            OMNamespace defaultNamespace = this.getDefaultNamespace();
+            if (defaultNamespace != null && 
uri.equals(defaultNamespace.getName())) {
+               return defaultNamespace;
+            }
             Iterator namespaceListIterator = namespaces.values().iterator();
 
             OMNamespace ns = null;

Modified: 
webservices/commons/trunk/modules/axiom/test/org/apache/axiom/om/impl/serializer/PreserveEnvelopeTest.java
URL: 
http://svn.apache.org/viewcvs/webservices/commons/trunk/modules/axiom/test/org/apache/axiom/om/impl/serializer/PreserveEnvelopeTest.java?rev=391553&r1=391552&r2=391553&view=diff
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/test/org/apache/axiom/om/impl/serializer/PreserveEnvelopeTest.java
 (original)
+++ 
webservices/commons/trunk/modules/axiom/test/org/apache/axiom/om/impl/serializer/PreserveEnvelopeTest.java
 Wed Apr  5 00:18:20 2006
@@ -75,9 +75,11 @@
                                StAXOMBuilder builder = new StAXOMBuilder(new 
ByteArrayInputStream(originalXML.getBytes()));
                            OMElement documentElement = 
builder.getDocumentElement();
                            //assertXMLEqual(originalXML, 
documentElement.toString());
-                           
-                           String outstr  = documentElement.toString();
-                           assertTrue(outstr.indexOf("xmlns:saml=") > 0);
+                           documentElement.build();
+
+                    String outstr  = documentElement.toString();
+                    System.out.println("outstr = " + outstr);
+                    assertTrue(outstr.indexOf("xmlns:saml=") > 0);
                            assertTrue(outstr.indexOf("<Assertion") == 0);
                            
                        } catch (XMLStreamException e) {


Reply via email to