Ejemplo n.º 1
0
  @Test
  public void testNextBinding() throws Exception {
    when(mockValue.getString()).thenReturn("x");
    final Binding binding = testObj.nextBinding();

    assertTrue(binding.contains(Var.alloc("a")));
    final Node a = binding.get(Var.alloc("a"));
    assertEquals("x", a.getLiteralLexicalForm());
  }
Ejemplo n.º 2
0
  private ResultSetRewindable convertToStrings(ResultSetRewindable resultsActual) {
    List<Binding> bindings = new ArrayList<Binding>();
    while (resultsActual.hasNext()) {
      Binding b = resultsActual.nextBinding();
      BindingMap b2 = BindingFactory.create();

      for (String vn : resultsActual.getResultVars()) {
        Var v = Var.alloc(vn);
        Node n = b.get(v);
        String s;
        if (n == null) s = "";
        else if (n.isBlank()) s = "_:" + n.getBlankNodeLabel();
        else s = NodeFunctions.str(n);
        b2.add(v, NodeFactory.createLiteral(s));
      }
      bindings.add(b2);
    }
    ResultSet rs =
        new ResultSetStream(
            resultsActual.getResultVars(), null, new QueryIterPlainWrapper(bindings.iterator()));
    return ResultSetFactory.makeRewindable(rs);
  }
 @Override
 protected RDFNode _get(String varName) {
   Node n = binding.get(Var.alloc(varName));
   if (n == null) return null;
   return ModelUtils.convertGraphNodeToRDFNode(n, model);
 }