commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mben...@apache.org
Subject svn commit: r666910 - /commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/NamespaceResolver.java
Date Wed, 11 Jun 2008 23:50:29 GMT
Author: mbenson
Date: Wed Jun 11 16:50:29 2008
New Revision: 666910

URL: http://svn.apache.org/viewvc?rev=666910&view=rev
Log:
[JXPATH-123]

Modified:
    commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/NamespaceResolver.java

Modified: commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/NamespaceResolver.java
URL: http://svn.apache.org/viewvc/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/NamespaceResolver.java?rev=666910&r1=666909&r2=666910&view=diff
==============================================================================
--- commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/NamespaceResolver.java
(original)
+++ commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/NamespaceResolver.java
Wed Jun 11 16:50:29 2008
@@ -17,8 +17,6 @@
 package org.apache.commons.jxpath.ri;
 
 import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
 
 import org.apache.commons.jxpath.Pointer;
 import org.apache.commons.jxpath.ri.model.NodeIterator;
@@ -36,7 +34,7 @@
     /** namespace map */
     protected HashMap namespaceMap = new HashMap();
     /** reverse lookup map */
-    protected HashMap reverseMap;
+    protected HashMap reverseMap = new HashMap();
     /** pointer */
     protected NodePointer pointer;
     private boolean sealed;
@@ -94,7 +92,7 @@
                     "Cannot register namespaces on a sealed NamespaceResolver");
         }
         namespaceMap.put(prefix, namespaceURI);
-        reverseMap = null;
+        reverseMap.put(namespaceURI, prefix);
     }
 
     /**
@@ -164,14 +162,6 @@
      * @since JXPath 1.3
      */
     protected synchronized String getExternallyRegisteredPrefix(String namespaceURI) {
-        if (reverseMap == null) {
-            reverseMap = new HashMap();
-            Iterator it = namespaceMap.entrySet().iterator();
-            while (it.hasNext()) {
-                Map.Entry entry = (Map.Entry) it.next();
-                reverseMap.put(entry.getValue(), entry.getKey());
-            }
-        }
         String prefix = (String) reverseMap.get(namespaceURI);
         return prefix == null && parent != null ? parent
                 .getExternallyRegisteredPrefix(namespaceURI) : prefix;



Mime
View raw message