Class BBRuleContext
- java.lang.Object
-
- org.apache.jena.reasoner.rulesys.impl.BBRuleContext
-
- All Implemented Interfaces:
RuleContext
public class BBRuleContext extends java.lang.Object implements RuleContext
Implementation of RuleContext for use in the backward chaining interpreter. The RuleContext allows builtin predicates to interpret variable bindings to access the static triple data.
-
-
Constructor Summary
Constructors Constructor Description BBRuleContext(BackwardRuleInfGraphI graph)
Construct an empty context.
-
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.BindingEnvironment
getEnv()
Returns the current variable binding environment for the current rule.InfGraph
getGraph()
Returns the parent inference graph.Rule
getRule()
Returns the rule.Node
getTemp(Node instance, Node prop, Node pclass)
Retrieve or create a bNode representing an inferred property value.void
remove(Triple t)
Remove a triple from the deduction graph (and the original graph if relevant).void
setEnv(BindingEnvironment env)
Set the binding environment for the this contextvoid
setRule(Rule rule)
Sets the rule.void
silentAdd(Triple t)
Assert a new triple in the deduction graph, bypassing any processing machinery.
-
-
-
Constructor Detail
-
BBRuleContext
public BBRuleContext(BackwardRuleInfGraphI graph)
Construct an empty context. It can't be used until the rule and environment have been set.
-
-
Method Detail
-
contains
public boolean contains(Node s, Node p, Node o)
Description copied from interface:RuleContext
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
- See Also:
RuleContext.contains(org.apache.jena.graph.Node, org.apache.jena.graph.Node, org.apache.jena.graph.Node)
-
contains
public boolean contains(Triple t)
Description copied from interface:RuleContext
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
- See Also:
RuleContext.contains(org.apache.jena.graph.Triple)
-
find
public ClosableIterator<Triple> find(Node s, Node p, Node o)
Description copied from interface:RuleContext
In some formulations the context includes deductions that are not yet visible to the underlying graph but need to be checked for.- Specified by:
find
in interfaceRuleContext
- See Also:
RuleContext.find(org.apache.jena.graph.Node, org.apache.jena.graph.Node, org.apache.jena.graph.Node)
-
getEnv
public BindingEnvironment getEnv()
Description copied from interface:RuleContext
Returns the current variable binding environment for the current rule.- Specified by:
getEnv
in interfaceRuleContext
- Returns:
- BindingEnvironment
- See Also:
RuleContext.getEnv()
-
setEnv
public void setEnv(BindingEnvironment env)
Set the binding environment for the this context
-
getGraph
public InfGraph getGraph()
Description copied from interface:RuleContext
Returns the parent inference graph.- Specified by:
getGraph
in interfaceRuleContext
- Returns:
- InfGraph
- See Also:
RuleContext.getGraph()
-
getRule
public Rule getRule()
Description copied from interface:RuleContext
Returns the rule.- Specified by:
getRule
in interfaceRuleContext
- Returns:
- Rule
- See Also:
RuleContext.getRule()
-
setRule
public void setRule(Rule rule)
Description copied from interface:RuleContext
Sets the rule.- Specified by:
setRule
in interfaceRuleContext
- Parameters:
rule
- The rule to set- See Also:
RuleContext.setRule(org.apache.jena.reasoner.rulesys.Rule)
-
silentAdd
public void silentAdd(Triple t)
Assert a new triple in the deduction graph, bypassing any processing machinery.- Specified by:
silentAdd
in interfaceRuleContext
-
add
public void add(Triple t)
Assert a new triple in the deduction graph, triggering any consequent processing as appropriate. In the backward case there no immediate consequences so this is equivalent to a silentAdd.- Specified by:
add
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
-
getTemp
public Node getTemp(Node instance, Node prop, Node pclass)
Retrieve or create a bNode representing an inferred property value. This is currently only available on backward contexts and not part of the normal RuleContext interface.- Parameters:
instance
- the base instance node to which the property appliesprop
- the property node whose value is being inferredpclass
- the (optional, can be null) class for the inferred value.- Returns:
- the bNode representing the property value
-
-