当前位置: 首页>>代码示例>>Java>>正文


Java FOAF.NAMESPACE属性代码示例

本文整理汇总了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());
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:17,代码来源:AntecedentVisitorTest.java

示例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());
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:21,代码来源:AntecedentVisitorTest.java

示例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());
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:24,代码来源:AntecedentVisitorTest.java

示例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());
    }));
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:25,代码来源:AntecedentVisitorTest.java

示例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);
	}
}
 
开发者ID:cumulusrdf,项目名称:cumulusrdf,代码行数:24,代码来源:KnownURIsDictionaryTest.java

示例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);
}
 
开发者ID:cumulusrdf,项目名称:cumulusrdf,代码行数:11,代码来源:KnownURIsDictionaryTest.java

示例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);
	}
}
 
开发者ID:cumulusrdf,项目名称:cumulusrdf,代码行数:38,代码来源:KnownURIsDictionaryTest.java


注:本文中的org.openrdf.model.vocabulary.FOAF.NAMESPACE属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。