[jboss-svn-commits] JBL Code SVN: r18352 - labs/jbossrules/branches/4.0.x/drools-core/src/main/java/org/drools/reteoo.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Wed Feb 6 13:39:48 EST 2008


Author: tirelli
Date: 2008-02-06 13:39:48 -0500 (Wed, 06 Feb 2008)
New Revision: 18352

Added:
   labs/jbossrules/branches/4.0.x/drools-core/src/main/java/org/drools/reteoo/RuleRemovalContext.java
Log:
JBRULES-1315: adding missing file

Added: labs/jbossrules/branches/4.0.x/drools-core/src/main/java/org/drools/reteoo/RuleRemovalContext.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-core/src/main/java/org/drools/reteoo/RuleRemovalContext.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-core/src/main/java/org/drools/reteoo/RuleRemovalContext.java	2008-02-06 18:39:48 UTC (rev 18352)
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2008 JBoss Inc
+ * 
+ * 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.
+ *
+ * Created on Feb 6, 2008
+ */
+
+package org.drools.reteoo;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.drools.common.BaseNode;
+
+/**
+ * This context class is used during rule removal to ensure
+ * network consistency.
+ * 
+ * @author etirelli
+ *
+ */
+public class RuleRemovalContext
+    implements
+    Serializable {
+    
+    private Map visitedNodes;
+    
+    public RuleRemovalContext() {
+        this.visitedNodes = new HashMap();
+    }
+    
+    /**
+     * We need to track tuple source nodes that we visit
+     * to avoid multiple removal in case of subnetworks
+     * 
+     * @param node
+     */
+    public void visitTupleSource( TupleSource node ) {
+        this.visitedNodes.put( new Integer(node.getId()), node );
+    }
+    
+    /**
+     * We need to track tuple source nodes that we visit
+     * to avoid multiple removal in case of subnetworks
+     * 
+     * @param node
+     * @return
+     */
+    public boolean alreadyVisited( TupleSource node ) {
+        return this.visitedNodes.containsKey( new Integer( node.getId() ) );
+    }
+
+    public void clear() {
+        this.visitedNodes.clear();
+    }
+}




More information about the jboss-svn-commits mailing list