org.apache.jena.sparql.engine.binding.Binding.get()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(5.3k)|赞(0)|评价(0)|浏览(173)

本文整理了Java中org.apache.jena.sparql.engine.binding.Binding.get()方法的一些代码示例,展示了Binding.get()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Binding.get()方法的具体详情如下:
包路径:org.apache.jena.sparql.engine.binding.Binding
类名称:Binding
方法名:get

Binding.get介绍

[英]Return the object bound to a variable, or null
[中]返回绑定到变量的对象,或null

代码示例

代码示例来源:origin: apache/jena

/** Return the value in the binding or the variable itself. */
public static Node lookup(Binding binding, Var var) {
  Node n = binding.get(var);
  if ( n != null )
    return n;
  return var;
}

代码示例来源:origin: apache/jena

@Override
public Node get(Var var)
{
  return binding.get(var) ;
}

代码示例来源:origin: apache/jena

@Override
public boolean containsCompatibleWithSharedDomain(Binding binding) {
  Node value = binding.get(this.var);
  if ( value == null )
    // No shared domain.
    return false;
  return this.values.contains(value);
}

代码示例来源:origin: apache/jena

private Key convertToKey(Binding binding)
{
  Node[] indexKey = new Node[varColumns.size()] ;
  for ( Map.Entry<Var,Integer> varCol : varColumns.entrySet() )
  {
    Node value = binding.get(varCol.getKey()) ;
    if ( value == null )
      missingValue = true ;
    indexKey[varCol.getValue()] = value ;
  }
  return new Key(indexKey) ;
}

代码示例来源:origin: apache/jena

@Override
protected Node get1(Var var) {
  if ( !accept(var) )
    return null ;
  return binding.get(var) ;
}

代码示例来源:origin: apache/jena

/** Return the object bound to a name, or null */
@Override
final public Node get(Var var) {
  Node node = get1(var);
  if ( node != null )
    return node;
  if ( parent == null )
    return null;
  return parent.get(var);
}

代码示例来源:origin: apache/jena

public static void addAll(BindingMap dest, Binding src) {
  Iterator<Var> iter = src.vars();
  for ( ; iter.hasNext() ; ) {
    Var v = iter.next();
    Node n = src.get(v);
    dest.add(v, n);
  }
}

代码示例来源:origin: apache/jena

@Override
protected Node getNode(String columnLabel) throws SQLException {
  if (this.isClosed())
    throw new SQLException("Result Set is closed");
  if (this.getCurrentRow() == null)
    throw new SQLException("Not currently at a row");
  if (!this.columns.contains(columnLabel))
    throw new SQLException("The given column does not exist in the result set");
  return this.getCurrentRow().get(Var.alloc(columnLabel));
}

代码示例来源:origin: apache/jena

private static Node substitute(Node node, Binding binding)
{
  if ( Var.isVar(node) )
  {
    Node x = binding.get(Var.alloc(node)) ;
    if ( x != null )
      return x ;
  }
  return node ;
}

代码示例来源:origin: apache/jena

@Override
protected Node getNode(String columnLabel) throws SQLException {
  if (this.isClosed())
    throw new SQLException("Result Set is closed");
  if (this.getCurrentRow() == null)
    throw new SQLException("Not currently at a row");
  if (!this.columns.contains(columnLabel))
    throw new SQLException("The given column does not exist in the result set");
  return this.getCurrentRow().get(Var.alloc(columnLabel));
}

代码示例来源:origin: apache/jena

public static int hashCode(Binding bind) {
  int hash = 0xC0;
  for ( Iterator<Var> iter = bind.vars() ; iter.hasNext() ; ) {
    Var var = iter.next();
    Node node = bind.get(var);
    hash ^= var.hashCode();
    hash ^= node.hashCode();
  }
  return hash;
}

代码示例来源:origin: apache/jena

@Override
protected RDFNode _get(String varName)
{
  Node n = binding.get(Var.alloc(varName)) ;
  if ( n == null )
    return null;
  return ModelUtils.convertGraphNodeToRDFNode(n, model) ;
}

代码示例来源:origin: apache/jena

/** Bound value or null */
private static Node resolve(Binding b, Node n) {
  if ( ! n.isVariable() ) return n ;
  return b.get(Var.alloc(n)) ;
}

代码示例来源:origin: apache/jena

private Triple resolveTriple(final Triple t, final Binding values) {
  int idx = variables.indexOf(t.getSubject());
  final Node s = idx == -1 ? t.getSubject() : values.get(Var
      .alloc(variables.get(idx)));
  idx = variables.indexOf(t.getPredicate());
  final Node p = idx == -1 ? t.getPredicate() : values.get(Var
      .alloc(variables.get(idx)));
  idx = variables.indexOf(t.getObject());
  final Node o = idx == -1 ? t.getObject() : values.get(Var
      .alloc(variables.get(idx)));
  return new Triple(s, p, o);
}

代码示例来源:origin: apache/jena

static NodeValue eval(Var v, Binding binding, FunctionEnv env)
{
  if ( binding == null )
    throw new VariableNotBoundException("Not bound: (no binding): "+v) ;
  Node nv = binding.get(v) ;
  if ( nv == null )
    throw new VariableNotBoundException("Not bound: variable "+v) ;
  // Wrap as a NodeValue.
  return NodeValue.makeNode(nv) ;
}

代码示例来源:origin: apache/jena

private static Node value(PropFuncArg arg, Binding b) {
    Node x = arg.getArg() ;
    if ( !Var.isVar(x) )
      return x ;
    return b.get(Var.alloc(x)) ;
  }
}

代码示例来源:origin: apache/jena

public static Binding transform(Binding b, NodeTransform transform) {
  BindingMap b2 = BindingFactory.create() ;
  List<Var> vars = Iter.toList(b.vars()) ;
  for ( Var v : vars ) {
    Var v2 = (Var)transform.apply(v) ;
    b2.add(v2, b.get(v));
  }
  return b2 ;
}

代码示例来源: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: apache/jena

@Test public void path_38()
{ 
  // Same end points.
  List<Binding> x = eval(graph6, "?x", "(pathN+ :p)", "?x" ) ;
  
  assertEquals(2, x.size()) ;
  Node node1 = x.get(0).get(Var.alloc("x")) ;
  Node node2 = x.get(1).get(Var.alloc("x")) ;
  assertFalse(node1.equals(node2)) ;
  assertTrue(node1.equals(n1) || node1.equals(n2)) ;
  assertTrue(node2.equals(n1) || node2.equals(n2)) ;
}

代码示例来源:origin: apache/jena

@Test public void path_37()
{ 
  List<Binding> x = eval(graph6, "?x", "(path* :p)", "?x" ) ;
  assertEquals(2, x.size()) ;
  Node node1 = x.get(0).get(Var.alloc("x")) ;
  Node node2 = x.get(1).get(Var.alloc("x")) ;
  assertFalse(node1.equals(node2)) ;
  assertTrue(node1.equals(n1) || node1.equals(n2)) ;
  assertTrue(node2.equals(n1) || node2.equals(n2)) ;
}

相关文章