use of org.apache.jena.sparql.syntax.Template in project jena by apache.
the class ParserSPARQL11 method parseTemplate.
public static Template parseTemplate(String string) {
final Query query = new Query();
Action action = new Action() {
@Override
public void exec(SPARQLParser11 parser) throws Exception {
Template t = parser.ConstructTemplate();
query.setConstructTemplate(t);
}
};
perform(query, string, action);
return query.getConstructTemplate();
}
use of org.apache.jena.sparql.syntax.Template in project jena by apache.
the class ParserARQ method parseTemplate.
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();
}
use of org.apache.jena.sparql.syntax.Template in project jena by apache.
the class ConstructHandlerTest method testAddAll.
@Test
public void testAddAll() {
Triple t = new Triple(NodeFactory.createURI("one"), NodeFactory.createURI("two"), NodeFactory.createURI("three"));
ConstructHandler handler2 = new ConstructHandler(new Query());
handler2.addConstruct(t);
handler.addAll(handler2);
Template template = query.getConstructTemplate();
assertNotNull(template);
List<Triple> lst = template.getTriples();
assertEquals(1, lst.size());
assertEquals(t, lst.get(0));
}
use of org.apache.jena.sparql.syntax.Template in project jena by apache.
the class ConstructHandlerTest method testAddConstruct.
@Test
public void testAddConstruct() {
Triple t = new Triple(NodeFactory.createURI("one"), NodeFactory.createURI("two"), NodeFactory.createURI("three"));
handler.addConstruct(t);
Template template = query.getConstructTemplate();
assertNotNull(template);
List<Triple> lst = template.getTriples();
assertEquals(1, lst.size());
assertEquals(t, lst.get(0));
}
use of org.apache.jena.sparql.syntax.Template in project jena by apache.
the class ConstructHandler method addConstruct.
/**
* Add a triple to the construct statement.
* @param t The triple to add.
*/
public void addConstruct(Triple t) {
constructs.add(t);
query.setConstructTemplate(new Template(BasicPattern.wrap(constructs)));
}
Aggregations