Class RETERuleContext

  • All Implemented Interfaces:
    RuleContext

    public class RETERuleContext
    extends java.lang.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.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void add​(Triple t)
      Assert a new triple in the deduction graph, triggering any consequent processing as appropriate.
      boolean contains​(Node s, Node p, Node o)
      Return true if the triple pattern is already in either the graph or the stack.
      boolean contains​(Triple t)
      Return true if the triple is already in either the graph or the stack.
      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.
      RETEEngine getEngine()
      Returns the RETE engine associated with this context.
      BindingEnvironment getEnv()
      Returns the current variable binding environment for the current rule.
      InfGraph getGraph()
      Returns the graph.
      Rule getRule()
      Returns the rule.
      void remove​(Triple t)
      Remove a triple from the deduction graph (and the original graph if relevant).
      void setEnv​(BindingEnvironment env)
      Sets the current binding environment for this context.
      void setRule​(Rule rule)
      Sets the rule.
      boolean shouldFire​(boolean allowUnsafe)
      Check whether the rule should fire in this context.
      boolean shouldStillFire()
      Check if a rule from the conflict set is still OK to fire.
      void silentAdd​(Triple t)
      Assert a new triple in the deduction graph, bypassing any processing machinery.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • RETERuleContext

        public RETERuleContext​(ForwardRuleInfGraphI graph,
                               RETEEngine engine)
        Constructor.
        Parameters:
        graph - the inference graph which owns this context.
    • Method Detail

      • getEnv

        public BindingEnvironment getEnv()
        Returns the current variable binding environment for the current rule.
        Specified by:
        getEnv in interface RuleContext
        Returns:
        BindingEnvironment
      • 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
        Returns:
        Rule
      • setRule

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

        public void setEnv​(BindingEnvironment env)
        Sets the current binding environment for this context.
        Parameters:
        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.