/** * Create a new Rete pattern matcher functionality. */ public RetePatternMatcherFunctionality(IRulebase rulebase) { this.rulebase = rulebase; this.node = new ReteNode(); // Build existing rules of the rulebase. for(Iterator it=rulebase.getRules().iterator(); it.hasNext(); ) node.addRule((IRule)it.next()); node.setInited(true); rulebase.addRulebaseListener(this); }
/** * Clone this object. * @return A clone of this object. */ public Object clone() { RetePatternMatcherFunctionality ret = null; try { ret = (RetePatternMatcherFunctionality)super.clone(); ret.rulebase = (IRulebase)rulebase.clone(); ret.rulebase.addRulebaseListener(ret); ret.node = (ReteNode)node.clone(); } catch(CloneNotSupportedException exception) { throw new RuntimeException("Cloning not supported: "+this); } return ret; } }
/** * Dispose the panel * and remove all listeners. */ public void dispose() { rulebase.removeRulebaseListener(listener); }
/** * Get a unique rulename for a given rulename. * @param rb The rulebase. * @param rulename The rulename. * @return The (possibly modified) rulename. */ public static String getUniqueRuleName(IRulebase rb, String rulename) { int count = 1; String suffix = ""; Rule testrule = new Rule(rulename+suffix, null, null); while(rb.getRules().contains(testrule)) { suffix = "_"+count; testrule = new Rule(rulename+suffix, null, null); } return testrule.getName(); } }
fncon.addConstraint(new BoundConstraint(null, fn)); fncon.addConstraint(new LiteralConstraint(fibo_has_value, Long.valueOf(-1))); rete.getRulebase().addRule(new Rule("recurse", fncon, new IAction() f1con.addConstraint(new LiteralConstraint(fibo_has_value, Long.valueOf(-1))); f1con.addConstraint(new LiteralConstraint(fibo_has_sequence, Integer.valueOf(1))); rete.getRulebase().addRule(new Rule("bootstrap1", f1con, new IAction() f2con.addConstraint(new LiteralConstraint(fibo_has_value, Long.valueOf(-1))); f2con.addConstraint(new LiteralConstraint(fibo_has_sequence, Integer.valueOf(2))); rete.getRulebase().addRule(new Rule("bootstrap2", f2con, new IAction() new Object[]{f1seq, new FunctionCall(new Sub(), new Object[]{f2seq, Integer.valueOf(1)})}))); rete.getRulebase().addRule(new Rule("calc", new AndCondition(new ICondition[]{f00con, f11con, f22con}), new IAction()
/** * Get a unique rulename for a given rulename. * @param rb The rulebase. * @param rulename The rulename. * @return The (possibly modified) rulename. */ public static String getUniqueRuleName(IRulebase rb, String rulename) { int count = 1; String suffix = ""; Rule testrule = new Rule(rulename+suffix, null, null); while(rb.getRules().contains(testrule)) { suffix = "_"+count; testrule = new Rule(rulename+suffix, null, null); } return testrule.getName(); } }
system.getRulebase().addRule(rule);
/** * Create a new Rete pattern matcher functionality. */ public RetePatternMatcherFunctionality(IRulebase rulebase) { this.rulebase = rulebase; this.node = new ReteNode(); // Build existing rules of the rulebase. for(Iterator it=rulebase.getRules().iterator(); it.hasNext(); ) node.addRule((IRule)it.next()); node.setInited(true); rulebase.addRulebaseListener(this); }
for(Iterator it=matcherfunc.getRulebase().getRules().iterator(); it.hasNext(); ) names.add(((IRule)it.next()).getName()); modelinfo.addProperty("debugger.breakpoints", names);
/** * Clone this object. * @return A clone of this object. */ public Object clone() { RetePatternMatcherFunctionality ret = null; try { ret = (RetePatternMatcherFunctionality)super.clone(); ret.rulebase = (IRulebase)rulebase.clone(); ret.rulebase.addRulebaseListener(ret); ret.node = (ReteNode)node.clone(); } catch(CloneNotSupportedException exception) { throw new RuntimeException("Cloning not supported: "+this); } return ret; } }
this.rulebase = rulebase; this.rules = new ArrayList(); for(Iterator it=rulebase.getRules().iterator(); it.hasNext(); ) rules.add(((IRule)it.next()).getName()); rulebase.addRulebaseListener(listener);