Package org.openrdf.query.impl

Examples of org.openrdf.query.impl.MapBindingSet


  }

  private TupleResult createQueryResult() {
    List<String> bindingNames = Arrays.asList("a", "b", "c");

    MapBindingSet solution1 = new MapBindingSet(bindingNames.size());
    solution1.addBinding("a", new URIImpl("foo:bar"));
    solution1.addBinding("b", new BNodeImpl("bnode"));
    solution1.addBinding("c", new LiteralImpl("baz"));

    MapBindingSet solution2 = new MapBindingSet(bindingNames.size());
    solution2.addBinding("a", new LiteralImpl("1", XMLSchema.INTEGER));
    solution2.addBinding("c", new LiteralImpl("Hello World!", "en"));

    List<? extends BindingSet> bindingSetList = Arrays.asList(solution1, solution2);

    TupleResultImpl result = new TupleResultImpl(bindingNames, bindingSetList);
View Full Code Here


        else {
          currentValue = valueFactory.createLiteral(text);
        }
      }
      else if (RESULT_TAG.equals(tagName)) {
        currentSolution = new MapBindingSet(bindingNames.size());
      }
      else if (VAR_TAG.equals(tagName)) {
        String varName = atts.get(VAR_NAME_ATT);

        if (varName == null) {
View Full Code Here

  }

  private void reportSolution(Resource solutionNode, List<String> bindingNames)
    throws RDFHandlerException
  {
    MapBindingSet bindingSet = new MapBindingSet(bindingNames.size());

    Iterator<Value> bindingIter = model.filter(solutionNode, BINDING, null).objects().iterator();
    while (bindingIter.hasNext()) {
      Value bindingNode = bindingIter.next();

      if (bindingNode instanceof Resource) {
        Binding binding = getBinding((Resource)bindingNode);
        bindingSet.addBinding(binding);
      }
      else {
        throw new RDFHandlerException("Value for " + BINDING + " is not a resource: " + bindingNode);
      }
    }
View Full Code Here

  }

  private TupleResult createQueryResult() {
    List<String> bindingNames = Arrays.asList("a", "b", "c");

    MapBindingSet solution1 = new MapBindingSet(bindingNames.size());
    solution1.addBinding("a", new URIImpl("foo:bar"));
    solution1.addBinding("b", new BNodeImpl("bnode"));
    solution1.addBinding("c", new LiteralImpl("baz"));

    MapBindingSet solution2 = new MapBindingSet(bindingNames.size());
    solution2.addBinding("a", new LiteralImpl("1", XMLSchema.INTEGER));
    solution2.addBinding("c", new LiteralImpl("Hello World!", "en"));

    List<? extends BindingSet> bindingSetList = Arrays.asList(solution1, solution2);

    return new TupleResultImpl(bindingNames, bindingSetList);
  }
View Full Code Here

    con.commit();

    TupleQueryModel tupleQuery = QueryParserUtil.parseTupleQuery(QueryLanguage.SERQL,
        "select X from {X} rdf:type {Y} rdf:type {rdfs:Class}", null);

    MapBindingSet bindings = new MapBindingSet(1);

    Cursor<? extends BindingSet> iter;
    iter = con.evaluate(tupleQuery, bindings, false);

    int resultCount = verifyQueryResult(iter, 1);
    assertEquals("Wrong number of query results", 2, resultCount);

    bindings.addBinding("Y", painter);
    iter = con.evaluate(tupleQuery, bindings, false);
    resultCount = verifyQueryResult(iter, 1);
    assertEquals("Wrong number of query results", 1, resultCount);

    bindings.addBinding("Z", painting);
    iter = con.evaluate(tupleQuery, bindings, false);
    resultCount = verifyQueryResult(iter, 1);
    assertEquals("Wrong number of query results", 1, resultCount);

    bindings.removeBinding("Y");
    iter = con.evaluate(tupleQuery, bindings, false);
    resultCount = verifyQueryResult(iter, 1);
    assertEquals("Wrong number of query results", 2, resultCount);
  }
View Full Code Here

  public BindingSet sign(BindingSet bindings) {
    if (bindings == null) {
      return null;
    }
    MapBindingSet signed = new MapBindingSet(bindings.size());
    for (Binding binding : bindings) {
      signed.addBinding(binding.getName(), sign(binding.getValue()));
    }
    return signed;
  }
View Full Code Here

      ValueFactory vf = ValueFactoryImpl.getInstance();

      for (RepositoryInfo info : getRepositoryManager().getAllRepositoryInfos()) {
        String id = info.getId();

        MapBindingSet bindings = new MapBindingSet(3);
        bindings.addBinding("uri", vf.createURI(namespace, id));
        bindings.addBinding("id", vf.createLiteral(id));

        if (info.getDescription() != null) {
          bindings.addBinding("title", vf.createLiteral(info.getDescription()));
        }

        result.append(bindings);
      }
View Full Code Here

        try {
            sparqlQuery = getPrefixes() + sparqlQuery;
            final SPARQLParser parser = new SPARQLParser();
            final ParsedQuery query = parser.parseQuery(sparqlQuery, null);
            boolean includeInferred = false;
            final CloseableIteration<? extends BindingSet, QueryEvaluationException> results = this.sailConnection.get().evaluate(query.getTupleExpr(), query.getDataset(), new MapBindingSet(), includeInferred);
            final List<Map<String, Vertex>> returnList = new ArrayList<Map<String, Vertex>>();
            try {
                while (results.hasNext()) {
                    BindingSet bs = results.next();
                    Map<String, Vertex> returnMap = new HashMap<String, Vertex>();
View Full Code Here

    ParsedTupleQuery tupleQuery = QueryParserUtil.parseTupleQuery(QueryLanguage.SERQL,
        "select X from {X} rdf:type {Y} rdf:type {rdfs:Class}", null);
    TupleExpr tupleExpr = tupleQuery.getTupleExpr();

    MapBindingSet bindings = new MapBindingSet(1);

    CloseableIteration<? extends BindingSet, QueryEvaluationException> iter;
    iter = con.evaluate(tupleExpr, null, bindings, false);
    assertEquals(2, countElements(iter));

    bindings.addBinding("Y", painter);
    iter = con.evaluate(tupleExpr, null, bindings, false);
    assertEquals(1, countElements(iter));

    bindings.addBinding("Z", painting);
    iter = con.evaluate(tupleExpr, null, bindings, false);
    assertEquals(1, countElements(iter));

    bindings.removeBinding("Y");
    iter = con.evaluate(tupleExpr, null, bindings, false);
    assertEquals(2, countElements(iter));
  }
View Full Code Here

  }

  private void reportSolution(Resource solutionNode, List<String> bindingNames)
    throws RDFHandlerException, GraphUtilException
  {
    MapBindingSet bindingSet = new MapBindingSet(bindingNames.size());

    Iterator<Value> bindingIter = GraphUtil.getObjectIterator(graph, solutionNode, BINDING);
    while (bindingIter.hasNext()) {
      Value bindingNode = bindingIter.next();

      if (bindingNode instanceof Resource) {
        Binding binding = getBinding((Resource)bindingNode);
        bindingSet.addBinding(binding);
      }
      else {
        throw new RDFHandlerException("Value for " + BINDING + " is not a resource: " + bindingNode);
      }
    }
View Full Code Here

TOP

Related Classes of org.openrdf.query.impl.MapBindingSet

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.