Package com.hp.hpl.jena.query

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


        return query ;
    }
   
    public static Element parseElement(String string)
    {
        final Query query = new Query () ;
        Action action = new Action() {
            @Override
            public void exec(ARQParser parser) throws Exception
            {
                Element el = parser.GroupGraphPattern() ;
                query.setQueryPattern(el) ;
            }
        } ;
        perform(query, string, action) ;
        return query.getQueryPattern() ;
    }
View Full Code Here


       
        // Force setup
        {
            getStore() ;
            getModStore().getDataset() ;
            Query query = modQuery.getQuery() ;
            QueryExecution qExec = QueryExecutionFactory.create(query, getModStore().getDataset()) ;
            // Don't execute
            qExec.abort();
        }
       
        if ( getModTime().timingEnabled() )
        {
            // Setup costs : flush classes into memory and establish connection
            getModTime().startTimer() ;
            long connectTime =  getModTime().endTimer() ;
            //System.out.println("Connect time:    "+timeStr(connectTime)) ;
           
            getModTime().startTimer() ;
            Query query = modQuery.getQuery() ;
            long javaTime = getModTime().endTimer() ;
           
            if ( isVerbose() )
                System.out.println("Class load time: "+getModTime().timeStr(javaTime)) ;
        }
       
       
        long totalTime = 0 ;
        try {
            getModTime().startTimer() ;
            for ( int i = 0 ; i < repeatCount ; i++ )
            {
//                if ( i == 2 )
//                {
//                    // Reset timer to forget classloading overhead
//                    getModTime().endTimer() ;
//                    getModTime().startTimer() ;
//                }
                   
                Query query = modQuery.getQuery() ;
                QueryExecution qExec = QueryExecutionFactory.create(query, getModStore().getDataset()) ;
               
                if ( isVerbose() )
                    PrintSDB.print(((QueryExecutionBase)qExec).getPlan().getOp()) ;
               
View Full Code Here

    }

    @Override
    protected void execCmd(List<String> positionalArgs)
    {
        Query query = modQuery.getQuery() ;
        compilePrint(getStore(), query) ;
    }
View Full Code Here

        return query.getQueryPattern() ;
    }
   
    public static Template parseTemplate(String string)
    {
        final Query query = new Query () ;
        Action action = new Action() {
            @Override
            public void exec(ARQParser parser) throws Exception
            {
                Template t = parser.ConstructTemplate() ;
                query.setConstructTemplate(t) ;
            }
        } ;
        perform(query, string, action) ;
        return query.getConstructTemplate() ;
    }
View Full Code Here

//    protected UpdateSink getUpdateSink() { return sink ; }
    public void setUpdateSink(UpdateSink sink)
    {
        this.sink = sink ;
        this.query = new Query() ;
        setPrologue(sink.getPrologue()) ;
    }
View Full Code Here

    protected void startSubSelect(int line, int col)
    {
        if ( query == null )
            throw new ARQInternalErrorException("Parser query object is null") ;
        stack.push(query) ;
        query = new Query(getPrologue()) ;
    }
View Full Code Here

        query = new Query(getPrologue()) ;
    }
   
    protected Query endSubSelect(int line, int column)
    {
        Query subQuery = query ;
        if ( ! subQuery.isSelectType() )
            throwParseException("Subquery not a SELECT query", line, column) ;
        query = stack.pop();
        return subQuery ;
    }
View Full Code Here

       
        // Potentially expensive query.
        String sparqlQueryString = "SELECT (count(*) AS ?count) { ?s ?p ?o }" ;
        // See http://incubator.apache.org/jena/documentation/query/app_api.html
       
        Query query = QueryFactory.create(sparqlQueryString) ;
        QueryExecution qexec = QueryExecutionFactory.create(query, dataset) ;
        try {
          ResultSet results = qexec.execSelect() ;
          for ( ; results.hasNext() ; )
          {
View Full Code Here

       
        // Query string.
        String queryString = prolog + NL +
            "SELECT ?title WHERE {?x dc:title ?title}" ;
       
        Query query = QueryFactory.create(queryString) ;
        // Print with line numbers
        query.serialize(new IndentedWriter(System.out,true)) ;
        System.out.println() ;
       
        // Create a single execution of this query, apply to a model
        // which is wrapped up as a Dataset
       
View Full Code Here

   
    public static void main(String[] args)
    {
        Model model = createModel() ;
       
        Query query = QueryFactory.make() ;
        query.setQuerySelectType() ;
       
        // See also ExProg1
       
        ElementGroup elg = new ElementGroup() ;
       
        Var varTitle = Var.alloc("title") ;
        Var varX = Var.alloc("x") ;
       
        Triple t1 = new Triple(varX, DC.title.asNode(),  varTitle) ;
        elg.addTriplePattern(t1) ;
       
        // Adds a filter.  Need to wrap variable in a NodeVar.
        Expr expr = new E_Regex(new ExprVar(varTitle), "sparql", "i") ;
        ElementFilter filter = new  ElementFilter(expr) ;
        elg.addElementFilter(filter) ;
       
        // Attach the group to query. 
        query.setQueryPattern(elg) ;
       
        // Choose what we want - SELECT ?title
        query.addResultVar(varTitle) ;
       
        // Print query with line numbers
        // Prefix mapping just helps serialization
        query.getPrefixMapping().setNsPrefix("dc" , DC.getURI()) ;
        query.serialize(new IndentedWriter(System.out,true)) ;
        System.out.println() ;
       
        QueryExecution qexec = QueryExecutionFactory.create(query, model) ;

        try {
View Full Code Here

TOP

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

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.