java.lang.Object
org.apache.jena.sparql.engine.binding.BindingBuilder
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)
...
.build();
The build() method can only be called once per binding constructed. A
BindingBuilder can be reused but is not thread safe.
Example:
BindingBuilder builder = Binding.builder(parent);
for .... {
builder.reset()
for ( ... each variable ... ) {
builder.add(var, node)
}
Binding binding = builder.build();
... accumulate binding ...
}
Example:
BindingBuilder builder = Binding.builder(parent);
for .... {
Binding binding =
builder.reset()
.add(var1, node1)
.add(var2, node2)
.add(var3, node3)
.build();
}
... 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 Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionAdd all the (var, value) pairs from another bindingbuild()Construct the binding.booleanstatic BindingBuildercreate()static BindingBuilderorg.apache.jena.graph.Nodeorg.apache.jena.graph.NodeGet or return the variable.booleanisEmpty()reset()Reset the builder state, while keeping the parentAccumulate (var,value) pairs.snapshot()Build a view of the current state.toString()vars1()Variables in the builder - does not include the parent.
-
Field Details
-
noParent
-
-
Method Details
-
create
-
create
-
set
Accumulate (var,value) pairs. Allow binding in this level to be replaced (i.e. not in parent) -
add
-
addAll
Add all the (var, value) pairs from another binding -
getOrSame
Get or return the variable. -
get
-
contains
-
isEmpty
public boolean isEmpty() -
vars1
Variables in the builder - does not include the parent. -
reset
Reset the builder state, while keeping the parent -
build
Construct the binding. This can be called only once for a binding but the builder can be reused after a call toreset(). -
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
-