Search in sources :

Example 36 with Query

use of org.apache.jena.query.Query in project jena by apache.

the class ParserSPARQL11 method parseElement.

public static Element parseElement(String string) {
    final Query query = new Query();
    Action action = new Action() {

        @Override
        public void exec(SPARQLParser11 parser) throws Exception {
            Element el = parser.GroupGraphPattern();
            query.setQueryPattern(el);
        }
    };
    perform(query, string, action);
    return query.getQueryPattern();
}
Also used : SPARQLParser11(org.apache.jena.sparql.lang.sparql_11.SPARQLParser11) Query(org.apache.jena.query.Query) Element(org.apache.jena.sparql.syntax.Element)

Example 37 with Query

use of org.apache.jena.query.Query in project jena by apache.

the class SPARQLParserBase method endSubSelect.

protected Query endSubSelect(int line, int column) {
    Query subQuery = query;
    if (!subQuery.isSelectType())
        throwParseException("Subquery not a SELECT query", line, column);
    popQuery();
    return subQuery;
}
Also used : Query(org.apache.jena.query.Query)

Example 38 with Query

use of org.apache.jena.query.Query in project jena by apache.

the class ParserSPARQL10 method parseElement.

public static Element parseElement(String string) {
    final Query query = new Query();
    Action action = new Action() {

        @Override
        public void exec(SPARQLParser10 parser) throws Exception {
            Element el = parser.GroupGraphPattern();
            query.setQueryPattern(el);
        }
    };
    perform(query, string, action);
    return query.getQueryPattern();
}
Also used : Query(org.apache.jena.query.Query) Element(org.apache.jena.sparql.syntax.Element) SPARQLParser10(org.apache.jena.sparql.lang.sparql_10.SPARQLParser10)

Example 39 with Query

use of org.apache.jena.query.Query in project jena by apache.

the class ParserSPARQL10 method parseTemplate.

public static Template parseTemplate(String string) {
    final Query query = new Query();
    Action action = new Action() {

        @Override
        public void exec(SPARQLParser10 parser) throws Exception {
            Template t = parser.ConstructTemplate();
            query.setConstructTemplate(t);
        }
    };
    perform(query, string, action);
    return query.getConstructTemplate();
}
Also used : Query(org.apache.jena.query.Query) SPARQLParser10(org.apache.jena.sparql.lang.sparql_10.SPARQLParser10) Template(org.apache.jena.sparql.syntax.Template)

Example 40 with Query

use of org.apache.jena.query.Query in project jena by apache.

the class TestVarRename method checkRename.

private void checkRename(String queryString, String opExpectedString) {
    Op opExpected = SSE.parseOp(opExpectedString);
    queryString = "PREFIX : <http://example/>\n" + queryString;
    Query query = QueryFactory.create(queryString);
    Op op = Algebra.compile(query);
    Op opRenamed = TransformScopeRename.transform(op);
    assertEquals(opExpected, opRenamed);
}
Also used : Op(org.apache.jena.sparql.algebra.Op) Query(org.apache.jena.query.Query)

Aggregations

Query (org.apache.jena.query.Query)265 Test (org.junit.Test)78 ContractTest (org.xenei.junit.contract.ContractTest)65 QueryExecution (org.apache.jena.query.QueryExecution)63 ElementSubQuery (org.apache.jena.sparql.syntax.ElementSubQuery)49 WhereValidator (org.apache.jena.arq.querybuilder.WhereValidator)42 Var (org.apache.jena.sparql.core.Var)42 Triple (org.apache.jena.graph.Triple)38 ElementPathBlock (org.apache.jena.sparql.syntax.ElementPathBlock)32 ResultSet (org.apache.jena.query.ResultSet)29 Node (org.apache.jena.graph.Node)28 TriplePath (org.apache.jena.sparql.core.TriplePath)28 QuerySolution (org.apache.jena.query.QuerySolution)26 ExprVar (org.apache.jena.sparql.expr.ExprVar)24 Binding (org.apache.jena.sparql.engine.binding.Binding)22 Model (org.apache.jena.rdf.model.Model)20 HashMap (java.util.HashMap)19 Dataset (org.apache.jena.query.Dataset)15 Op (org.apache.jena.sparql.algebra.Op)15 SelectBuilder (org.apache.jena.arq.querybuilder.SelectBuilder)14