Package org.openrdf.query

Examples of org.openrdf.query.BindingSet


        + "                test:outputDocument {OUTPUT}; "
        + "                test:status {\"APPROVED\"} "
        + "using namespace test = <http://www.w3.org/2000/10/rdf-tests/rdfcore/testSchema#>";
    TupleQueryResult queryResult = con.prepareTupleQuery(QueryLanguage.SERQL, query).evaluate();
    while (queryResult.hasNext()) {
      BindingSet bindingSet = queryResult.next();
      String caseURI = bindingSet.getValue("TESTCASE").toString();
      String inputURL = bindingSet.getValue("INPUT").toString();
      String outputURL = bindingSet.getValue("OUTPUT").toString();
      suite.addTest(new PositiveParserTest(caseURI, inputURL, outputURL));
    }

    queryResult.close();

    // Add all negative parser tests
    query = "select TESTCASE, INPUT " + "from {TESTCASE} rdf:type {test:NegativeParserTest}; "
        + "                test:inputDocument {INPUT}; " + "                test:status {\"APPROVED\"} "
        + "using namespace test = <http://www.w3.org/2000/10/rdf-tests/rdfcore/testSchema#>";
    queryResult = con.prepareTupleQuery(QueryLanguage.SERQL, query).evaluate();
    while (queryResult.hasNext()) {
      BindingSet bindingSet = queryResult.next();
      String caseURI = bindingSet.getValue("TESTCASE").toString();
      String inputURL = bindingSet.getValue("INPUT").toString();
      suite.addTest(new NegativeParserTest(caseURI, inputURL));
    }

    queryResult.close();
    con.close();
View Full Code Here


      List<Resource> contextList = new ArrayList<Resource>();

      TupleQueryResult contextIDs = getRepository().getHTTPClient().getContextIDs();
      try {
        while (contextIDs.hasNext()) {
          BindingSet bindingSet = contextIDs.next();
          Value context = bindingSet.getValue("contextID");

          if (context instanceof Resource) {
            contextList.add((Resource)context);
          }
        }
View Full Code Here

      List<Namespace> namespaceList = new ArrayList<Namespace>();

      TupleQueryResult namespaces = getRepository().getHTTPClient().getNamespaces();
      try {
        while (namespaces.hasNext()) {
          BindingSet bindingSet = namespaces.next();
          Value prefix = bindingSet.getValue("prefix");
          Value namespace = bindingSet.getValue("namespace");

          if (prefix instanceof Literal && namespace instanceof Literal) {
            String prefixStr = ((Literal)prefix).getLabel();
            String namespaceStr = ((Literal)namespace).getLabel();
            namespaceList.add(new NamespaceImpl(prefixStr, namespaceStr));
View Full Code Here

    try {
      List<Entry> orderedEntries = new ArrayList<Entry>();
      Map<Key, Entry> entries = new HashMap<Key, Entry>();

      while (iter.hasNext()) {
        BindingSet bindingSet = iter.next();
        Key key = new Key(bindingSet);
        Entry entry = entries.get(key);

        if (entry == null) {
          entry = new Entry(bindingSet);
View Full Code Here

    try {
      Map<Key, Entry> entries = new HashMap<Key, Entry>();

      while (iter.hasNext()) {
        BindingSet sol = iter.next();
        Key key = new Key(sol);
        Entry entry = entries.get(key);

        if (entry == null) {
          entry = new Entry(sol);
View Full Code Here

    iter = con.evaluate(tupleQuery.getTupleExpr(), null, EmptyBindingSet.getInstance(), false);

    try {
      assertTrue(iter.hasNext());

      BindingSet bindings = iter.next();
      assertEquals(subj, bindings.getValue("S"));
      assertEquals(pred, bindings.getValue("P"));
      assertEquals(obj, bindings.getValue("O"));
      assertTrue(!iter.hasNext());
    }
    finally {
      iter.close();
    }
View Full Code Here

    CloseableIteration<? extends BindingSet, QueryEvaluationException> iter;
    iter = con.evaluate(tupleQuery.getTupleExpr(), null, EmptyBindingSet.getInstance(), false);

    while (iter.hasNext()) {
      BindingSet bindings = iter.next();
      Value c = bindings.getValue("C");
      if (c instanceof Resource) {
        con.addStatement((Resource)c, RDF.TYPE, RDFS.CLASS);
      }
    }

    con.commit();

    // Simulate auto-commit

    assertEquals(3, countElements(con.getStatements(null, RDF.TYPE, RDFS.CLASS, false)));

    tupleQuery = QueryParserUtil.parseTupleQuery(QueryLanguage.SERQL, "SELECT P FROM {} P {}", null);
    iter = con.evaluate(tupleQuery.getTupleExpr(), null, EmptyBindingSet.getInstance(), false);

    while (iter.hasNext()) {
      BindingSet bindings = iter.next();
      Value p = bindings.getValue("P");
      if (p instanceof URI) {
        con.addStatement((URI)p, RDF.TYPE, RDF.PROPERTY);
        con.commit();
      }
    }
View Full Code Here

    @Override
    public boolean equals(Object other)
    {
      if (other instanceof Key && other.hashCode() == hash) {
        BindingSet otherSolution = ((Key)other).bindingSet;

        for (String name : group.getGroupBindingNames()) {
          Value v1 = bindingSet.getValue(name);
          Value v2 = otherSolution.getValue(name);

          if (!ObjectUtil.nullEquals(v1, v2)) {
            return false;
          }
        }
View Full Code Here

    this.queryString = queryString;
    this.baseURI = baseURI;
  }

  protected Binding[] getBindingsArray() {
    BindingSet bindings = this.getBindings();

    Binding[] bindingsArray = new Binding[bindings.size()];

    Iterator<Binding> iter = bindings.iterator();
    for (int i = 0; i < bindings.size(); i++) {
      bindingsArray[i] = iter.next();
    }

    return bindingsArray;
  }
View Full Code Here

      try {
        ValueFactory vf = getValueFactory();

        while (bindingsIter.hasNext()) {
          BindingSet bindings = bindingsIter.next();

          Value subj = bindings.getValue("subject");
          Value pred = bindings.getValue("predicate");
          Value obj = bindings.getValue("object");

          if (subj instanceof Resource && pred instanceof URI && obj != null) {
            statements.add(vf.createStatement((Resource)subj, (URI)pred, obj));
          }
        }
View Full Code Here

TOP

Related Classes of org.openrdf.query.BindingSet

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.