Author: dims
Date: Wed Nov 22 08:06:37 2006
New Revision: 478206

URL: http://svn.apache.org/viewvc?view=rev&rev=478206
Log:
- Avoid creating OMNamespace unless it is needed/accessed
- When we do, don't use prefix as the key in the hashmap if it is null/empty


Modified:
    
webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java
    
webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/factory/OMLinkedListImplFactory.java

Modified: 
webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java?view=diff&rev=478206&r1=478205&r2=478206
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java
 (original)
+++ 
webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java
 Wed Nov 22 08:06:37 2006
@@ -52,8 +52,11 @@
     private final OMDataSource dataSource;
     
     /** Namespace for element, needed in order to bypass base class handling. 
*/
-    private OMNamespace definedNamespace;
+    private OMNamespace definedNamespace = null;
     
+    /** Namespace for element, needed in order to bypass base class handling. 
*/
+    private QName definedQName = null;
+
     /** Flag for parser provided to base element class. */
     private boolean isParserSet;
     
@@ -83,12 +86,9 @@
      */
     public OMSourcedElementImpl(QName qName, OMFactory factory, OMDataSource 
source) {
         //create a namespace
-        this(qName.getLocalPart(),
-            factory.createOMNamespace(qName.getNamespaceURI(),
-                                      qName.getPrefix()),
-            factory,
-            source);
-
+        super(qName.getLocalPart(), null, factory);
+        dataSource = source;
+        definedQName = qName;
     }
     
     /**
@@ -417,6 +417,9 @@
      * @see org.apache.axiom.om.OMElement#getNamespace()
      */
     public OMNamespace getNamespace() throws OMException {
+        if(definedNamespace == null && definedQName != null) {
+            definedNamespace = 
factory.createOMNamespace(definedQName.getNamespaceURI(), 
definedQName.getPrefix());
+        }
         return definedNamespace;
     }
 
@@ -442,10 +445,9 @@
     public QName getQName() {
         if (isExpanded()) {
             return super.getQName();
-        } else if (definedNamespace != null) {
+        } else if (getNamespace() != null) {
             // always ignore prefix on name from sourced element
             return new QName(definedNamespace.getNamespaceURI(), 
getLocalName());
-
         } else {
             return new QName(getLocalName());
         }

Modified: 
webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/factory/OMLinkedListImplFactory.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/factory/OMLinkedListImplFactory.java?view=diff&rev=478206&r1=478205&r2=478206
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/factory/OMLinkedListImplFactory.java
 (original)
+++ 
webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/factory/OMLinkedListImplFactory.java
 Wed Nov 22 08:06:37 2006
@@ -114,7 +114,10 @@
      * @return Returns OMNamespace.
      */
     public OMNamespace createOMNamespace(String uri, String prefix) {
-        String key = uri + uriAndPrefixSeparator + prefix;
+        String key = uri;
+        if(prefix != null && prefix.length() > 0) {
+            key = key + uriAndPrefixSeparator + prefix;
+        }
         OMNamespace existingNamespaceObject = (OMNamespace) 
namespaceTable.get(key);
         if (existingNamespaceObject == null) {
             existingNamespaceObject = new OMNamespaceImpl(uri, prefix);



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to