You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commons-dev@ws.apache.org by sc...@apache.org on 2008/06/09 16:10:33 UTC

svn commit: r665696 - in /webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom: OMAttributeImpl.java OMElementImpl.java

Author: scheu
Date: Mon Jun  9 07:10:33 2008
New Revision: 665696

URL: http://svn.apache.org/viewvc?rev=665696&view=rev
Log:
AXIS2-3845
Contributor:Takahide Nogayama
Cache the getQName object in both OMAttributeImpl and OMElementImpl.  This says time and prevents unnecessary temporary objects.

Modified:
    webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMAttributeImpl.java
    webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMAttributeImpl.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMAttributeImpl.java?rev=665696&r1=665695&r2=665696&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMAttributeImpl.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMAttributeImpl.java Mon Jun  9 07:10:33 2008
@@ -40,6 +40,8 @@
 
     /** Field namespace */
     private OMNamespace namespace;
+    
+    private QName qName;
 
     /** <code>OMFactory</code> that created this <code>OMAttribute</code> */
     private OMFactory factory;
@@ -68,16 +70,21 @@
 
     /** @return Returns QName. */
     public QName getQName() {
+        if (qName != null) {
+            return qName;
+        }
+
         if (namespace != null) {
             // Guard against QName implementation sillyness.
             if (namespace.getPrefix() == null) {
-                return new QName(namespace.getNamespaceURI(), localName);
+                this.qName = new QName(namespace.getNamespaceURI(), localName);
             } else {
-                return new QName(namespace.getNamespaceURI(), localName, namespace.getPrefix());
+                this.qName =  new QName(namespace.getNamespaceURI(), localName, namespace.getPrefix());
             }
         } else {
-            return new QName(localName);
+            this.qName =  new QName(localName);
         }
+        return this.qName;
     }
 
     // -------- Getters and Setters
@@ -100,6 +107,7 @@
         if (localName == null || localName.trim().length() == 0)
             throw new IllegalArgumentException("Local name may not be null or empty");
         this.localName = localName;
+        this.qName = null;
     }
 
     /**
@@ -145,6 +153,7 @@
      */
     public void setOMNamespace(OMNamespace omNamespace) {
         this.namespace = omNamespace;
+        this.qName = null;
     }
 
     /**

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java?rev=665696&r1=665695&r2=665696&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java Mon Jun  9 07:10:33 2008
@@ -73,12 +73,15 @@
 
     /** Field localName */
     protected String localName;
+
+    protected QName qName;
+
     /** Field firstChild */
     protected OMNode firstChild;
 
     /** Field namespaces */
     protected HashMap namespaces = null;
-
+    
     /** Field attributes */
     protected HashMap attributes = null;
 
@@ -374,6 +377,7 @@
         namespaces.put("", namespace);
         if (ns == null || "".equals(ns.getPrefix())) {
             ns = namespace;
+            this.qName = null;
         }
         return namespace;
     }
@@ -990,6 +994,7 @@
     /** Method setLocalName. */
     public void setLocalName(String localName) {
         this.localName = localName;
+        this.qName = null;
     }
 
     /**
@@ -1008,6 +1013,7 @@
                 // if it was overriden, then we must explicitly declare default default namespace as the namespace
                 // of this element
                 ns = DEFAULT_DEFAULT_NS_OBJECT;
+                this.qName = null;
             }
         }
         return ns;
@@ -1020,10 +1026,12 @@
             nsObject = handleNamespace(namespace);
         }
         this.ns = nsObject;
+        this.qName = null;
     }
 
     public void setNamespaceWithNoFindInCurrentScope(OMNamespace namespace) {
         this.ns = namespace;
+        this.qName = null;
     }
 
     /**
@@ -1032,7 +1040,10 @@
      * @return Returns QName.
      */
     public QName getQName() {
-        QName qName;
+        if (qName != null) {
+            return qName;
+        }
+
         if (ns != null) {
             if (ns.getPrefix() != null) {
                 qName = new QName(ns.getNamespaceURI(), localName, ns.getPrefix());