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:53 UTC

svn commit: r153728 - jakarta/commons/proper/digester/branches/digester2/src/java/org/apache/commons/digester2/FallbackRuleManager.java

Author: ozeigermann
Date: Sun Feb 13 23:13:53 2005
New Revision: 153728

URL: http://svn.apache.org/viewcvs?view=rev&rev=153728
Log:
Added intial version of rule manager with default actions

Added:
    jakarta/commons/proper/digester/branches/digester2/src/java/org/apache/commons/digester2/FallbackRuleManager.java

Added: jakarta/commons/proper/digester/branches/digester2/src/java/org/apache/commons/digester2/FallbackRuleManager.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/digester/branches/digester2/src/java/org/apache/commons/digester2/FallbackRuleManager.java?view=auto&rev=153728
==============================================================================
--- jakarta/commons/proper/digester/branches/digester2/src/java/org/apache/commons/digester2/FallbackRuleManager.java (added)
+++ jakarta/commons/proper/digester/branches/digester2/src/java/org/apache/commons/digester2/FallbackRuleManager.java Sun Feb 13 23:13:53 2005
@@ -0,0 +1,79 @@
+/* $Id: DefaultRuleManager.java 153050 2005-02-09 12:12:28Z skitching $
+ *
+ * Copyright 2001-2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */ 
+
+
+package org.apache.commons.digester2;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * @see DefaultRuleManager
+ */
+public class FallbackRuleManager extends DefaultRuleManager {
+
+    protected final List fallbackActions;
+    protected List unmodifiableFallbackActions;
+
+    public FallbackRuleManager(List fallbackActions) {
+        this.fallbackActions = fallbackActions;
+        unmodifiableFallbackActions = Collections.unmodifiableList(fallbackActions);
+    }
+    
+    public FallbackRuleManager() {
+        this(new ArrayList());
+    }
+    
+    public FallbackRuleManager(FallbackRuleManager manager) {
+        this(manager.fallbackActions);
+    }
+    
+    /**
+     * @see DefaultRuleManager#copy()
+     */
+    public RuleManager copy() {
+        return new FallbackRuleManager(this);
+    }
+    
+    /**
+     * @see DefaultRuleManager#getMatchingActions(String)
+     */
+    public List getMatchingActions(String path) {
+        List actionList = super.getMatchingActions(path);
+        if (actionList == Collections.EMPTY_LIST && fallbackActions != null && fallbackActions.size() != 0) {
+            return unmodifiableFallbackActions;
+        } else {
+            return actionList;
+        }
+    }
+
+    public void addFallbackAction(Action action) {
+        fallbackActions.add(action);
+        unmodifiableFallbackActions = Collections.unmodifiableList(fallbackActions);
+    }
+
+    public boolean removeFallbackAction(Action action) {
+        boolean removed = fallbackActions.remove(action);
+        unmodifiableFallbackActions = Collections.unmodifiableList(fallbackActions);
+        return removed;
+    }
+
+    public List getFallbackActions() {
+        return unmodifiableFallbackActions;
+    }
+}



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