java.lang.Object
org.apache.jena.reasoner.rulesys.impl.BFRuleContext
- All Implemented Interfaces:
RuleContext
An implementation of the generic RuleContext interface used by
the basic forward (BF) rule engine. This provides additional
methods specific to the functioning of that engine.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd a triple to a temporary "pending" store, ready to be added to added to the deductions graph and the processing stack later.voidAdd a triple to the stack of triples to waiting to be processed by the rule engine.booleanReturn true if the triple pattern is already in either the graph or the stack.booleanReturn true if the triple is already in either the graph or the stack.In some formulations the context includes deductions that are not yet visible to the underlying graph but need to be checked for.voidTake all the pending triples and add them to both the given graph and to the processing stack.getEnv()Returns the current variable binding environment for the current rule.Variant of the generic getEnv interface specific to the basic forward rule system.getGraph()Returns the graph.Return the next triple to be added to the graph, removing it from the stack.getRule()Returns the rule.voidRemove a triple from the deduction graph (and the original graph if relevant).voidresetEnv(int newSize) Reset the binding environment back to empty.voidSets the rule.voidAssert a new triple in the deduction graph, bypassing any processing machinery.
-
Constructor Details
-
BFRuleContext
Constructor.- Parameters:
graph- the inference graph which owns this context.
-
-
Method Details
-
getEnv
Returns the current variable binding environment for the current rule.- Specified by:
getEnvin interfaceRuleContext- Returns:
- BindingEnvironment
-
getEnvStack
Variant of the generic getEnv interface specific to the basic forward rule system. Returns the current variable binding environment for the current rule.- Returns:
- BindingStack
-
getGraph
Returns the graph.- Specified by:
getGraphin interfaceRuleContext- Returns:
- InfGraph
-
getRule
Returns the rule.- Specified by:
getRulein interfaceRuleContext- Returns:
- Rule
-
setRule
Sets the rule.- Specified by:
setRulein interfaceRuleContext- Parameters:
rule- The rule to set
-
addTriple
Add a triple to the stack of triples to waiting to be processed by the rule engine. -
add
Add a triple to a temporary "pending" store, ready to be added to added to the deductions graph and the processing stack later.This is needed to prevent concurrent modification exceptions which searching the deductions for matches to a given rule.
- Specified by:
addin interfaceRuleContext
-
flushPending
public void flushPending()Take all the pending triples and add them to both the given graph and to the processing stack. -
contains
Return true if the triple is already in either the graph or the stack. I.e. it has already been deduced.- Specified by:
containsin interfaceRuleContext
-
contains
Return true if the triple pattern is already in either the graph or the stack. I.e. it has already been deduced.- Specified by:
containsin interfaceRuleContext
-
find
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:
findin interfaceRuleContext
-
getNextTriple
Return the next triple to be added to the graph, removing it from the stack.- Returns:
- the Triple or null if there are no more
-
resetEnv
public void resetEnv(int newSize) Reset the binding environment back to empty.- Parameters:
newSize- the number of variables needed for processing the new rule
-
silentAdd
Assert a new triple in the deduction graph, bypassing any processing machinery.- Specified by:
silentAddin interfaceRuleContext
-
remove
Remove a triple from the deduction graph (and the original graph if relevant).- Specified by:
removein interfaceRuleContext
-