本文整理了Java中org.apache.jena.sparql.engine.binding.Binding.contains()
方法的一些代码示例,展示了Binding.contains()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Binding.contains()
方法的具体详情如下:
包路径:org.apache.jena.sparql.engine.binding.Binding
类名称:Binding
方法名:contains
[英]Test whether a variable is bound to some object
[中]测试变量是否绑定到某个对象
代码示例来源:origin: apache/jena
@Override
public boolean contains(Var var)
{
return binding.contains(var) ;
}
代码示例来源:origin: apache/jena
private boolean hasCommonVars(Binding left, Binding right)
{
for ( Var v: commonVars )
{
if ( left.contains(v) && right.contains(v) )
return true ;
}
return false;
}
代码示例来源:origin: apache/jena
private static boolean needVars(List<Var> vars, Binding binding)
{
if ( vars == null ) return true ;
for ( Var v : vars )
{
if ( ! binding.contains(v) )
return true ;
}
return false ;
}
代码示例来源:origin: apache/jena
public QueryIterExtendByVar(Binding binding, Var var, Iterator<Node> members, ExecutionContext execCxt) {
super(execCxt);
if ( true ) { // Assume not too costly.
if ( binding.contains(var) )
throw new ARQInternalErrorException("Var " + var + " already set in " + binding);
}
this.binding = binding;
this.var = var;
this.members = members;
}
代码示例来源:origin: apache/jena
@Override
protected boolean _contains(String varName)
{
return binding.contains(Var.alloc(varName)) ;
}
代码示例来源:origin: apache/jena
public static boolean disjoint(Binding binding1, Binding binding2)
{
Iterator<Var> iterVar1 = binding1.vars() ;
for ( ; iterVar1.hasNext() ; )
{
Var v = iterVar1.next() ;
if ( binding2.contains(v) )
return false ;
}
return true ;
}
}
代码示例来源:origin: apache/jena
/** Test whether a name is bound to some object */
@Override
public boolean contains(Var var) {
if ( contains1(var) )
return true;
if ( parent == null )
return false;
return parent.contains(var);
}
代码示例来源:origin: apache/jena
@Override
protected boolean contains1(Var var) {
return accept(var) && binding.contains(var) ;
}
代码示例来源:origin: rdfhdt/hdt-java
private List<Var> calcVars()
{
List<Var> vars = new ArrayList<>(4) ;
// Only if not in parent.
// A (var/value) binding may have been copied down to record it's HDTId.
Binding b = idBinding.getParentBinding() ;
for ( Var v : idBinding )
{
if ( b == null || ! b.contains(v) )
vars.add(v) ;
}
return vars ;
}
代码示例来源:origin: apache/jena
private List<Var> calcVars()
{
List<Var> vars = new ArrayList<>(4) ;
// Only if not in parent.
// A (var/value) binding may have been copied down to record it's NodeId.
Binding b = idBinding.getParentBinding() ;
Iterator<Var> iter = idBinding.iterator() ;
for ( Var v : idBinding )
{
if ( b == null || ! b.contains(v) )
vars.add(v) ;
}
return vars ;
}
代码示例来源:origin: apache/jena
private List<Var> calcVars()
{
List<Var> vars = new ArrayList<>(4) ;
// Only if not in parent.
// A (var/value) binding may have been copied down to record it's NodeId.
Binding b = idBinding.getParentBinding() ;
Iterator<Var> iter = idBinding.iterator() ;
for ( Var v : idBinding )
{
if ( b == null || ! b.contains(v) )
vars.add(v) ;
}
return vars ;
}
代码示例来源:origin: apache/jena
public static Binding merge(Binding bindingLeft, Binding bindingRight)
{
// Test to see if compatible: Iterate over variables in left
boolean matches = compatible(bindingLeft, bindingRight) ;
if ( ! matches )
return null ;
// If compatible, merge. Iterate over variables in right but not in left.
BindingMap b = BindingFactory.create(bindingLeft) ;
for ( Iterator<Var> vIter = bindingRight.vars() ; vIter.hasNext() ; )
{
Var v = vIter.next();
Node n = bindingRight.get(v) ;
if ( ! bindingLeft.contains(v) )
b.add(v, n) ;
}
return b ;
}
代码示例来源:origin: apache/jena
@Override
public Binding accept(Binding binding) {
if ( binding.contains(var) ) {
if ( mustBeNewVar )
throw new QueryExecException("Already set: " + var);
Node n2 = binding.get(var) ;
if ( ! n2.equals(node) )
// And filter out.
return null ;
else
// Already in the binding with the value -> nothing to do.
return binding ;
}
return BindingFactory.binding(binding, var, node) ;
}
代码示例来源:origin: apache/jena
@Override
public Expr copySubstitute(Binding binding)
{
Var v = varNode ;
if ( binding == null || !binding.contains(v) )
return new ExprVar(v) ;
Node v2 = binding.get(v);
return v2.isVariable() ? new ExprVar(v2) : eval(binding, null) ;
}
代码示例来源:origin: SmartDataAnalytics/Sparqlify
Set<Var> exprVars = expr.getVarsMentioned();
for(Var var : exprVars) {
if(!binding.contains(var)) {
allBound = false;
break;
代码示例来源:origin: apache/jena
@Override
public NodeValue evalSpecial(Binding binding, FunctionEnv env) {
// See alse ExprLib.evalOrNull.
// This code predates that; it handles exceptions
// slightly differently (VariableNotBoundException not
// a general ExprEvalException).
if ( expr.isConstant() )
// The case of the variable having been substituted for a constant.
// Note: this has often been optimized away by constant folding
// (ExprTransformConstantFold) which called eval(NodeValue x) -> TRUE.
return NodeValue.TRUE ;
if ( expr.isVariable() )
// The case of the expr being a single variable.
return NodeValue.booleanReturn(binding.contains(expr.asVar())) ;
// General expression. This case can't be written in SPARQL
// but we keep the code general in case some optimziation rewrite
// or algebra expression uses the generalized feature.
try {
expr.eval(binding, env) ;
return NodeValue.TRUE ;
} catch (VariableNotBoundException ex) {
return NodeValue.FALSE ;
}
}
代码示例来源:origin: ch.epfl.bluebrain.nexus.org.topbraid/shacl
if(expr != null && (!expr.isVariable() || binding.contains(expr.asVar()))) {
NodeValue x = expr.eval(binding, env);
if(x != null) {
代码示例来源:origin: apache/jena
private void testErr(String qsAgg, DatasetGraph ds, Syntax syntax) {
Query query = buildGroupBy(qsAgg, syntax) ;
try ( QueryExecution qExec = QueryExecutionFactory.create(query, DatasetFactory.wrap(ds)) ) {
ResultSet rs = qExec.execSelect() ;
assertTrue(rs.getResultVars().contains("X")) ;
Binding b = rs.nextBinding() ;
assertFalse(b.contains(Var.alloc("X"))) ;
}
}
代码示例来源:origin: apache/jena
@Override
public QueryIterator exec(Binding binding, Node name, ExprList args, ExecutionContext execCxt)
{
// Eval if possible.
ExprList evalArgs = new ExprList() ;
for (Expr e : args)
{
if ( e.isVariable() )
{
Var v = e.getExprVar().asVar() ;
// Special case - allow unevaluated variables.
if ( binding.contains(v) )
evalArgs.add(e.eval(binding, execCxt)) ;
else
evalArgs.add(e) ;
}
else
{
NodeValue x = e.eval(binding, execCxt) ;
evalArgs.add(x) ;
}
}
return execEval(binding, evalArgs, execCxt) ;
}
代码示例来源:origin: apache/jena
private void testEmptyNoGroupBy(String qsAgg, DatasetGraph ds, Syntax syntax) {
Query query = buildNoGroupBy(qsAgg, syntax) ;
try ( QueryExecution qExec = QueryExecutionFactory.create(query, DatasetFactory.wrap(ds)) ) {
ResultSet rs = qExec.execSelect() ;
assertTrue(rs.hasNext()) ;
assertTrue(rs.getResultVars().contains("X")) ;
Binding b = rs.nextBinding() ;
assertFalse(b.contains(Var.alloc("X"))) ;
}
}
内容来源于网络,如有侵权,请联系作者删除!