Package com.hp.hpl.jena.query

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


      "where {?s dc:creator ?o. }";
   
    System.out.println("RESULTS:");

    Query query = QueryFactory.create(Q);
    QueryExecution qe = QueryExecutionFactory.create(query, model);
    try {
      Model model_ = qe.execConstruct();
     
  //    _listStatements(model_);
 
      StringWriter writer = new StringWriter();
      model_.getWriter().write(model_, writer, null);
 
      String result = writer.getBuffer().toString();
      System.out.println(result);
    }
    finally {
      qe.close();
    }

  }
View Full Code Here


    System.out.println("RESULTS:");
   
    Query query = QueryFactory.create(Q);

    QueryExecution qe = QueryExecutionFactory.create(query, model);
    ResultSet results = qe.execSelect();
    ResultSetFormatter.out(System.out, results, query);

    qe.close();
  }
View Full Code Here

   
    System.out.println("QUERY:\n" +Q);
    System.out.println("RESULTS:");

    Query query = QueryFactory.create(Q);
    QueryExecution qe = QueryExecutionFactory.create(query, model);
    try {
      Model model_ = qe.execConstruct();
     
      _listStatements(model_);
 
//      StringWriter writer = new StringWriter();
//      model_.getWriter().write(model_, writer, null);
// 
//      String result = writer.getBuffer().toString();
//      System.out.println(result);
    }
    finally {
      qe.close();
    }

  }
View Full Code Here

    {
        Query q = QueryFactory.create(qs) ;
        if ( q.getResultVars().size() != 1 )
            throw new ARQException("getExactlyOne: Must have exactly one result columns") ;
        String varname = q.getResultVars().get(0) ;
        QueryExecution qExec = QueryExecutionFactory.create(q, ds);
        return getExactlyOne(qExec, varname) ;
    }
View Full Code Here

    @AfterClass  public static void afterClass() { FunctionRegistry.get().remove(ns + "wait") ; }
   
    @Test(expected=QueryCancelledException.class)
    public void test_Cancel_API_1()
    {
        QueryExecution qExec = makeQExec("SELECT * {?s ?p ?o}") ;
        try {
            ResultSet rs = qExec.execSelect() ;
            assertTrue(rs.hasNext()) ;
            qExec.abort();
           
            assertTrue(rs.hasNext()) ;
            rs.nextSolution();
            assertFalse("Results not expected after cancel.", rs.hasNext()) ;
        } finally { qExec.close() ; }
    }
View Full Code Here

    }
   
    @Test(expected=QueryCancelledException.class)
    public void test_Cancel_API_2()
    {
        QueryExecution qExec = makeQExec("PREFIX ex: <" + ns + "> " +
        "SELECT * {?s ?p ?o . FILTER ex:wait(100) }") ;
        try {
            ResultSet rs = qExec.execSelect() ;
            assertTrue(rs.hasNext()) ;
            qExec.abort();
            assertTrue(rs.hasNext()) ;
            rs.nextSolution();
            assertFalse("Results not expected after cancel.", rs.hasNext()) ;
        } finally { qExec.close() ; }
    }   
View Full Code Here

        } finally { qExec.close() ; }
    }   
   
    @Test public void test_Cancel_API_3() throws InterruptedException
    {
        QueryExecution qExec = makeQExec("PREFIX ex: <" + ns + "> " +
        "SELECT * {?s ?p ?o . FILTER ex:wait(100) }") ;
        CancelThreadRunner thread = new CancelThreadRunner(qExec);
        thread.start();
        synchronized (qExec) { qExec.wait() ; }
        qExec.abort();
        synchronized (qExec) { qExec.notify() ; }
        assertEquals (1, thread.getCount()) ;
    }
View Full Code Here

        assertEquals (1, thread.getCount()) ;
    }
   
    @Test public void test_Cancel_API_4() throws InterruptedException
    {
        QueryExecution qExec = makeQExec("PREFIX ex: <" + ns + "> " +
        "SELECT * {?s ?p ?o } ORDER BY ex:wait(100)") ;
        CancelThreadRunner thread = new CancelThreadRunner(qExec);
        thread.start();
        synchronized (qExec) { qExec.wait() ; }
        qExec.abort();
        synchronized (qExec) { qExec.notify() ; }
        assertEquals (1, thread.getCount()) ;
    }
View Full Code Here

    }

    private QueryExecution makeQExec(String queryString)
    {
        Query q = QueryFactory.create(queryString) ;
        QueryExecution qExec = QueryExecutionFactory.create(q, m) ;
        return qExec ;
    }
View Full Code Here

        Assert.assertTrue(UserDefinedFunctionFactory.getFactory().isRegistered("http://example/square"));
       
        String query = "SELECT (<http://example/square>(2) AS ?square) { }";
        Query q = QueryFactory.create(query);
       
        QueryExecution qe = QueryExecutionFactory.create(q, ModelFactory.createDefaultModel());
        ResultSet rset = qe.execSelect();
        Assert.assertTrue(rset.hasNext());
        Binding b = rset.nextBinding();
        Assert.assertFalse(rset.hasNext());
        qe.close();
       
        //Validate returned value
        Node actual = b.get(Var.alloc("square"));
        Assert.assertEquals(NodeFactoryExtra.intToNode(4), actual);
    }
View Full Code Here

TOP

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

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.