本文整理汇总了Java中org.openrdf.query.algebra.StatementPattern.Scope类的典型用法代码示例。如果您正苦于以下问题:Java Scope类的具体用法?Java Scope怎么用?Java Scope使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Scope类属于org.openrdf.query.algebra.StatementPattern包,在下文中一共展示了Scope类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testComplexQuery
import org.openrdf.query.algebra.StatementPattern.Scope; //导入依赖的package包/类
@Test
public void testComplexQuery() throws Exception {
String text = "PREFIX foaf: <" + FOAF.NAMESPACE + ">\n"
+ "PREFIX ex: <" + EX + ">\n"
+ "SELECT * WHERE {\n"
+ " { ?x a foaf:Person } UNION {\n"
+ " GRAPH ex:Graph1 { ?y a foaf:Person }\n"
+ " } .\n"
+ " GRAPH ex:Graph2 {\n"
+ " ?x foaf:knows ?y .\n"
+ " }\n ."
+ " OPTIONAL { ?x foaf:mbox ?m } .\n"
+ " FILTER (?x != ?y) .\n"
+ "}";
ParsedQuery query = new SPARQLParser().parseQuery(text, null);
AntecedentVisitor visitor = new AntecedentVisitor();
query.getTupleExpr().visit(visitor);
Set<StatementPattern> expected = Sets.newHashSet(
new StatementPattern(Scope.NAMED_CONTEXTS, new Var("y"), c(RDF.TYPE), c(FOAF.PERSON), c(G1)),
new StatementPattern(new Var("x"), c(RDF.TYPE), c(FOAF.PERSON)),
new StatementPattern(Scope.NAMED_CONTEXTS, new Var("x"), c(FOAF.KNOWS), new Var("y"), c(G2)),
new StatementPattern(new Var("x"), c(FOAF.MBOX), new Var("m")));
Assert.assertEquals(expected, visitor.getAntecedents());
}
示例2: extractConstructExpression
import org.openrdf.query.algebra.StatementPattern.Scope; //导入依赖的package包/类
private static TupleExpr extractConstructExpression(
final Map<String, ExtensionElem> extensions,
final Iterable<? extends ProjectionElemList> multiProjections) {
TupleExpr expression = null;
for (final ProjectionElemList projections : multiProjections) {
final Var subj = extractConstructVar(extensions, projections.getElements().get(0));
final Var pred = extractConstructVar(extensions, projections.getElements().get(1));
final Var obj = extractConstructVar(extensions, projections.getElements().get(2));
final Var ctx = projections.getElements().size() < 4 ? null : extractConstructVar(
extensions, projections.getElements().get(3));
final StatementPattern pattern = new StatementPattern(
ctx == null ? Scope.DEFAULT_CONTEXTS : Scope.NAMED_CONTEXTS, subj, pred,
obj, ctx);
expression = expression == null ? pattern : new Join(expression, pattern);
}
return expression;
}
示例3: getGraphs
import org.openrdf.query.algebra.StatementPattern.Scope; //导入依赖的package包/类
private Set<URI> getGraphs(StatementPattern sp) {
if (sp.getScope() == Scope.DEFAULT_CONTEXTS)
return dataset.getDefaultGraphs();
return dataset.getNamedGraphs();
}