本文整理汇总了Java中org.apache.jena.sparql.syntax.ElementTriplesBlock类的典型用法代码示例。如果您正苦于以下问题:Java ElementTriplesBlock类的具体用法?Java ElementTriplesBlock怎么用?Java ElementTriplesBlock使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ElementTriplesBlock类属于org.apache.jena.sparql.syntax包,在下文中一共展示了ElementTriplesBlock类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visit
import org.apache.jena.sparql.syntax.ElementTriplesBlock; //导入依赖的package包/类
@Override
public void visit(ElementTriplesBlock el) {
final BasicPattern bgp = el.getPattern();
final ElementTriplesBlock nzed = new ElementTriplesBlock();
final NodeExprNormalizer nenzer = new NodeExprNormalizer();
bgp.forEach((t) -> {
t.getSubject().visitWith(nenzer);
Node s = nenzer.getResult();
t.getPredicate().visitWith(nenzer);
Node p = nenzer.getResult();
t.getObject().visitWith(nenzer);
Node o = nenzer.getResult();
nzed.addTriple(new Triple(s, p, o));
});
endVisit(nzed, nenzer);
}
示例2: buildSyntax
import org.apache.jena.sparql.syntax.ElementTriplesBlock; //导入依赖的package包/类
private QueryIterator buildSyntax(QueryIterator input, Node nodeVar, String pattern, ExecutionContext execCxt)
{
Var var2 = createNewVar() ;
// Triple patterns for ?x rdfs:label ?hiddenVar
ElementTriplesBlock elementBGP = new ElementTriplesBlock();
Triple t = new Triple(nodeVar, RDFS.label.asNode(), var2) ;
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) ;
}
示例3: visit
import org.apache.jena.sparql.syntax.ElementTriplesBlock; //导入依赖的package包/类
@Override
public void visit(ElementTriplesBlock el) {
if (el.isEmpty()) {
out.println("# Empty BGP");
return;
}
formatTriples(el.getPattern());
}
示例4: getJenaPath
import org.apache.jena.sparql.syntax.ElementTriplesBlock; //导入依赖的package包/类
/**
* Attempts to parse a given string into a Jena Path.
* Throws an Exception if the string cannot be parsed.
* @param string the string to parse
* @param model the Model to operate on (for prefixes)
* @return a Path or a Resource if this is a URI
*/
public static Object getJenaPath(String string, Model model) throws QueryParseException {
Query query = ARQFactory.get().createQuery(model, "ASK { ?a \n" + string + "\n ?b }");
Element element = query.getQueryPattern();
if(element instanceof ElementGroup) {
Element e = ((ElementGroup)element).getElements().get(0);
if(e instanceof ElementPathBlock) {
return ((ElementPathBlock) e).getPattern().get(0).getPath();
}
else if(e instanceof ElementTriplesBlock) {
return model.asRDFNode(((ElementTriplesBlock) e).getPattern().get(0).getPredicate());
}
}
throw new QueryParseException("Not a SPARQL 1.1 Path expression", 2, 1);
}
示例5: needsDotSeparator
import org.apache.jena.sparql.syntax.ElementTriplesBlock; //导入依赖的package包/类
private static boolean needsDotSeparator(Element el) {
return (el instanceof ElementTriplesBlock) || (el instanceof ElementPathBlock);
}