Class RETERuleContext

All Implemented Interfaces:

public class RETERuleContext extends Object implements RuleContext
An implementation of the generic RuleContext for use in the RETE implementation. The RuleContext is used to supply context information to the builtin operations.
  • Constructor Details

    • RETERuleContext

      public RETERuleContext(ForwardRuleInfGraphI graph, RETEEngine engine)
      graph - the inference graph which owns this context.
  • Method Details

    • getEnv

      public BindingEnvironment getEnv()
      Returns the current variable binding environment for the current rule.
      Specified by:
      getEnv in interface RuleContext
    • getGraph

      public InfGraph getGraph()
      Returns the graph.
      Specified by:
      getGraph in interface RuleContext
    • getEngine

      public RETEEngine getEngine()
      Returns the RETE engine associated with this context.
    • getRule

      public Rule getRule()
      Returns the rule.
      Specified by:
      getRule in interface RuleContext
    • setRule

      public void setRule(Rule rule)
      Sets the rule.
      Specified by:
      setRule in interface RuleContext
      rule - The rule to set
    • setEnv

      public void setEnv(BindingEnvironment env)
      Sets the current binding environment for this context.
      env - the binding environment so far
    • contains

      public boolean contains(Triple t)
      Return true if the triple is already in either the graph or the stack. I.e. it has already been deduced.
      Specified by:
      contains in interface RuleContext
    • contains

      public boolean contains(Node s, Node p, Node o)
      Return true if the triple pattern is already in either the graph or the stack. I.e. it has already been deduced.
      Specified by:
      contains in interface RuleContext
    • find

      public ClosableIterator<Triple> find(Node s, Node p, Node o)
      In some formulations the context includes deductions that are not yet visible to the underlying graph but need to be checked for. However, currently this calls the graph find directly.
      Specified by:
      find in interface RuleContext
    • silentAdd

      public void silentAdd(Triple t)
      Assert a new triple in the deduction graph, bypassing any processing machinery.
      Specified by:
      silentAdd in interface RuleContext
    • remove

      public void remove(Triple t)
      Remove a triple from the deduction graph (and the original graph if relevant).
      Specified by:
      remove in interface RuleContext
    • add

      public void add(Triple t)
      Assert a new triple in the deduction graph, triggering any consequent processing as appropriate.
      Specified by:
      add in interface RuleContext
    • shouldFire

      public boolean shouldFire(boolean allowUnsafe)
      Check whether the rule should fire in this context.
    • shouldStillFire

      public boolean shouldStillFire()
      Check if a rule from the conflict set is still OK to fire. Just checks the non-monotonic guards such as noValue.