本文整理匯總了Java中org.apache.jena.sparql.engine.binding.BindingHashMap類的典型用法代碼示例。如果您正苦於以下問題:Java BindingHashMap類的具體用法?Java BindingHashMap怎麽用?Java BindingHashMap使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
BindingHashMap類屬於org.apache.jena.sparql.engine.binding包,在下文中一共展示了BindingHashMap類的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: visit
import org.apache.jena.sparql.engine.binding.BindingHashMap; //導入依賴的package包/類
@Override
public void visit(ElementData el) {
final NodeExprNormalizer nenzer = new NodeExprNormalizer();
final ElementData nzed = new ElementData();
final List<Var> vars = el.getVars();
vars.forEach((v) -> {
nzed.add(v);
});
el.getRows().forEach((b) -> {
final BindingHashMap binding = new BindingHashMap();
vars.forEach((v) -> {
final Node n = b.get(v);
if (n != null) {
n.visitWith(nenzer);
binding.add(v, nenzer.getResult());
}
nzed.add(binding);
});
});
endVisit(nzed, nenzer);
}
示例2: BindingHashMapOverwrite
import org.apache.jena.sparql.engine.binding.BindingHashMap; //導入依賴的package包/類
/**
* Constructs a new binding from a query solution.
*
* @param binding -
*/
public BindingHashMapOverwrite(final QuerySolution binding) {
var = null;
node = null;
if (binding == null) {
parent = null;
} else {
final BindingHashMap p = new BindingHashMap();
for (Iterator<String> it = binding.varNames(); it.hasNext();) {
final String varName = it.next();
if (binding.get(varName) != null) {
p.add(Var.alloc(varName), binding.get(varName).asNode());
}
}
parent = p;
}
// LOG.trace("New binding #" + System.identityHashCode(this) + " copies " + binding);
}
示例3: asBinding
import org.apache.jena.sparql.engine.binding.BindingHashMap; //導入依賴的package包/類
/**
* Turns a QuerySolution into a Binding.
* @param map the input QuerySolution
* @return a Binding or null if the input is null
*/
public static Binding asBinding(final QuerySolution map) {
if(map != null) {
BindingHashMap result = new BindingHashMap();
Iterator<String> varNames = map.varNames();
while(varNames.hasNext()) {
String varName = varNames.next();
RDFNode node = map.get(varName);
if(node != null) {
result.add(Var.alloc(varName), node.asNode());
}
}
return result;
}
else {
return null;
}
}
示例4: mergeValues
import org.apache.jena.sparql.engine.binding.BindingHashMap; //導入依賴的package包/類
/**
* merge values in qvalues.
*
* @param qvariables
* @param qvalues
* @param variables
* @param values
*/
private void mergeValues(
final List<Var> qvariables,
final List<Binding> qvalues,
final List<Var> variables,
final List<BindingHashMapOverwrite> values) {
// check that no variable is duplicate in variables and qvariables
// brute force, ok if not many variables.
checkNotContainsSome(qvariables, variables);
checkNotContainsSome(variables, qvariables);
// merge variables
qvariables.addAll(variables);
// deal with empty cases
if (values.isEmpty() && qvalues.isEmpty()) {
return;
}
// ensure not empty
ensureNotEmpty(qvariables, qvalues);
ensureNotEmpty(variables, values);
// perform the merge
int j = qvalues.size();
for (int i = 0; i < j; i++) {
Binding qb = qvalues.remove(0);
for (Binding b : values) {
BindingHashMap newqb = new BindingHashMap();
newqb.addAll(qb);
newqb.addAll(b);
qvalues.add(newqb);
}
}
}
示例5: ensureNotEmpty
import org.apache.jena.sparql.engine.binding.BindingHashMap; //導入依賴的package包/類
/**
* Utility function. ensures there is at least a row of null values in a
* values block.
*
* @param <T> a sub class of Binding
* @param variables the values variables
* @param values the values bindings
*/
protected final <T extends Binding> void ensureNotEmpty(
final List<Var> variables,
final List<T> values) {
Objects.requireNonNull(variables);
Objects.requireNonNull(values);
if (values.isEmpty()) {
final BindingHashMap map = new BindingHashMap();
values.add((T) new BindingHashMapOverwrite(map, null, null));
}
}
示例6: toBinding
import org.apache.jena.sparql.engine.binding.BindingHashMap; //導入依賴的package包/類
private Binding toBinding(String[] row) {
BindingHashMap result = new BindingHashMap();
for (int i = 0; i < row.length; i++) {
if (isUnboundValue(row[i]))
continue;
result.add(getVar(i), NodeFactory.createLiteral(sanitizeString(row[i])));
}
// Add current row number as ?ROWNUM
result.add(TarqlQuery.ROWNUM, NodeFactory.createLiteral(
Integer.toString(rownum), XSDDatatype.XSDinteger));
return result;
}
示例7: binding
import org.apache.jena.sparql.engine.binding.BindingHashMap; //導入依賴的package包/類
public static Binding binding(List<Var> header, String... values) {
if (header.size() != values.length) {
throw new IllegalArgumentException(
"header and values must have same length: " +
header + ", " + Arrays.toString(values));
}
BindingHashMap result = new BindingHashMap();
for (int i = 0; i < header.size(); i++) {
result.add(header.get(i), NodeFactoryExtra.parseNode(values[i]));
}
return result;
}
示例8: removePseudoVars
import org.apache.jena.sparql.engine.binding.BindingHashMap; //導入依賴的package包/類
public static Binding removePseudoVars(Binding binding) {
BindingHashMap result = new BindingHashMap();
Iterator<Var> it = binding.vars();
while (it.hasNext()) {
Var var = it.next();
if (var.equals(TarqlQuery.ROWNUM)) continue;
result.add(var, binding.get(var));
}
return result;
}