Class RETERuleContext
- java.lang.Object
-
- org.apache.jena.reasoner.rulesys.impl.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.
-
-
Constructor Summary
Constructors Constructor Description RETERuleContext(ForwardRuleInfGraphI graph, RETEEngine engine)
Constructor.
-
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.
-
-
-
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 interfaceRuleContext
- Returns:
- BindingEnvironment
-
getGraph
public InfGraph getGraph()
Returns the graph.- Specified by:
getGraph
in interfaceRuleContext
- Returns:
- InfGraph
-
getEngine
public RETEEngine getEngine()
Returns the RETE engine associated with this context.
-
getRule
public Rule getRule()
Returns the rule.- Specified by:
getRule
in interfaceRuleContext
- Returns:
- Rule
-
setRule
public void setRule(Rule rule)
Sets the rule.- Specified by:
setRule
in interfaceRuleContext
- 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 interfaceRuleContext
-
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 interfaceRuleContext
-
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 interfaceRuleContext
-
silentAdd
public void silentAdd(Triple t)
Assert a new triple in the deduction graph, bypassing any processing machinery.- Specified by:
silentAdd
in interfaceRuleContext
-
remove
public void remove(Triple t)
Remove a triple from the deduction graph (and the original graph if relevant).- Specified by:
remove
in interfaceRuleContext
-
add
public void add(Triple t)
Assert a new triple in the deduction graph, triggering any consequent processing as appropriate.- Specified by:
add
in interfaceRuleContext
-
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.
-
-