commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simonetrip...@apache.org
Subject svn commit: r1066030 - /commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/RulesBinderImpl.java
Date Tue, 01 Feb 2011 12:35:58 GMT
Author: simonetripodi
Date: Tue Feb  1 12:35:58 2011
New Revision: 1066030

URL: http://svn.apache.org/viewvc?rev=1066030&view=rev
Log:
the rules binder implementation needs just to store the sequence which rule providers are
registered, then the Rules implementation will take care to store them in the proper data
structure

Modified:
    commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/RulesBinderImpl.java

Modified: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/RulesBinderImpl.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/RulesBinderImpl.java?rev=1066030&r1=1066029&r2=1066030&view=diff
==============================================================================
--- commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/RulesBinderImpl.java
(original)
+++ commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/RulesBinderImpl.java
Tue Feb  1 12:35:58 2011
@@ -18,8 +18,8 @@
 package org.apache.commons.digester3;
 
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.HashMap;
-import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
 
@@ -52,13 +52,13 @@ final class RulesBinderImpl implements R
     /**
      * The data structure where storing the providers binding.
      */
-    private final Map<String, List<RuleProvider<? extends Rule>>> providers;
+    private final Collection<RegisteredProvider> providers;
 
     /**
      * Creates a new {@link RulesBinder} instance with no bound providers.
      */
     public RulesBinderImpl() {
-        this(new LinkedHashMap<String, List<RuleProvider<? extends Rule>>>());
+        this(new ArrayList<RegisteredProvider>());
     }
 
     /**
@@ -67,7 +67,7 @@ final class RulesBinderImpl implements R
      *
      * @param providers the data structure where storing the providers binding.
      */
-    public RulesBinderImpl(Map<String, List<RuleProvider<? extends Rule>>>
providers) {
+    public RulesBinderImpl(Collection<RegisteredProvider> providers) {
         this.providers = providers;
     }
 
@@ -492,12 +492,7 @@ final class RulesBinderImpl implements R
                     return provider;
                 }
 
-                List<RuleProvider<? extends Rule>> providerLits = providers.get(keyPattern);
-                if (providerLits == null) {
-                    providerLits = new ArrayList<RuleProvider<? extends Rule>>();
-                    providers.put(keyPattern, providerLits);
-                }
-                providerLits.add(provider);
+                providers.add(new RegisteredProvider(keyPattern, provider));
 
                 return provider;
             }
@@ -518,6 +513,30 @@ final class RulesBinderImpl implements R
     }
 
     /**
+     * Used to associate rule providers with paths in the rules binder.
+     */
+    private static class RegisteredProvider {
+
+        private final String pattern;
+
+        private final RuleProvider<? extends Rule> provider;
+
+        public <R extends Rule> RegisteredProvider(String pattern, RuleProvider<R>
provider) {
+            this.pattern = pattern;
+            this.provider = provider;
+        }
+
+        public String getPattern() {
+            return pattern;
+        }
+
+        public RuleProvider<? extends Rule> getProvider() {
+            return provider;
+        }
+
+    }
+
+    /**
      * Abstract {@link ParamTypeBuilder} implementation for {@code setNext()}, {@code setRoot()}
and {@code setTop()}
      *
      * @param <R> The rule type has to be created



Mime
View raw message