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

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Mon Aug 18 08:14:48 EDT 2008


Author: dsotty
Date: 2008-08-18 08:14:48 -0400 (Mon, 18 Aug 2008)
New Revision: 21603

Added:
   labs/jbossrules/branches/uncDrools5x/drools-core/src/main/java/org/drools/reteoo/UncertainClassObjectTypeConf.java
Log:
New branch for uncertainty support in 5.x

Added: labs/jbossrules/branches/uncDrools5x/drools-core/src/main/java/org/drools/reteoo/UncertainClassObjectTypeConf.java
===================================================================
--- labs/jbossrules/branches/uncDrools5x/drools-core/src/main/java/org/drools/reteoo/UncertainClassObjectTypeConf.java	                        (rev 0)
+++ labs/jbossrules/branches/uncDrools5x/drools-core/src/main/java/org/drools/reteoo/UncertainClassObjectTypeConf.java	2008-08-18 12:14:48 UTC (rev 21603)
@@ -0,0 +1,82 @@
+/**
+ * 
+ */
+package org.drools.reteoo;
+
+import java.util.ArrayList;
+import java.util.Hashtable;
+import java.util.List;
+
+import org.drools.FactException;
+import org.drools.IUncertainRuleBase;
+import org.drools.common.InternalRuleBase;
+import org.drools.rule.EntryPoint;
+
+import uncertainty.truthvals.IUncertainDegree;
+
+/**
+ * @author sotty
+ *
+ */
+public class UncertainClassObjectTypeConf extends ClassObjectTypeConf implements
+		UncertainObjectTypeConf {
+
+	
+	private Hashtable<ObjectTypeNode, IUncertainDegree> matchMap = null;
+	
+	
+	public UncertainClassObjectTypeConf(final EntryPoint entryPoint,
+            final Class< ? > clazz,
+            final InternalRuleBase ruleBase) {		
+		super(entryPoint, clazz, ruleBase);
+		
+	}
+	
+	
+	
+	
+	
+	/**
+	 * Should not be used...
+	 */
+	public ObjectTypeNode[] getObjectTypeNodes() {       
+        return getMatchingObjectTypes(cls);
+    }
+
+	
+    public ObjectTypeNode[] getMatchingObjectTypes(final Class clazz) throws FactException {
+        final List<ObjectTypeNode> cache = new ArrayList<ObjectTypeNode>();
+
+        for ( ObjectTypeNode node : ruleBase.getRete().getObjectTypeNodes( this.entryPoint ).values() ) {
+            if ( node.isAssignableFrom( clazz ) ) {
+                cache.add( node );
+            }
+        }
+
+        return (ObjectTypeNode[]) cache.toArray( new ObjectTypeNode[cache.size()] );
+    }
+
+
+	/* (non-Javadoc)
+	 * @see org.drools.reteoo.UncertainObjectTypeConf#getMatchDegrees()
+	 */
+	public Hashtable<ObjectTypeNode, IUncertainDegree> getMatchDegrees() {					
+		
+		if ( this.matchMap == null ) {
+	        this.matchMap = new Hashtable<ObjectTypeNode, IUncertainDegree>();
+	        
+	        for ( ObjectTypeNode node : ruleBase.getRete().getObjectTypeNodes( this.entryPoint ).values() ) {
+	            
+	            matchMap.put(node, node.isSubClass(this.cls, ((IUncertainRuleBase) this.ruleBase).getTruthFactory()));
+	        }   	
+	        
+	    }
+	    return this.matchMap;
+	}
+	
+	
+    
+    
+		
+
+}




More information about the jboss-svn-commits mailing list