commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mben...@apache.org
Subject svn commit: r546994 - /jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/NamespaceResolver.java
Date Wed, 13 Jun 2007 18:45:44 GMT
Author: mbenson
Date: Wed Jun 13 11:45:43 2007
New Revision: 546994

URL: http://svn.apache.org/viewvc?view=rev&rev=546994
Log:
complete sealing handling

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

Modified: jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/NamespaceResolver.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/NamespaceResolver.java?view=diff&rev=546994&r1=546993&r2=546994
==============================================================================
--- jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/NamespaceResolver.java
(original)
+++ jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/NamespaceResolver.java
Wed Jun 13 11:45:43 2007
@@ -51,14 +51,17 @@
     public NamespaceResolver(NamespaceResolver parent) {
         this.parent = parent;
     }
-    
+
     /**
      * Registers a namespace prefix.
      * 
      * @param prefix A namespace prefix
      * @param namespaceURI A URI for that prefix
      */
-    public void registerNamespace(String prefix, String namespaceURI) {
+    public synchronized void registerNamespace(String prefix, String namespaceURI) {
+        if (isSealed()) {
+            throw new IllegalStateException("Cannot register namespaces on a sealed NamespaceResolver");
+        }
         namespaceMap.put(prefix, namespaceURI);
         reverseMap = null;
     }
@@ -92,7 +95,7 @@
      * @param prefix The namespace prefix to look up
      * @return namespace URI or null if the prefix is undefined.
      */
-    public String getNamespaceURI(String prefix) {
+    public synchronized String getNamespaceURI(String prefix) {
         String uri = (String) namespaceMap.get(prefix);
         if (uri == null && pointer != null) {
             uri = pointer.getNamespaceURI(prefix);
@@ -108,7 +111,7 @@
      * @param namespaceURI the ns URI to check.
      * @return String prefix
      */
-    public String getPrefix(String namespaceURI) {
+    public synchronized String getPrefix(String namespaceURI) {
         if (reverseMap == null) {
             reverseMap = new HashMap();
             NodeIterator ni = pointer.namespaceIterator();
@@ -159,7 +162,9 @@
      */
     public Object clone() {
         try {
-            return super.clone();
+            NamespaceResolver result = (NamespaceResolver) super.clone();
+            result.sealed = false;
+            return result;
         }
         catch (CloneNotSupportedException e) {
             // Of course, it's supported.



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message