Class BindingStack

java.lang.Object
org.apache.jena.reasoner.rulesys.impl.BindingStack
All Implemented Interfaces:
BindingEnvironment

public class BindingStack extends Object implements BindingEnvironment
Provides a trail of possible variable bindings for a forward rule.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    bind(int i, Node value)
    Bind the ith variable in the current envionment to the given value.
    boolean
    bind(Node var, Node value)
    Bind a variable in the current envionment to the given value.
    void
    Bind a variable in the current envionment to the given value.
    void
    Forget the previously pushed state but keep the current environment.
    If the node is a variable then return the current binding (null if not bound) otherwise return the node itself.
    Return the current array of bindings
    Return the most ground version of the node.
    Instantiate a triple pattern against the current environment.
    void
    Save the current environment on an internal stack
    void
    reset(int newSize)
    Reset the binding environment to empty.
    void
    Forget the current environment and return the previously pushed state.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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

      public void unwind() throws IndexOutOfBoundsException
      Forget the current environment and return the previously pushed state.
      Throws:
      IndexOutOfBoundsException - if there was not previous push
    • commit

      public void commit() throws IndexOutOfBoundsException
      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

      public Node[] getEnvironment()
      Return the current array of bindings
    • getBinding

      public Node getBinding(Node node)
      If the node is a variable then return the current binding (null if not bound) otherwise return the node itself.
    • getGroundVersion

      public Node getGroundVersion(Node node)
      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 interface BindingEnvironment
    • bind

      public boolean bind(int i, Node value)
      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

      public boolean bind(Node var, Node value)
      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 interface BindingEnvironment
      Parameters:
      var - a Node_RuleVariable defining the variable to bind
      value - the value to bind
      Returns:
      false if the binding fails
    • bindNoCheck

      public void bindNoCheck(Node_RuleVariable var, Node value)
      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 bind
      value - the value to bind
    • instantiate

      public Triple instantiate(TriplePattern pattern)
      Instantiate a triple pattern against the current environment. This version handles unbound variables by turning them into bNodes.
      Specified by:
      instantiate in interface BindingEnvironment
      Parameters:
      pattern - the triple pattern to match
      Returns:
      a new, instantiated triple