Package com.hp.hpl.jena.query

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


     * Throw excpetion if more than one.
     */
    public static RDFNode getOne(QueryExecution qExec, String varname)
    {
        try {
            ResultSet rs = qExec.execSelect() ;
           
            if ( ! rs.hasNext() )
                return null ;

            QuerySolution qs = rs.nextSolution() ;
            RDFNode r = qs.get(varname) ;
            if ( rs.hasNext() )
            {
                QuerySolution qs2 = rs.next();
                RDFNode r2 = qs2.get(varname) ;
                if ( rs.hasNext() )
                    throw new ARQException("More than one: var ?"+varname+ " -> "+r+", "+r2+", ...") ;
                else
                    throw new ARQException("Found two matches: var ?"+varname+ " -> "+r+", "+r2) ;
            }
            return r ;
View Full Code Here


        InputStream in = httpQuery.exec() ;

        // Read the whole of the results now.
        // Avoids the problems with calling back into the same system e.g. Fuseki+SERVICE <http://localhost:3030/...>
       
        ResultSet rs = ResultSetFactory.fromXML(in) ;
        QueryIterator qIter = new QueryIteratorResultSet(rs) ;
        qIter = QueryIter.materialize(qIter) ;
        // And close connection now, not when qIter is closed.
        IO.close(in) ;
        return  qIter ;
View Full Code Here

    public abstract boolean isEmpty() ;

    @Override
    public ResultSet toResultSet() {
        QueryIterator qIter = iterator(null) ;
        ResultSet rs = new ResultSetStream(getVarNames(), null, qIter) ;
        rs = ResultSetFactory.makeRewindable(rs) ;
        qIter.close() ;
        return rs ;
    }
View Full Code Here

    public static Iterator<Node> storeGraphNames(Store store)
    {
        List<Node> x = new ArrayList<Node>() ;
        String qs = "SELECT ?g { GRAPH ?g { }}" ;
        QueryExecution qExec = QueryExecutionFactory.create(qs, SDBFactory.connectDataset(store)) ;
        ResultSet rs = qExec.execSelect() ;
        Var var_g = Var.alloc("g") ;
        while(rs.hasNext())
        {
            Node n = rs.nextBinding().get(var_g) ;
            x.add(n) ;
        }
        return x.iterator() ;
    }
View Full Code Here

    public static boolean containsGraph(Store store, Node graphNode)
    {
        String qs = "SELECT * { GRAPH "+FmtUtils.stringForNode(graphNode)+" { ?s ?p ?o }} LIMIT 1" ;
        Dataset ds = SDBFactory.connectDataset(store) ;
        QueryExecution qExec = QueryExecutionFactory.create(qs, ds) ;
        ResultSet rs = qExec.execSelect() ;
        boolean b = rs.hasNext() ;
        qExec.close();
        return b ;
    }
View Full Code Here

                                             "PREFIX  xsd:    <http://www.w3.org/2001/XMLSchema#>",
                                             "PREFIX  owl:    <http://www.w3.org/2002/07/owl#>",
                                             "PREFIX skos:    <http://www.w3.org/2004/02/skos/core#>") ;
        Query query = QueryFactory.create(preamble+"\n"+qs, Syntax.syntaxARQ) ;
        QueryExecution qexec = QueryExecutionFactory.create(query, model) ;
        ResultSet rs = qexec.execSelect() ;
        for ( ; rs.hasNext() ; )
        {
            QuerySolution soln= rs.next() ;
            Node x = soln.get("x").asNode() ;
            Node y = soln.get("y").asNode() ;
            if ( ! multimap.containsKey(x) )
                multimap.put(x, new ArrayList<Node>()) ;
            multimap.get(x).add(y) ;
View Full Code Here

        if ( model == null )
            model = GraphFactory.makeJenaDefaultModel() ;
        if ( rows != null )
        {
            QueryIterator qIter = new QueryIterPlainWrapper(rows.iterator()) ;
            ResultSet rs = new ResultSetStream(Var.varNames(vars), model, qIter) ;
            super.set(rs) ;
        }
        else
            super.set(booleanResult) ;
        return this ;
View Full Code Here

    Query query = QueryFactory.create(queryString);

//     Execute the query and obtain results
    QueryExecution qe = QueryExecutionFactory.create(query, manifest);
    ResultSet results = qe.execSelect();
   
    WDSingleTest one = null;
    Resource last = null;
    while (results.hasNext()) {
      QuerySolution s = results.nextSolution();
      Resource in = s.getResource("in");
      Resource out = s.getResource("out");
      Resource test = s.getResource("test");
     
      Property approval = m.createProperty(
View Full Code Here

        model.read(new FileInputStream(license), null);

        QueryExecution qexec = QueryExecutionFactory.create(
            queryString, model);
        try {
          ResultSet results = qexec.execSelect();
          while (results.hasNext()) {
            QuerySolution soln = results.nextSolution();
            try {
              Literal u = soln.getLiteral("user");
//              System.err.println("user: "+u.getString());
              Literal s = soln.getLiteral("software");
//              System.err.println("software: "+s);
View Full Code Here

        Dataset ds = DatasetFactory.create(item.getDefaultGraphURIs(), item.getNamedGraphURIs()) ;
        ARQ.getContext().set(ARQ.strictGraph, oldValue) ;
       
        // ---- First, get the expected results by executing in-memory or from a results file.
       
        ResultSet rs = null ;
        if ( item.getResults() != null )
            rs = item.getResults().getResultSet() ;
        ResultSetRewindable rs1 = null ;
        String expectedLabel = "" ;
        if ( rs != null )
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.