Package com.hp.hpl.jena.sparql.syntax

Examples of com.hp.hpl.jena.sparql.syntax.ElementGroup


        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
View Full Code Here


        query.setQuerySelectType() ;
       
        // Build pattern
       
        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) ;
       
        // Don't use bNodes for anon variables.  The conversion is done in parsing.
        // BNodes here are assumed to be values from the target graph.
        Triple t2 = new Triple(varX, DC.description.asNode(), Var.alloc("desc")) ;
        elg.addTriplePattern(t2) ;
       
        // Attach the group to query. 
        query.setQueryPattern(elg) ;

        // Choose what we want - SELECT *
 
View Full Code Here

        elementBGP.addTriple(t) ;
       
        // Regular expression for  regex(?hiddenVar, "pattern", "i")
        Expr regex = new E_Regex(new ExprVar(var2.getName()), pattern, "i") ;
       
        ElementGroup elementGroup = new ElementGroup() ;
        elementGroup.addElement(elementBGP) ;
        elementGroup.addElement(new ElementFilter(regex)) ;
        // Compile it.
        // The better design is to build the Op structure programmatically,
        Op op = Algebra.compile(elementGroup) ;
        op = Algebra.optimize(op, execCxt.getContext()) ;
        return QC.execute(op, input, execCxt) ;
View Full Code Here

            throw new QueryExecException("Attempt to get a DESCRIBE result from a "+labelForQuery(query)+" query") ;
        //Was: query.setQueryResultStar(true) ; but why?
        query.setResultVars() ;
        // If there was no WhereClause, use an empty pattern (one solution, no columns).
        if ( query.getQueryPattern() == null )
            query.setQueryPattern(new ElementGroup()) ;
       
        Set<RDFNode> set = new HashSet<RDFNode>() ;

        //May return null (no query pattern)
        ResultSet qRes = execResultSet() ;
View Full Code Here

        return NodeTransformLib.transformQuads(bnodesToVariables, quads) ;
    }
   
    protected Element elementFromQuads(List<Quad> quads)
    {
        ElementGroup el = new ElementGroup() ;
        ElementTriplesBlock x = new ElementTriplesBlock() ;
        // Maybe empty??
        el.addElement(x) ;
        Node g = Quad.defaultGraphNodeGenerated ;
       
        for ( Quad q : quads )
        {
            if ( q.getGraph() != g )
            {
                g = q.getGraph() ;
                x = new ElementTriplesBlock() ;
                if ( g == null || g == Quad.defaultGraphNodeGenerated )
                    el.addElement(x) ;
                else
                {
                    ElementNamedGraph eng = new ElementNamedGraph(g, x) ;
                    el.addElement(eng) ;
                }
            }
            x.addTriple(q.asTriple()) ;
        }
        return el ;
View Full Code Here

        elementBGP.addTriple(t) ;
       
        // Regular expression for  regex(?hiddenVar, "pattern", "i")
        Expr regex = new E_Regex(new ExprVar(var2.getName()), pattern, "i") ;
       
        ElementGroup elementGroup = new ElementGroup() ;
        elementGroup.addElement(elementBGP) ;
        elementGroup.addElement(new ElementFilter(regex)) ;
        // Compile it.
        // The better design is to build the Op structure programmatically,
        Op op = Algebra.compile(elementGroup) ;
        op = Algebra.optimize(op, execCxt.getContext()) ;
        return QC.execute(op, input, execCxt) ;
View Full Code Here

        query.setQuerySelectType() ;
       
        // Build pattern
       
        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) ;
       
        // Don't use bNodes for anon variables.  The conversion is done in parsing.
        // BNodes here are assumed to be values from the target graph.
        Triple t2 = new Triple(varX, DC.description.asNode(), Var.alloc("desc")) ;
        elg.addTriplePattern(t2) ;
       
        // Attach the group to query. 
        query.setQueryPattern(elg) ;

        // Choose what we want - SELECT *
 
View Full Code Here

        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
View Full Code Here

            throw new QueryExecException("Attempt to get a DESCRIBE result from a "+labelForQuery(query)+" query") ;
        //Was: query.setQueryResultStar(true) ; but why?
        query.setResultVars() ;
        // If there was no WhereClause, use an empty pattern (one solution, no columns).
        if ( query.getQueryPattern() == null )
            query.setQueryPattern(new ElementGroup()) ;
       
        Set<RDFNode> set = new HashSet<RDFNode>() ;

        //May return null (no query pattern)
        ResultSet qRes = execResultSet() ;
View Full Code Here

        return NodeTransformLib.transformQuads(bnodesToVariables, quads) ;
    }
   
    protected Element elementFromQuads(List<Quad> quads)
    {
        ElementGroup el = new ElementGroup() ;
        ElementTriplesBlock x = new ElementTriplesBlock() ;
        // Maybe empty??
        el.addElement(x) ;
        Node g = Quad.defaultGraphNodeGenerated ;
       
        for ( Quad q : quads )
        {
            if ( q.getGraph() != g )
            {
                g = q.getGraph() ;
                x = new ElementTriplesBlock() ;
                if ( g == null || g == Quad.defaultGraphNodeGenerated )
                    el.addElement(x) ;
                else
                {
                    ElementNamedGraph eng = new ElementNamedGraph(g, x) ;
                    el.addElement(eng) ;
                }
            }
            x.addTriple(q.asTriple()) ;
        }
        return el ;
View Full Code Here

TOP

Related Classes of com.hp.hpl.jena.sparql.syntax.ElementGroup

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.