You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ra...@apache.org on 2008/12/23 21:45:23 UTC

svn commit: r729104 - /commons/proper/digester/trunk/src/java/org/apache/commons/digester/WithDefaultsRulesWrapper.java

Author: rahul
Date: Tue Dec 23 12:45:23 2008
New Revision: 729104

URL: http://svn.apache.org/viewvc?rev=729104&view=rev
Log:
Use generics and for-each.

Modified:
    commons/proper/digester/trunk/src/java/org/apache/commons/digester/WithDefaultsRulesWrapper.java

Modified: commons/proper/digester/trunk/src/java/org/apache/commons/digester/WithDefaultsRulesWrapper.java
URL: http://svn.apache.org/viewvc/commons/proper/digester/trunk/src/java/org/apache/commons/digester/WithDefaultsRulesWrapper.java?rev=729104&r1=729103&r2=729104&view=diff
==============================================================================
--- commons/proper/digester/trunk/src/java/org/apache/commons/digester/WithDefaultsRulesWrapper.java (original)
+++ commons/proper/digester/trunk/src/java/org/apache/commons/digester/WithDefaultsRulesWrapper.java Tue Dec 23 12:45:23 2008
@@ -19,7 +19,6 @@
 package org.apache.commons.digester;
 
 import java.util.ArrayList;
-import java.util.Iterator;
 import java.util.List;
 
 /**
@@ -54,9 +53,9 @@
     /** The Rules implementation that this class wraps. */
     private Rules wrappedRules;
     /** Rules to be fired when the wrapped implementations returns none. */
-    private List defaultRules = new ArrayList();
+    private List<Rule> defaultRules = new ArrayList<Rule>();
     /** All rules (preserves order in which they were originally added) */
-    private List allRules = new ArrayList();
+    private List<Rule> allRules = new ArrayList<Rule>();
     
     // --------------------------------------------------------- Constructor
     
@@ -83,9 +82,7 @@
     /** Sets digeseter using these Rules */
     public void setDigester(Digester digester) {
         wrappedRules.setDigester(digester);
-        Iterator it = defaultRules.iterator();
-        while (it.hasNext()) {
-            Rule rule = (Rule) it.next();
+        for (Rule rule : defaultRules) {
             rule.setDigester(digester);
         }
     }
@@ -101,13 +98,13 @@
     }
     
     /** Gets Rule's which will be fired when the wrapped implementation returns no matches */
-    public List getDefaults() {
+    public List<Rule> getDefaults() {
         return defaultRules;
     }
     
     // --------------------------------------------------------- Public Methods
     
-    public List match(String pattern) {
+    public List<Rule> match(String pattern) {
         return match("", pattern);
     }
     
@@ -116,11 +113,11 @@
      * If wrapped implementation returns any matches return those.
      * Otherwise, return default matches.
      */
-    public List match(String namespaceURI, String pattern) {
-        List matches = wrappedRules.match(namespaceURI, pattern);
+    public List<Rule> match(String namespaceURI, String pattern) {
+        List<Rule> matches = wrappedRules.match(namespaceURI, pattern);
         if (matches ==  null || matches.isEmpty()) {
             // a little bit of defensive programming
-            return new ArrayList(defaultRules);
+            return new ArrayList<Rule>(defaultRules);
         }
         // otherwise
         return matches;
@@ -142,7 +139,7 @@
     }
     
     /** Gets all rules */
-    public List rules() {
+    public List<Rule> rules() {
         return allRules;
     }