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


Java方法org.eclipse.rdf4j.query.GraphQueryResult.next代码示例

以下是Java方法org.eclipse.rdf4j.query.GraphQueryResult.next的代码示例。如果您正苦于以下问题:Java GraphQueryResult.next方法的具体用法?Java GraphQueryResult.next怎么用?Java GraphQueryResult.next使用的例子?那么恭喜您, 这里整理的方法代码示例例程将为您提供帮助。您也可以进一步了解该方法所在org.eclipse.rdf4j.query.GraphQueryResult的用法示例。

本文一共展示了GraphQueryResult.next的10个开源代码实例,这些例子默认根据受欢迎程度排序。您可以为喜欢的代码打CALL点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: testGraphQueryWithBaseURIInline

import org.eclipse.rdf4j.query.GraphQueryResult; //导入方法依赖的package包/类
@Test
public void testGraphQueryWithBaseURIInline()
        throws Exception {
    String queryString ="BASE <http://marklogic.com/test/baseuri>\n" +
            "PREFIX nn: <http://semanticbible.org/ns/2006/NTNames#>\n" +
            "PREFIX test: <http://marklogic.com#test>\n" +
            "construct { ?s  test:test <relative>} WHERE {?s nn:childOf nn:Eve . }";
    GraphQuery graphQuery = conn.prepareGraphQuery(QueryLanguage.SPARQL, queryString);
    GraphQueryResult results = graphQuery.evaluate();
    Statement st1 = results.next();
    Assert.assertEquals("http://semanticbible.org/ns/2006/NTNames#Abel", st1.getSubject().stringValue());
    Assert.assertEquals("http://semanticbible.org/ns/2006/NTNames#Abel", st1.getSubject().stringValue());
    Statement st2 = results.next();
    Assert.assertEquals("http://semanticbible.org/ns/2006/NTNames#Cain", st2.getSubject().stringValue());
    results.close();
}
 
开发者ID:marklogic,项目:marklogic-rdf4j,完整代码来源:MarkLogicGraphQueryTest.java


示例2: testGraphQueryWithBaseURIWithEmptyBaseURI

import org.eclipse.rdf4j.query.GraphQueryResult; //导入方法依赖的package包/类
@Ignore
@Test
public void testGraphQueryWithBaseURIWithEmptyBaseURI()
        throws Exception {
    String queryString =
            "PREFIX nn: <http://semanticbible.org/ns/2006/NTNames#>\n" +
                    "PREFIX test: <http://marklogic.com#test>\n" +
                    "construct { ?s  test:test <relative>} WHERE {?s nn:childOf nn:Eve . }";
    GraphQuery graphQuery = conn.prepareGraphQuery(queryString, "");
    exception.expect(QueryEvaluationException.class);

    GraphQueryResult results = graphQuery.evaluate();
    Statement st1 = results.next();
    Assert.assertEquals("http://relative", st1.getObject().stringValue());
    @SuppressWarnings("unused")
    Statement st2 = results.next();
    Assert.assertEquals("http://relative", st1.getObject().stringValue());
    results.close();
}
 
开发者ID:marklogic,项目:marklogic-rdf4j,完整代码来源:MarkLogicGraphQueryTest.java


示例3: testPrepareGraphQueryWithSingleResult

import org.eclipse.rdf4j.query.GraphQueryResult; //导入方法依赖的package包/类
@Test
public void testPrepareGraphQueryWithSingleResult() throws Exception
{
    Resource context1 = conn.getValueFactory().createIRI("http://marklogic.com/test/context1");

    ValueFactory f= conn.getValueFactory();

    IRI alice = f.createIRI("http://example.org/people/alice");
    IRI name = f.createIRI("http://example.org/ontology/name");
    Literal alicesName = f.createLiteral("Alice1");

    Statement st1 = f.createStatement(alice, name, alicesName);
    conn.add(st1,context1);

    String query = " DESCRIBE <http://example.org/people/alice> ";
    GraphQuery queryObj = conn.prepareGraphQuery(query);
    GraphQueryResult result = queryObj.evaluate();

    Assert.assertTrue(result != null);
    Assert.assertTrue(result.hasNext());
    @SuppressWarnings("unused")
    Statement st = result.next();
    Assert.assertFalse(result.hasNext());
    result.close();
    conn.clear(context1);
}
 
开发者ID:marklogic,项目:marklogic-rdf4j,完整代码来源:MarkLogicGraphQueryTest.java


示例4: testConstructQuery

import org.eclipse.rdf4j.query.GraphQueryResult; //导入方法依赖的package包/类
@Test
public void testConstructQuery()
        throws Exception {
    String queryString = "PREFIX nn: <http://semanticbible.org/ns/2006/NTNames#>\n" +
            "PREFIX test: <http://marklogic.com#test>\n" +
            "\n" +
            "construct { ?s  test:test \"0\"} WHERE  {?s nn:childOf nn:Eve . }";
    GraphQuery graphQuery = conn.prepareGraphQuery(QueryLanguage.SPARQL, queryString);
    GraphQueryResult results = graphQuery.evaluate();
    Statement st1 = results.next();
    Assert.assertEquals("http://semanticbible.org/ns/2006/NTNames#Abel", st1.getSubject().stringValue());
    Statement st2 = results.next();
    Assert.assertEquals("http://semanticbible.org/ns/2006/NTNames#Cain", st2.getSubject().stringValue());
    results.close();
}
 
开发者ID:marklogic,项目:marklogic-rdf4j,完整代码来源:MarkLogicGraphQueryTest.java


示例5: testGraphQueryWithBaseURI

import org.eclipse.rdf4j.query.GraphQueryResult; //导入方法依赖的package包/类
@Test
public void testGraphQueryWithBaseURI()
        throws Exception {
    String queryString =
            "PREFIX nn: <http://semanticbible.org/ns/2006/NTNames#>\n" +
                    "PREFIX test: <http://marklogic.com#test>\n" +
                    "construct { ?s  test:test <relative>} WHERE {?s nn:childOf nn:Eve . }";
    GraphQuery graphQuery = conn.prepareGraphQuery(queryString, "http://marklogic.com/test/baseuri/");
    GraphQueryResult results = graphQuery.evaluate();
    Statement st1 = results.next();
    Assert.assertEquals("http://marklogic.com/test/baseuri/relative", st1.getObject().stringValue());
    Statement st2 = results.next();
    Assert.assertEquals("http://marklogic.com/test/baseuri/relative", st2.getObject().stringValue());
    results.close();
}
 
开发者ID:marklogic,项目:marklogic-rdf4j,完整代码来源:MarkLogicGraphQueryTest.java


示例6: testDescribeQuery

import org.eclipse.rdf4j.query.GraphQueryResult; //导入方法依赖的package包/类
@Test
public void testDescribeQuery()
        throws Exception {
    String queryString = "DESCRIBE <http://semanticbible.org/ns/2006/NTNames#Shelah>";
    GraphQuery graphQuery = conn.prepareGraphQuery(QueryLanguage.SPARQL, queryString);
    GraphQueryResult results = graphQuery.evaluate();
    Statement st1 = results.next();
    Assert.assertEquals("http://semanticbible.org/ns/2006/NTNames#Shelah", st1.getSubject().stringValue());
    Assert.assertEquals("http://semanticbible.org/ns/2006/NTNames#childOf", st1.getPredicate().stringValue());
    Assert.assertEquals("http://semanticbible.org/ns/2006/NTNames#CainanSonOfArphaxad", st1.getObject().stringValue());
    results.close();
}
 
开发者ID:marklogic,项目:marklogic-rdf4j,完整代码来源:MarkLogicGraphQueryTest.java


示例7: writeGraphQueryResult

import org.eclipse.rdf4j.query.GraphQueryResult; //导入方法依赖的package包/类
@Override
public void writeGraphQueryResult(GraphQueryResult queryResult) throws ExportException {
    try {
        while (queryResult.hasNext()) {
            queryResult.next();
            tick();
        }
    } catch (QueryEvaluationException e) {
        throw new ExportException(e);
    }
}
 
开发者ID:Merck,项目:Halyard,完整代码来源:HalyardExport.java


示例8: testPrepareGraphQuery2

import org.eclipse.rdf4j.query.GraphQueryResult; //导入方法依赖的package包/类
@Test
public void testPrepareGraphQuery2() throws Exception {
	Statement st1 = vf.createStatement(john, fname, johnfname, dirgraph);
	Statement st2 = vf.createStatement(john, lname, johnlname, dirgraph);
	Statement st3 = vf.createStatement(john, homeTel, johnhomeTel, dirgraph);
	Statement st4 = vf.createStatement(john, email, johnemail, dirgraph);
	Statement st5 = vf.createStatement(micah, fname, micahfname, dirgraph);
	Statement st6 = vf.createStatement(micah, lname, micahlname, dirgraph);
	Statement st7 = vf.createStatement(micah, homeTel, micahhomeTel, dirgraph);
	Statement st8 = vf.createStatement(fei, fname, feifname, dirgraph);
	Statement st9 = vf.createStatement(fei, lname, feilname, dirgraph);
	Statement st10 = vf.createStatement(fei, email, feiemail, dirgraph);

	StatementList<Statement> sL = new StatementList<Statement>(st1);
	sL.add(st2);
	sL.add(st3);
	sL.add(st4);
	sL.add(st5);
	sL.add(st6);
	sL.add(st7);
	sL.add(st8);
	sL.add(st9);
	sL.add(st10);

	StatementIterator iter = new StatementIterator(sL);
	Iteration<Statement, Exception> it = new IteratorIteration<>(iter);
	testAdminCon.add(it, dirgraph);
	Assert.assertEquals(10, testAdminCon.size(dirgraph));

	StringBuilder queryBuilder = new StringBuilder(128);
	queryBuilder.append(" PREFIX ad: <http://marklogicsparql.com/addressbook#>");
	queryBuilder.append(" PREFIX id:  <http://marklogicsparql.com/id#> ");
	queryBuilder.append(" CONSTRUCT{ <#1111> ad:email ?e .} ");
	queryBuilder.append(" FROM <http://marklogic.com/dirgraph> ");
	queryBuilder.append(" WHERE ");
	queryBuilder.append(" { ");
	queryBuilder.append("  <#1111> ad:lastName ?o; ");
	queryBuilder.append("          ad:email  ?e. ");
	queryBuilder.append(" }  ");

	GraphQuery query = testAdminCon.prepareGraphQuery(QueryLanguage.SPARQL, queryBuilder.toString(),
			"http://marklogicsparql.com/id");
	GraphQueryResult result = query.evaluate();

	Literal[] expectedObjectresult = { johnemail };
	IRI[] expectedPredicateresult = { email };
	int i = 0;

	try {
		assertThat(result, is(notNullValue()));
		while (result.hasNext()) {
			Statement st = result.next();
			IRI subject = (IRI) st.getSubject();
			Assert.assertEquals(subject, john);
			IRI predicate = st.getPredicate();
			Assert.assertEquals(predicate, expectedPredicateresult[i]);
			Value object = st.getObject();
			Assert.assertEquals(object, expectedObjectresult[i]);
			i++;
		}
	} finally {
		result.close();
	}

}
 
开发者ID:marklogic,项目:marklogic-rdf4j,完整代码来源:MarkLogicRepositoryConnectionTest.java


示例9: testPrepareGraphQuery4

import org.eclipse.rdf4j.query.GraphQueryResult; //导入方法依赖的package包/类
@Test
public void testPrepareGraphQuery4() throws Exception {

	Statement st1 = vf.createStatement(john, fname, johnfname);
	Statement st2 = vf.createStatement(john, lname, johnlname);
	Statement st3 = vf.createStatement(john, homeTel, johnhomeTel);
	Statement st4 = vf.createStatement(john, email, johnemail);
	Statement st5 = vf.createStatement(micah, fname, micahfname);
	Statement st6 = vf.createStatement(micah, lname, micahlname);
	Statement st7 = vf.createStatement(micah, homeTel, micahhomeTel);
	Statement st8 = vf.createStatement(fei, fname, feifname);
	Statement st9 = vf.createStatement(fei, lname, feilname);
	Statement st10 = vf.createStatement(fei, email, feiemail);

	testWriterCon.add(st1, dirgraph);
	testWriterCon.add(st2, dirgraph);
	testWriterCon.add(st3, dirgraph);
	testWriterCon.add(st4, dirgraph);
	testWriterCon.add(st5, dirgraph);
	testWriterCon.add(st6, dirgraph);
	testWriterCon.add(st7, dirgraph);
	testWriterCon.add(st8, dirgraph);
	testWriterCon.add(st9, dirgraph);
	testWriterCon.add(st10, dirgraph);

	Assert.assertEquals(10, testWriterCon.size(dirgraph));

	String query = " DESCRIBE  <#3333>  ";
	GraphQuery queryObj = testReaderCon.prepareGraphQuery(query, "http://marklogicsparql.com/id");

	GraphQueryResult result = queryObj.evaluate();
	int i = 0;

	try {
		assertThat(result, is(notNullValue()));
		assertThat(result.hasNext(), is(equalTo(true)));
		while (result.hasNext()) {
			Statement st = result.next();
			IRI subject = (IRI) st.getSubject();
			Assert.assertNotNull(subject);
			IRI predicate = st.getPredicate();
			Assert.assertNotNull(predicate);
			Value object = st.getObject();
			Assert.assertNotNull(object);
			i++;
		}
	} finally {
		result.close();
	}
	Assert.assertEquals(3, i);

}
 
开发者ID:marklogic,项目:marklogic-rdf4j,完整代码来源:MarkLogicRepositoryConnectionTest.java


示例10: testPrepareQuery3

import org.eclipse.rdf4j.query.GraphQueryResult; //导入方法依赖的package包/类
@Test
public void testPrepareQuery3() throws Exception {

	Statement st1 = vf.createStatement(john, fname, johnfname);
	Statement st2 = vf.createStatement(john, lname, johnlname);
	Statement st3 = vf.createStatement(john, homeTel, johnhomeTel);

	testWriterCon.add(st1, dirgraph);
	testWriterCon.add(st2, dirgraph);
	testWriterCon.add(st3, dirgraph);

	Assert.assertEquals(3, testWriterCon.size(dirgraph));

	String query = " DESCRIBE  <http://marklogicsparql.com/id#1111>  ";
	Query queryObj = testReaderCon.prepareQuery(query, "http://marklogicsparql.com/id");
	GraphQueryResult result = null;

	if (queryObj instanceof GraphQuery) {
		result = ((GraphQuery) queryObj).evaluate();

	}

	Literal[] expectedObjectresult = { johnfname, johnlname, johnhomeTel };
	IRI[] expectedPredicateresult = { fname, lname, homeTel };
	int i = 0;

	try {
		assertThat(result, is(notNullValue()));
		assertThat(result.hasNext(), is(equalTo(true)));
		while (result.hasNext()) {
			Statement st = result.next();
			IRI subject = (IRI) st.getSubject();
			Assert.assertEquals(subject, john);
			IRI predicate = st.getPredicate();
			Assert.assertEquals(predicate, expectedPredicateresult[i]);
			Value object = st.getObject();
			Assert.assertEquals(object, expectedObjectresult[i]);
			i++;
		}
	} finally {
		result.close();
	}
}
 
开发者ID:marklogic,项目:marklogic-rdf4j,完整代码来源:MarkLogicRepositoryConnectionTest.java



注:本文示例均筛选自Github平台上各路大神开发的开源项目,代码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。