java.lang.Object
org.apache.jena.reasoner.rulesys.impl.BindingVector
- All Implemented Interfaces:
BindingEnvironment
An implementation of a binding environment that maintains
a single array of bound values for the variables in a rule.
Stack management is done externally. This is intended for use in
the Brule system and so also supports variable-variable bindings by
use of reference chains.
-
Constructor Summary
ConstructorDescriptionBindingVector
(int size) Constructor - create an empty binding environmentBindingVector
(Node[] env) Constructor - create a binding environment from a vector of bindingsBindingVector
(BindingVector clone) Constructor - create a binding environment which is a copy of the given environment -
Method Summary
Modifier and TypeMethodDescriptionboolean
Bind the ith variable in the current environment to the given value.boolean
Bind a variable in the current environment to the given value.boolean
Equality overridegetBinding
(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 bindings.getGroundVersion
(Node node) Return the most ground version of the node.int
hashCode()
hash function overrideinstantiate
(TriplePattern pattern) Instantiate a triple pattern against the current environment.partInstantiate
(TriplePattern goal) Bind the variables in a goal pattern using the binding environment, to generate a more specialized goaltoString()
Printable formstatic BindingVector
unify
(TriplePattern goal, TriplePattern head, int numRuleVars) Unify a goal with the head of a rule.
-
Constructor Details
-
BindingVector
public BindingVector(int size) Constructor - create an empty binding environment -
BindingVector
Constructor - create a binding environment from a vector of bindings -
BindingVector
Constructor - create a binding environment which is a copy of the given environment
-
-
Method Details
-
getEnvironment
Return the current array of bindings. Useful for fast access to several bindings, not useful for doing updates. -
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 environment to the given value. Checks that the new binding is compatible with any current binding. Handles aliased variables.- Returns:
- false if the binding fails
-
bind
Bind a variable in the current environment 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
-
partInstantiate
Bind the variables in a goal pattern using the binding environment, to generate a more specialized goal- Parameters:
goal
- the TriplePattern to be instantiated- Returns:
- a TriplePattern obtained from the goal by substituting current bindings
-
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
-
toString
Printable form -
unify
Unify a goal with the head of a rule. This is a poor-man's unification, we should try switching to a more conventional global-variables-with-trail implementation in the future.- Parameters:
goal
- the goal pattern which it being matched to a rulehead
- the head pattern of the rule which is being instantiatednumRuleVars
- the length of the environment to allocate.- Returns:
- An initialized binding environment for the rule variables or null if the unification fails. If a variable in the environment becomes aliased to another variable through the unification this is represented by having its value in the environment be the variable to which it is aliased.
-
equals
Equality override -
hashCode
public int hashCode()hash function override
-