You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by oz...@apache.org on 2005/02/14 08:13:26 UTC
svn commit: r153727 -
jakarta/commons/proper/digester/branches/digester2/src/java/org/apache/commons/digester2/DefaultRuleManager.java
Author: ozeigermann
Date: Sun Feb 13 23:13:25 2005
New Revision: 153727
URL: http://svn.apache.org/viewcvs?view=rev&rev=153727
Log:
- Rigid protection of guts by making member variables private and passing
umodifiable list back from getMatchingActions.
- Added copy contructor to allow copying of member variables from sub
classes
Modified:
jakarta/commons/proper/digester/branches/digester2/src/java/org/apache/commons/digester2/DefaultRuleManager.java
Modified: jakarta/commons/proper/digester/branches/digester2/src/java/org/apache/commons/digester2/DefaultRuleManager.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/digester/branches/digester2/src/java/org/apache/commons/digester2/DefaultRuleManager.java?view=diff&r1=153726&r2=153727
==============================================================================
--- jakarta/commons/proper/digester/branches/digester2/src/java/org/apache/commons/digester2/DefaultRuleManager.java (original)
+++ jakarta/commons/proper/digester/branches/digester2/src/java/org/apache/commons/digester2/DefaultRuleManager.java Sun Feb 13 23:13:25 2005
@@ -19,6 +19,7 @@
package org.apache.commons.digester2;
+import java.util.Collections;
import java.util.Map;
import java.util.HashMap;
import java.util.List;
@@ -58,37 +59,56 @@
* Map of namespace-prefix to namespace-uri, used only by the
* addAction() method.
*/
- protected HashMap namespaces = new HashMap();
+ private HashMap namespaces = new HashMap();
/**
* The list of all actions in the cache. This set allows us to
* iterate over the set of actions to invoke the startParse/finishParse
* methods.
*/
- protected ArrayList actions = new ArrayList(20);
+ private ArrayList actions = new ArrayList(20);
/**
* Map of expanded-pattern -> list-of-actions, so that we can
* find the pattern that matches the current xml element, then
* return the list of actions.
*/
- protected MultiHashMap rules = new MultiHashMap();
+ private MultiHashMap rules = new MultiHashMap();
+
+ // ---------------------------------------------------------
+ // Ctor
+ // ---------------------------------------------------------
+
+ /**
+ * Default ctor.
+ */
+ public DefaultRuleManager() {
+ }
+
+ /**
+ * Returns a clone of this object. The Action objects currently
+ * registered are not copied, as Action objects are required to be
+ * re-entrant and thread-safe.
+ */
+ public DefaultRuleManager(DefaultRuleManager manager) {
+ this.namespaces = (HashMap) manager.namespaces.clone();
+ this.actions = (ArrayList) manager.actions.clone();
+ this.rules = (MultiHashMap) manager.rules.clone();
+ }
+
+
// ---------------------------------------------------------
// Public Methods
// ---------------------------------------------------------
/**
- * Return a clone of this object. The Action objects currently
+ * Returns a clone of this object. The Action objects currently
* registered are not copied, as Action objects are required to be
* re-entrant and thread-safe.
*/
public RuleManager copy() {
- DefaultRuleManager copy = new DefaultRuleManager();
- copy.namespaces = (HashMap) this.namespaces.clone();
- copy.actions = (ArrayList) this.actions.clone();
- copy.rules = (MultiHashMap) this.rules.clone();
- return copy;
+ return new DefaultRuleManager(this);
}
/**
@@ -229,7 +249,7 @@
return java.util.Collections.EMPTY_LIST;
}
else {
- return actionList;
+ return Collections.unmodifiableList(actionList);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org