java.lang.Object
org.apache.jena.reasoner.rulesys.impl.BindingStack
- All Implemented Interfaces:
BindingEnvironment
Provides a trail of possible variable bindings for a forward rule.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Bind the ith variable in the current envionment to the given value.boolean
Bind a variable in the current envionment to the given value.void
bindNoCheck
(Node_RuleVariable var, Node value) Bind a variable in the current envionment to the given value.void
commit()
Forget the previously pushed state but keep the current environment.getBinding
(Node node) If the node is a variable then return the current binding (null if not bound) otherwise return the node itself.Node[]
Return the current array of bindingsgetGroundVersion
(Node node) Return the most ground version of the node.instantiate
(TriplePattern pattern) Instantiate a triple pattern against the current environment.void
push()
Save the current environment on an internal stackvoid
reset
(int newSize) Reset the binding environment to empty.void
unwind()
Forget the current environment and return the previously pushed state.
-
Constructor Details
-
BindingStack
public BindingStack()Constructor. The stack isn't ready for use until reset has been called.
-
-
Method Details
-
push
public void push()Save the current environment on an internal stack -
unwind
Forget the current environment and return the previously pushed state.- Throws:
IndexOutOfBoundsException
- if there was not previous push
-
commit
Forget the previously pushed state but keep the current environment.- Throws:
IndexOutOfBoundsException
- if there was not previous push
-
reset
public void reset(int newSize) Reset the binding environment to empty.- Parameters:
newSize
- the number of variables needed for processing the new rule
-
getEnvironment
Return the current array of bindings -
getBinding
If the node is a variable then return the current binding (null if not bound) otherwise return the node itself. -
getGroundVersion
Return the most ground version of the node. If the node is not a variable just return it, if it is a variable bound in this environment return the binding, if it is an unbound variable return the variable.- Specified by:
getGroundVersion
in interfaceBindingEnvironment
-
bind
Bind the ith variable in the current envionment to the given value. Checks that the new binding is compatible with any current binding.- Returns:
- false if the binding fails
-
bind
Bind a variable in the current envionment to the given value. Checks that the new binding is compatible with any current binding.- Specified by:
bind
in interfaceBindingEnvironment
- Parameters:
var
- a Node_RuleVariable defining the variable to bindvalue
- the value to bind- Returns:
- false if the binding fails
-
bindNoCheck
Bind a variable in the current envionment to the given value. Overrides and ignores any current binding.- Parameters:
var
- a Node_RuleVariable defining the variable to bindvalue
- the value to bind
-
instantiate
Instantiate a triple pattern against the current environment. This version handles unbound variables by turning them into bNodes.- Specified by:
instantiate
in interfaceBindingEnvironment
- Parameters:
pattern
- the triple pattern to match- Returns:
- a new, instantiated triple
-