Class BindingBuilder


public class BindingBuilder extends Object
Build Bindings.

Binding are immutable and can not be changed once constructed. A BindingBuilder accumulates some var/node pairs and, at the build step, chooses the most efficient Binding implementation.

   Binding binding = Binding.builder()
                        .add(var, value)
The build() method can only be called once per binding constructed. A BindingBuilder can be reused but is not thread safe.


   BindingBuilder builder = Binding.builder(parent);
   for .... {

      for ( ... each variable ... ) {
          builder.add(var, node)
      Binding binding =;
      ... accumulate binding ...


   BindingBuilder builder = Binding.builder(parent);
   for .... {
      Binding binding =
             .add(var1, node1)
             .add(var2, node2)
             .add(var3, node3)
      ... accumulate binding ...
See also BindingFactory. When the number of var/node pairs is fixed and known, operations in BindingFactory directly create a binding without needing a builder.
  • Field Details

    • noParent

      public static final Binding noParent
  • Method Details

    • create

      public static BindingBuilder create()
    • create

      public static BindingBuilder create(Binding parent)
    • set

      public BindingBuilder set(Var var, org.apache.jena.graph.Node node)
      Accumulate (var,value) pairs. Allow binding in this level to be replaced (i.e. not in parent)
    • add

      public BindingBuilder add(Var var, org.apache.jena.graph.Node node)
    • addAll

      public BindingBuilder addAll(Binding other)
      Add all the (var, value) pairs from another binding
    • getOrSame

      public org.apache.jena.graph.Node getOrSame(Var var)
      Get or return the variable.
    • get

      public org.apache.jena.graph.Node get(Var var)
    • contains

      public boolean contains(Var var)
    • isEmpty

      public boolean isEmpty()
    • vars1

      public Iterator<Var> vars1()
      Variables in the builder - does not include the parent.
    • reset

      public BindingBuilder reset()
      Reset the builder state, while keeping the parent
    • build

      public Binding build()
      Construct the binding. This can be called only once for a binding but the builder can be reused after a call to reset().
    • snapshot

      public Binding snapshot()
      Build a view of the current state.

      Do not modify the builder while this binding is in use. Changes to the builder make this view unstable. To create a finished binding, call build().

    • toString

      public String toString()
      toString in class Object