Package com.hp.hpl.jena.query

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


           
            // 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
                if ( x instanceof Literal )
                {
                    Literal titleStr = (Literal)x  ;
View Full Code Here


            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
                if ( x.isLiteral() )
                {
                    Literal titleStr = (Literal)x  ;
View Full Code Here

           
            // 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
                if ( x instanceof Literal )
                {
                    Literal titleStr = (Literal)x  ;
View Full Code Here

   
    ResultSet res = qe.execSelect();
   
    assertTrue("I have results", res.hasNext());
   
    QuerySolution soln = res.nextSolution();
   
    RDFNode subj = soln.get("subj");
       
    assertEquals("Result is correct", "urn:ex:TABLE1;FIELD1=2;FIELD3=3", ((Resource) subj).getURI());
   
    qe = prepareQuery("ASK WHERE {  <urn:ex:TABLE1;FIELD1=2;FIELD3=3> <urn:ex:TABLE1_FIELD2> 'C' } ");
   
View Full Code Here

   
    QueryEngine qe = new LdapQueryEngine(query, config);
    qe.setDataset(DatasetFactory.create());
    ResultSet res = qe.execSelect();
    assertTrue("I have results", res.hasNext());
    QuerySolution result = res.nextSolution();
    assertTrue("I have a country", result.contains("country"));
    assertEquals("I have the correct country", Node.createLiteral("GB"), result.get("country").asNode());
  }
View Full Code Here

        QueryExecution qexec = QueryExecutionFactory.create(query, dataset) ;
        try {
          ResultSet results = qexec.execSelect() ;
          for ( ; results.hasNext() ; )
          {
              QuerySolution soln = results.nextSolution() ;
              int count = soln.getLiteral("count").getInt() ;
              System.out.println("count = "+count) ;
          }
        } finally { qexec.close() ; }

        // Close the dataset.
View Full Code Here

    if (!supportsSPARQL11) return null;
    query = preProcessQuery(query, resourceURI);
    ResultSet rs = execQuerySelect(query);
    Map<Property, Integer> results = new HashMap<Property, Integer>();
    while (rs.hasNext()) {
      QuerySolution solution = rs.next();
      if (!solution.contains("p") || !solution.contains("count")) continue;
      Resource p = solution.get("p").asResource();
      int count = solution.get("count").asLiteral().getInt();
      results.put(ResourceFactory.createProperty(p.getURI()), count);
    }
    return results;
  }
View Full Code Here

        QueryExecution qe=QueryExecutionFactory.create(q,m);
        ResultSet r=qe.execSelect();
        assertEquals(1,r.getResultVars().size());
        assertEquals("dayName",r.getResultVars().get(0));
        assertTrue(r.hasNext());
        QuerySolution qs=r.nextSolution();
        assertEquals("Sunday",qs.get("dayName").asLiteral().getLexicalForm())
    }
View Full Code Here

            List<String> vars=results.getResultVars();
            if(vars.size()!=1) {
                throw new Exception("Scalar query returns other than one column");
            }

            QuerySolution row=results.nextSolution();
            RDFNode value=row.get(vars.get(0));
            if (results.hasNext()) {
                throw new Exception("Scalar query returns more than one row");
            }
            return value;
        } finally { qe.close(); }
View Full Code Here

            ResultSet results=qe.execSelect();
            Map<RDFNode,RDFNode> map=Maps.newHashMap();
            List<String> vars=results.getResultVars();

            while(results.hasNext()) {
                QuerySolution row=results.nextSolution();
                map.put(row.get(vars.get(0)),row.get(vars.get(1)));
            }
            return map;
        } finally { qe.close(); }
    }
View Full Code Here

TOP

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

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.