本文整理汇总了Java中com.hp.hpl.jena.sparql.engine.binding.Binding.vars方法的典型用法代码示例。如果您正苦于以下问题:Java Binding.vars方法的具体用法?Java Binding.vars怎么用?Java Binding.vars使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.hp.hpl.jena.sparql.engine.binding.Binding
的用法示例。
在下文中一共展示了Binding.vars方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: extendWith
import com.hp.hpl.jena.sparql.engine.binding.Binding; //导入方法依赖的package包/类
/**
* Joins this NodeRelation with a Binding. Any row in this
* NodeRelation that is incompatible with the binding will be
* dropped, and any compatible row will be extended with
* FixedNodeMakers whose node is taken from the binding.
*
* FIXME: This doesn't behave correctly when a node maker is available for a given variable but produces unbound results. Everything is compatible with unbound.
* FIXME: This ignores the condition of the binding maker, if any is present.
*
* @param binding A binding to join with this NodeRelation
* @return The joined NodeRelation
*/
public static NodeRelation extendWith(NodeRelation table, Binding binding) {
if (binding.isEmpty()) return table;
Map<Var,NodeMaker> extraVars = new HashMap<Var,NodeMaker>();
NodeRelation result = table;
for (Iterator<Var> it = binding.vars(); it.hasNext();) {
Var var = it.next();
Node value = binding.get(var);
if (table.getBindingMaker().has(var)) {
result = NodeRelationUtil.select(result, var, value);
} else {
extraVars.put(var, new FixedNodeMaker(value));
}
}
if (!extraVars.isEmpty()) {
extraVars.putAll(result.getBindingMaker().getNodeMakers());
result = new NodeRelation(result.getSQLConnection(), result.getBaseTabular(),
new BindingMaker(extraVars, result.getBindingMaker().getConditionColumn()));
}
return result;
}
示例2: extendWith
import com.hp.hpl.jena.sparql.engine.binding.Binding; //导入方法依赖的package包/类
/**
* Joins this NodeRelation with a Binding. Any row in this
* NodeRelation that is incompatible with the binding will be
* dropped, and any compatible row will be extended with
* FixedNodeMakers whose node is taken from the binding.
*
* @param binding A binding to join with this NodeRelation
* @return The joined NodeRelation
*/
public NodeRelation extendWith(Binding binding) {
if (binding.isEmpty()) return this;
MutableRelation mutator = new MutableRelation(baseRelation());
Map<Var,NodeMaker> columns = new HashMap<Var,NodeMaker>();
for (Var variable: variables()) {
columns.put(variable, nodeMaker(variable));
}
for (Iterator<Var> it = binding.vars(); it.hasNext();) {
Var var = it.next();
Node value = binding.get(var);
if (columns.containsKey(var)) {
columns.put(var, columns.get(var).selectNode(value, mutator));
} else {
columns.put(var, new FixedNodeMaker(value, false));
}
}
return new NodeRelation(mutator.immutableSnapshot(), columns);
}
示例3: convertToBindings
import com.hp.hpl.jena.sparql.engine.binding.Binding; //导入方法依赖的package包/类
/** Convert rows to bindings for a give parent, that may, or may not,
* have equivalent bindings of variables in the rows */
private static Iterator<Binding> convertToBindings(Iterator<Row<NodeId>> iter, final Binding parent, final NodeTable nodeTable) {
Transform<Row<NodeId>, Binding> conv = new Transform<Row<NodeId>, Binding>() {
@Override
public Binding convert(Row<NodeId> row) {
if ( parent.isEmpty() )
return new BindingRow(row, nodeTable) ;
// Temporary fix. Proper fix is to change BindingBase to allow multiple occurrences in a controlled way.
BindingMap b = BindingFactory.create() ;
if ( ! parent.isEmpty() ) {
for ( Iterator<Var> vars = parent.vars() ; vars.hasNext() ; ) {
Var v = vars.next() ;
if ( ! row.contains(v) )
b.add(v, parent.get(v)) ;
}
}
return new BindingRow(b, row, nodeTable) ;
}
} ;
return Iter.map(iter, conv) ;
}
示例4: convertToRow
import com.hp.hpl.jena.sparql.engine.binding.Binding; //导入方法依赖的package包/类
public static Row<NodeId> convertToRow(Binding binding, NodeTable nodeTable, RowBuilder<NodeId> builder) {
if ( binding instanceof BindingRow )
return ((BindingRow)binding).getRow() ;
builder.reset() ;
Iterator<Var> vIter = binding.vars() ;
for ( ; vIter.hasNext() ; ) {
Var v = vIter.next() ;
Node n = binding.get(v) ;
if ( n == null )
continue ;
NodeId nid = nodeTable.getNodeIdForNode(n) ;
if ( NodeId.isDoesNotExist(nid) )
// FIXME ???
continue;
builder.add(v, nid) ;
}
return builder.build() ;
}