本文整理汇总了Java中org.openrdf.model.vocabulary.FOAF.NAMESPACE属性的典型用法代码示例。如果您正苦于以下问题:Java FOAF.NAMESPACE属性的具体用法?Java FOAF.NAMESPACE怎么用?Java FOAF.NAMESPACE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.openrdf.model.vocabulary.FOAF
的用法示例。
在下文中一共展示了FOAF.NAMESPACE属性的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testSelectQuery
@Test
public void testSelectQuery() throws Exception {
String text = "PREFIX foaf: <" + FOAF.NAMESPACE + ">\n"
+ "SELECT * WHERE {\n"
+ " ?x a foaf:Person .\n"
+ " ?y a foaf:Person .\n"
+ " ?x foaf:knows ?y .\n"
+ "}";
ParsedQuery query = new SPARQLParser().parseQuery(text, null);
AntecedentVisitor visitor = new AntecedentVisitor();
query.getTupleExpr().visit(visitor);
Set<StatementPattern> expected = Sets.newHashSet(
new StatementPattern(new Var("x"), c(RDF.TYPE), c(FOAF.PERSON)),
new StatementPattern(new Var("y"), c(RDF.TYPE), c(FOAF.PERSON)),
new StatementPattern(new Var("x"), c(FOAF.KNOWS), new Var("y")));
Assert.assertEquals(expected, visitor.getAntecedents());
}
示例2: testConstructQuery
@Test
public void testConstructQuery() throws Exception {
String text = "PREFIX foaf: <" + FOAF.NAMESPACE + ">\n"
+ "CONSTRUCT {\n"
+ " ?y foaf:knows ?x .\n"
+ " ?y <urn:knows> ?x .\n"
+ " ?x <urn:knows> ?y .\n"
+ "} WHERE {\n"
+ " ?x a foaf:Person .\n"
+ " ?y a foaf:Person .\n"
+ " ?x foaf:knows ?y .\n"
+ "}";
ParsedQuery query = new SPARQLParser().parseQuery(text, null);
AntecedentVisitor visitor = new AntecedentVisitor();
query.getTupleExpr().visit(visitor);
Set<StatementPattern> expected = Sets.newHashSet(
new StatementPattern(new Var("x"), c(RDF.TYPE), c(FOAF.PERSON)),
new StatementPattern(new Var("y"), c(RDF.TYPE), c(FOAF.PERSON)),
new StatementPattern(new Var("x"), c(FOAF.KNOWS), new Var("y")));
Assert.assertEquals(expected, visitor.getAntecedents());
}
示例3: testComplexQuery
@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());
}
示例4: testBNodeQuery
@Test
public void testBNodeQuery() throws Exception {
String text = "PREFIX foaf: <" + FOAF.NAMESPACE + ">\n"
+ "SELECT * WHERE {\n"
+ " ?x a [ rdfs:subClassOf foaf:Person ] .\n"
+ " ?x foaf:knows ?y .\n"
+ "}";
ParsedQuery query = new SPARQLParser().parseQuery(text, null);
AntecedentVisitor visitor = new AntecedentVisitor();
query.getTupleExpr().visit(visitor);
Set<StatementPattern> actual = visitor.getAntecedents();
Assert.assertEquals(3, actual.size());
StatementPattern knows = new StatementPattern(new Var("x"), c(FOAF.KNOWS), new Var("y"));
Assert.assertTrue(actual.remove(knows));
Assert.assertTrue(actual.removeIf(sp -> {
return sp.getSubjectVar().equals(new Var("x"))
&& RDF.TYPE.equals(sp.getPredicateVar().getValue())
&& sp.getObjectVar().getValue() == null;
}));
Assert.assertTrue(actual.removeIf(sp -> {
return sp.getSubjectVar().getValue() == null
&& RDFS.SUBCLASSOF.equals(sp.getPredicateVar().getValue())
&& FOAF.PERSON.equals(sp.getObjectVar().getValue());
}));
}
示例5: removeManagedURI
/**
* Tests remove() method with managed URI.
*
* @throws Exception never otherwise the test fails.
*/
@Test
public void removeManagedURI() throws Exception {
final String[] managedNamespaces = {
FOAF.NAMESPACE,
RDFS.NAMESPACE,
OWL.NAMESPACE };
for (final String managedNamespace : managedNamespaces) {
assertTrue(_cut.contains(managedNamespace));
final Value uri = buildResource(managedNamespace + randomString());
final String n3 = NTriplesUtil.toNTriplesString(uri);
_cut.removeValue(uri, _isPredicate);
verify(_dummyIndex).remove(n3);
reset(_dummyIndex);
}
}
示例6: useInjectedDomains
/**
* Using the appropriate constructor, it is possible to define a custom set of domains.
*/
@Test
public void useInjectedDomains() {
final String[] customDomains = { FOAF.NAMESPACE, SKOS.NAMESPACE };
_cut = new KnownURIsDictionary(randomString(), _decoratee, customDomains);
assertArrayEquals(customDomains, _cut._domains);
}
示例7: getIdWithManagedURI
/**
* A request is received for a URI with a namespace that belongs to managed domains.
*
* @throws Exception never otherwise the test fails.
*/
@Test
public void getIdWithManagedURI() throws Exception {
final String[] managedNamespaces = {
FOAF.NAMESPACE,
RDFS.NAMESPACE,
OWL.NAMESPACE
};
for (final String managedNamespace : managedNamespaces) {
assertTrue(_cut.contains(managedNamespace));
final Value uri = buildResource(managedNamespace + randomString());
final String n3 = NTriplesUtil.toNTriplesString(uri);
// Make sure the mock index returns "Sorry, we don't have such value".
when(_dummyIndex.get(n3)).thenReturn(ValueDictionaryBase.NOT_SET);
// 1. ask for uri.
byte[] id = _cut.getID(uri, _isPredicate);
// 2. make sure the identifier is well-formed.
assertEquals(KnownURIsDictionary.ID_LENGTH, id.length);
assertEquals(KnownURIsDictionary.KNOWN_URI_MARKER, id[0]);
assertEquals(ValueDictionaryBase.RESOURCE_BYTE_FLAG, id[1]);
// 3. make sure the decoratee wasn't involved in identifier creation.
verify(_decoratee, times(0)).getID(uri, _isPredicate);
verify(_dummyIndex).putQuick(n3, id);
reset(_decoratee, _dummyIndex);
}
}