Package com.hp.hpl.jena.query

Examples of com.hp.hpl.jena.query.ResultSet


            // -------- Or make ResultSet from it (but not both - reading an
            //          iterator consumes the current solution)
            List<String> varNames = new ArrayList<String>() ;
            varNames.add("x") ;
            varNames.add("z") ;
            ResultSet rs = new ResultSetStream(varNames, m, qIter);
            ResultSetFormatter.out(rs) ;
            qIter.close() ;
        }
        System.exit(0) ;
    }
View Full Code Here


       
        QueryExecution qexec = QueryExecutionFactory.create(query, model) ;

        try {
            // Assumption: it's a SELECT query.
            ResultSet rs = qexec.execSelect() ;
           
            // The order of results is undefined.
            System.out.println("Titles: ") ;
            for ( ; rs.hasNext() ; )
            {
                QuerySolution rb = rs.nextSolution() ;
               
                // Get title - variable names do not include the '?' (or '$')
                RDFNode x = rb.get("title") ;
               
                // Check the type of the result value
View Full Code Here

        System.out.println("Titles: ") ;
       
        try {
            // Assumption: it's a SELECT query.
            ResultSet rs = qexec.execSelect() ;
           
            // The order of results is undefined.
            for ( ; rs.hasNext() ; )
            {
                QuerySolution rb = rs.nextSolution() ;
               
                // Get title - variable names do not include the '?' (or '$')
                RDFNode x = rb.get("title") ;
               
                // Check the type of the result value
View Full Code Here

       
        QueryExecution qexec = QueryExecutionFactory.create(query, model) ;
       
        try {
            // Assumption: it's a SELECT query.
            ResultSet rs = qexec.execSelect() ;
           
            // The order of results is undefined.
            System.out.println("Titles: ") ;
            for ( ; rs.hasNext() ; )
            {
                QuerySolution rb = rs.nextSolution() ;
               
                // Get title - variable names do not include the '?' (or '$')
                RDFNode x = rb.get("title") ;
               
                // Check the type of the result value
View Full Code Here

        String qs = prologue+"SELECT * { ?x ext:labelSearch 'EF' }" ;
        Query query = QueryFactory.create(qs) ;
        Model model = make() ;
        QueryExecution qExec = QueryExecutionFactory.create(query, model) ;
        try {
            ResultSet rs = qExec.execSelect() ;
            ResultSetFormatter.out(rs) ;
        } finally { qExec.close() ; }
       
        // Or register it.
        PropertyFunctionRegistry.get().put("http://example/f#search", labelSearch.class) ;
        prologue = "PREFIX ext: <http://example/f#>\n" ;
        qs = prologue+"SELECT * { ?x ext:search 'EF' }" ;
        query = QueryFactory.create(qs) ;
        qExec = QueryExecutionFactory.create(query, model) ;
        try {
            ResultSet rs = qExec.execSelect() ;
            ResultSetFormatter.out(rs) ;
        } finally { qExec.close() ; }
    }
View Full Code Here

      qe = new LdapQueryEngine(q, config);
    }
   
    qe.setDataset(DatasetFactory.create());
   
    ResultSet results = qe.execSelect();
   
    ResultSetFormatter.out(System.out, results);
  }
View Full Code Here

      else
        qe = new SQLQueryEngine(query, config);

      qe.setDataset(DatasetFactory.create());

      ResultSet results = qe.execSelect();
      resp.setHeader("Content-Type", "application/xml");
      ResultSetFormatter.outputAsXML(resp.getOutputStream(), results,
          stylesheet);
    }
    catch (Throwable e)
View Full Code Here

 
  public void testBasicSelectQuery() throws SQLException, ConfigException
  {
    QueryEngine qe = prepareQuery("SELECT ?s ?val1 WHERE { ?s <urn:ex:TABLE1_FIELD1> ?val1 }");
   
    ResultSet res = qe.execSelect();
   
    assertTrue("Query has results", res.hasNext());
    ResultSetFormatter.out(System.out, res);
  }
View Full Code Here

 
  public void testJoinQuery() throws SQLException, ConfigException
  {
    QueryEngine qe = prepareQuery("SELECT ?val1 ?val2 ?val3 WHERE { ?s1 <urn:ex:TABLE1_FIELD1> ?val1 ; <urn:ex:TABLE1_FIELD2> ?val2 . ?s2 <urn:ex:TABLE2_FIELD1> ?val1 ; <urn:ex:TABLE2_FIELD2> ?val3 .}");
   
    ResultSet res = qe.execSelect();
   
    assertTrue("Query has results", res.hasNext());
    ResultSetFormatter.out(System.out, res);
  }
View Full Code Here

 
  public void testOptionalSelectQuerySameSubject() throws SQLException, ConfigException
  {
    QueryEngine qe = prepareQuery("SELECT * WHERE { ?s <urn:ex:TABLE1_FIELD1> ?val1 . OPTIONAL { ?s <urn:ex:TABLE1_FIELD2> ?val2} }");
   
    ResultSet res = qe.execSelect();
   
    assertTrue("Optional subject join has result", res.hasNext());
   
    // No more than two results!
    res.next(); res.next();
    assertFalse("I only have two results", res.hasNext());
    //ResultSetFormatter.out(System.out, res);
  }
View Full Code Here

TOP

Related Classes of com.hp.hpl.jena.query.ResultSet

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.