本文整理汇总了Java中org.apache.jena.sparql.graph.NodeConst类的典型用法代码示例。如果您正苦于以下问题:Java NodeConst类的具体用法?Java NodeConst怎么用?Java NodeConst使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
NodeConst类属于org.apache.jena.sparql.graph包,在下文中一共展示了NodeConst类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildConstruct
import org.apache.jena.sparql.graph.NodeConst; //导入依赖的package包/类
private TripleCollectorBGP buildConstruct(TripleCollectorBGP collector, Element element) {
if (element instanceof ElementGroup) {
for (Element e : ((ElementGroup) element).getElements()) {
buildConstruct(collector, e);
}
return collector;
} else if (element instanceof ElementNamedGraph) {
collector.addTriple(new Triple(((ElementNamedGraph) element).getGraphNameNode(), NodeConst.nodeRDFType, NodeFactory.createURI("https://www.w3.org/TR/sparql11-service-description/#sd-namedGraphs")));
Element namedGraph = ((ElementNamedGraph) element).getElement();
return buildConstruct(collector, namedGraph);
} else if (element instanceof ElementPathBlock) {
ElementPathBlock epb = (ElementPathBlock) element;
List<TriplePath> list = epb.getPattern().getList();
for (TriplePath triplePath : list) {
collector.addTriple(triplePath.asTriple());
}
}
return collector;
}
示例2: initializeMatcher
import org.apache.jena.sparql.graph.NodeConst; //导入依赖的package包/类
private void initializeMatcher() {
Item type = Item.createNode(NodeConst.nodeRDFType);
//matcher.addPattern(new Pattern(1, TERM, TERM, TERM)) ; // SPO - built-in - not needed as a rule
// Numbers choosen as an approximation for a ldf graph of size numTriples
matcher.addPattern(new Pattern( 5, TERM, TERM, VAR)); // SP?
matcher.addPattern(new Pattern(Math.max(numTriples / 1000, 1000), VAR, type, TERM)); // ? type O -- worse than ?PO
matcher.addPattern(new Pattern(Math.max(numTriples / 10000, 90), VAR, TERM, TERM)); // ?PO
matcher.addPattern(new Pattern( 3, TERM, VAR, TERM)); // S?O
matcher.addPattern(new Pattern( 40, TERM, VAR, VAR)); // S??
matcher.addPattern(new Pattern( 200, VAR, VAR, TERM)); // ??O
matcher.addPattern(new Pattern(Math.max(numTriples / 200, 2000), VAR, TERM, VAR)); // ?P?
matcher.addPattern(new Pattern(numTriples, VAR, VAR, VAR)); // ???
}
示例3: main
import org.apache.jena.sparql.graph.NodeConst; //导入依赖的package包/类
public static void main(String[] args) {
// Example aggregate that counts literals.
// Returns unbound for no rows.
String aggUri = "http://example/countLiterals" ;
/* Registration */
AggregateRegistry.register(aggUri, myAccumulatorFactory, NodeConst.nodeMinusOne);
// Some data.
Graph g = SSE.parseGraph("(graph (:s :p :o) (:s :p 1))") ;
String qs = "SELECT (<http://example/countLiterals>(?o) AS ?x) {?s ?p ?o}" ;
// Execution as normal.
Query q = QueryFactory.create(qs) ;
try ( QueryExecution qexec = QueryExecutionFactory.create(q, ModelFactory.createModelForGraph(g)) ) {
ResultSet rs = qexec.execSelect() ;
ResultSetFormatter.out(rs);
}
}