當前位置: 首頁>>代碼示例>>Java>>正文


Java ResultSet.hasNext方法代碼示例

本文整理匯總了Java中com.hp.hpl.jena.query.ResultSet.hasNext方法的典型用法代碼示例。如果您正苦於以下問題:Java ResultSet.hasNext方法的具體用法?Java ResultSet.hasNext怎麽用?Java ResultSet.hasNext使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.hp.hpl.jena.query.ResultSet的用法示例。


在下文中一共展示了ResultSet.hasNext方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getAgentUri

import com.hp.hpl.jena.query.ResultSet; //導入方法依賴的package包/類
public Resource getAgentUri(VirtGraph graphOrgs, String vatId) {
	
	Resource agentUri = null;
	
	String queryUri = "PREFIX gr: <http://purl.org/goodrelations/v1#> " +
				"SELECT ?org ?vatId " +
				"FROM <" + QueryConfiguration.queryGraphOrganizations + "> " +
				"WHERE { " +
				"?org gr:vatID ?vatId . " +
				"FILTER ( ?vatId = \"" + vatId + "\"^^<http://www.w3.org/2001/XMLSchema#string> ) " +
				"}";

	VirtuosoQueryExecution vqeUri = VirtuosoQueryExecutionFactory.create(queryUri, graphOrgs);		
	ResultSet resultsUri = vqeUri.execSelect();
	
	if (resultsUri.hasNext()) {
		QuerySolution result = resultsUri.nextSolution();
		agentUri = result.getResource("org");
	}
	
	vqeUri.close();
	
	return agentUri;
}
 
開發者ID:YourDataStories,項目名稱:harvesters,代碼行數:25,代碼來源:Queries.java

示例2: getAllTestLists

import com.hp.hpl.jena.query.ResultSet; //導入方法依賴的package包/類
@Parameters(name="{index}: {0}")
public static Collection<Object[]> getAllTestLists() {
	Collection<Object[]> results = new ArrayList<Object[]>();
	for (File dir: new File(TEST_SUITE_DIR).listFiles()) {
		if (!dir.isDirectory() || !new File(dir.getAbsolutePath() + "/manifest.ttl").exists()) continue;
		String absolutePath = dir.getAbsolutePath();
		Model model = FileManager.get().loadModel(absolutePath + "/manifest.ttl");
		ResultSet resultSet = QueryExecutionFactory.create(QUERY, model).execSelect();
		while (resultSet.hasNext()) {
			QuerySolution solution = resultSet.nextSolution();
			if (Arrays.asList(D2RQTestUtil.SKIPPED_R2RML_TESTS).contains(solution.getResource("s").getLocalName())) continue;
			results.add(new Object[]{
					PrettyPrinter.toString(solution.getResource("s")),
					absolutePath + "/create.sql",
					absolutePath + "/" + solution.getLiteral("rml").getLexicalForm(),
					(solution.get("nquad") == null) ? 
							null : 
							absolutePath + "/" + solution.getLiteral("nquad").getLexicalForm()
			});
		}
	}
	return results;
}
 
開發者ID:d2rq,項目名稱:r2rml-kit,代碼行數:24,代碼來源:R2RMLTest.java

示例3: getAgentUriNoVat

import com.hp.hpl.jena.query.ResultSet; //導入方法依賴的package包/類
public Resource getAgentUriNoVat(VirtGraph graphOrgs, String vatId) {
	
	Resource agentUri = null;
	
	String queryUri = "PREFIX gr: <http://purl.org/goodrelations/v1#> " +
				"SELECT DISTINCT ?org " +
				"FROM <" + QueryConfiguration.queryGraphOrganizations + "> " +
				"WHERE { " +
				"?org rdf:type foaf:Organization . " +
				"FILTER (STR(?org) = \"http://linkedeconomy.org/resource/Organization/" + vatId + "\") . " +
				"}";

	VirtuosoQueryExecution vqeUri = VirtuosoQueryExecutionFactory.create(queryUri, graphOrgs);		
	ResultSet resultsUri = vqeUri.execSelect();
	
	if (resultsUri.hasNext()) {
		QuerySolution result = resultsUri.nextSolution();
		agentUri = result.getResource("org");
	}
	
	vqeUri.close();
	
	return agentUri;
}
 
開發者ID:YourDataStories,項目名稱:harvesters,代碼行數:25,代碼來源:Queries.java

示例4: testBulkLoad

import com.hp.hpl.jena.query.ResultSet; //導入方法依賴的package包/類
@Test
public void testBulkLoad() throws URISyntaxException, IOException, OperationNotSupportedException {
	URL[] files = new URL[1];
	URL url = TDBTest.class.getResource("/org/aksw/kbox/kibe/dbpedia_3.9.xml");
	files[0] = url;
	java.nio.file.Path f = Files.createTempDirectory("kb");
	String path = f.toFile().getPath();
	TDB.bulkload(f.toFile().getPath(), files);
	Date start = new Date();
	ResultSet rs = TDB.query("Select ?p where {<http://dbpedia.org/ontology/Place> ?p ?o}", path);
	int i = 0;
	Date end = new Date();
	System.out.println(end.getTime() - start.getTime());
	while (rs != null && rs.hasNext()) {
		rs.next();
		i++;
	}
	assertEquals(19, i);
}
 
開發者ID:AKSW,項目名稱:KBox,代碼行數:20,代碼來源:TDBTest.java

示例5: testQueryInstalledKB

import com.hp.hpl.jena.query.ResultSet; //導入方法依賴的package包/類
@Test
public void testQueryInstalledKB() throws Exception {
	ResultSet rs = KBox.query("Select ?p where {<http://dbpedia.org/ontology/Place> ?p ?o}",
			new URL("http://dbpedia39"));
	int i = 0;
	while (rs != null && rs.hasNext()) {
		rs.next();
		i++;
	}
	assertEquals(19, i);
	
	rs = KBox.query( 
			"Select ?p where {<http://dbpedia.org/ontology/Place> ?p ?o}",
			new URL("http://dbpedia39"));
	i = 0;
	while (rs != null && rs.hasNext()) {
	rs.next();
	i++;
	}
	assertEquals(19, i);
}
 
開發者ID:AKSW,項目名稱:KBox,代碼行數:22,代碼來源:KBoxTest.java

示例6: main

import com.hp.hpl.jena.query.ResultSet; //導入方法依賴的package包/類
public static void main(String[] args) {
	ModelD2RQ m = new ModelD2RQ("file:doc/example/mapping-iswc.ttl");
	String sparql = 
		"PREFIX dc: <http://purl.org/dc/elements/1.1/>" +
		"PREFIX foaf: <http://xmlns.com/foaf/0.1/>" +
		"SELECT ?paperTitle ?authorName WHERE {" +
		"    ?paper dc:title ?paperTitle . " +
		"    ?paper dc:creator ?author ." +
		"    ?author foaf:name ?authorName ." +
		"}";
	Query q = QueryFactory.create(sparql); 
	ResultSet rs = QueryExecutionFactory.create(q, m).execSelect();
	while (rs.hasNext()) {
		QuerySolution row = rs.nextSolution();
		System.out.println("Title: " + row.getLiteral("paperTitle").getString());
		System.out.println("Author: " + row.getLiteral("authorName").getString());
	}
	m.close();
}
 
開發者ID:aitoralmeida,項目名稱:c4a_data_repository,代碼行數:20,代碼來源:SPARQLExample.java

示例7: getTestListFromManifest

import com.hp.hpl.jena.query.ResultSet; //導入方法依賴的package包/類
public static Collection<Object[]> getTestListFromManifest(String manifestFileURL) {
		// We'd like to use FileManager.loadModel() but it doesn't work on jar: URLs
//		Model m = FileManager.get().loadModel(manifestFileURL);
		Model m = ModelFactory.createDefaultModel();
		m.read(manifestFileURL, "TURTLE");

		IRI baseIRI = D2RQTestUtil.createIRI(m.getNsPrefixURI("base"));
		ResultSet rs = QueryExecutionFactory.create(TEST_CASE_LIST, m).execSelect();
		List<Object[]> result = new ArrayList<Object[]>();
		while (rs.hasNext()) {
			QuerySolution qs = rs.next();
			Resource mapping = qs.getResource("mapping");
			Resource schema = qs.getResource("schema");
//			if (!mapping.getLocalName().equals("constant-object.ttl")) continue;
			QueryExecution qe = QueryExecutionFactory.create(TEST_CASE_TRIPLES, m);
			qe.setInitialBinding(qs);
			Model expectedTriples = qe.execConstruct();
			result.add(new Object[]{baseIRI.relativize(mapping.getURI()).toString(), mapping.getURI(), 
					schema.getURI(), expectedTriples});
		}
		return result;
	}
 
開發者ID:d2rq,項目名稱:r2rml-kit,代碼行數:23,代碼來源:ProcessorTestBase.java

示例8: checkRedirects

import com.hp.hpl.jena.query.ResultSet; //導入方法依賴的package包/類
private String checkRedirects(String resource) {
	String result = resource;
	try {

		Query query = QueryFactory
				.create("SELECT ?redirect WHERE{ <"
						+ resource
						+ "> <http://dbpedia.org/ontology/wikiPageRedirects> ?redirect. }");
		QueryExecution qe = QueryExecutionFactory.create(query, this.m);
		ResultSet results = qe.execSelect();
		while (results.hasNext()) {
			QuerySolution sol = results.nextSolution();
			result = sol.getResource("redirect").getURI();
		}
	} catch (Exception e) {
		return resource;
	}
	return result;
}
 
開發者ID:quhfus,項目名稱:DoSeR,代碼行數:20,代碼來源:LimayeAnnotationParserWebTables.java

示例9: queryEntitiesFromCategory

import com.hp.hpl.jena.query.ResultSet; //導入方法依賴的package包/類
private String queryEntitiesFromCategory(final String catUri) {
	String res = null;

	final String query = "SELECT ?entities WHERE{ ?entities <http://purl.org/dc/terms/subject> <"
			+ catUri + ">. }";
	try {
		final com.hp.hpl.jena.query.Query cquery = QueryFactory
				.create(query);
		final QueryExecution qexec = QueryExecutionFactory
				.create(cquery, m);
		final ResultSet results = qexec.execSelect();
		List<String> entities = new LinkedList<String>();
		while (results.hasNext()) {
			final QuerySolution sol = results.nextSolution();
			entities.add(sol.getResource("entities").getURI());
		}
		if (entities.size() != 0) {
			int randomNr = this.random.nextInt(entities.size());
			return entities.get(randomNr);
		}

	} catch (final QueryException e) {
		Logger.getRootLogger().error(e.getStackTrace());
	}
	return res;
}
 
開發者ID:quhfus,項目名稱:DoSeR,代碼行數:27,代碼來源:EvaluatePureDbpediaCategories.java

示例10: execQuery

import com.hp.hpl.jena.query.ResultSet; //導入方法依賴的package包/類
private String[] execQuery(String query, Processor processor)
{
	QueryEngineHTTP endpoint = new QueryEngineHTTP(_sparql, query);
	try {
		ResultSet rs = endpoint.execSelect();
		if ( !rs.hasNext() ) { return EMPTY; }

		List<String> l = new ArrayList<String>();
        while (rs.hasNext())
        {
            String uri = processor.process(rs.next().get("x"));
            if ( uri != null ) { l.add(uri); }
        }
        return ( l.size() == 0 ? EMPTY : l.toArray(EMPTY) );
	}
	catch (Throwable t) {
		t.printStackTrace();
	}
	finally {
		endpoint.close();
	}
	return EMPTY;
}
 
開發者ID:hugomanguinhas,項目名稱:europeana,代碼行數:24,代碼來源:WikidataCoReferenceResolver.java

示例11: testMetric_TotalExecutions_PerBuild

import com.hp.hpl.jena.query.ResultSet; //導入方法依賴的package包/類
@Test
public void testMetric_TotalExecutions_PerBuild() {
	Query query =
		QueryFactory.
			create(
				loadResource("/metrics/total_executions_per_build.sparql"));
	QueryExecution queryExecution = null;
	try {
		queryExecution = QueryExecutionFactory.create(query, executionsDataSet());
		ResultSet results = queryExecution.execSelect();
		for(; results.hasNext();) {
			QuerySolution solution = results.nextSolution();
			long total_executions = solution.getLiteral("total_executions").getLong();
			String buildId = shorten(solution.getResource("build").getURI());
			System.out.printf("Total executions of build %s: %d%n",buildId,total_executions);
		}
	} finally {
		if (queryExecution != null) {
			queryExecution.close();
		}
	}
}
 
開發者ID:SmartDeveloperHub,項目名稱:sdh-vocabulary,代碼行數:23,代碼來源:VocabularyTest.java

示例12: testMetric_TotalSuccesfulExecutions_Global

import com.hp.hpl.jena.query.ResultSet; //導入方法依賴的package包/類
@Test
public void testMetric_TotalSuccesfulExecutions_Global() {
	Query query =
		QueryFactory.
			create(
				loadResource("/metrics/total_succesful_executions_global.sparql"));
	QueryExecution queryExecution = null;
	try {
		queryExecution = QueryExecutionFactory.create(query, executionsDataSet());
		ResultSet results = queryExecution.execSelect();
		for(; results.hasNext();) {
			QuerySolution solution = results.nextSolution();
			long total_executions = solution.getLiteral("total_executions").getLong();
			System.out.printf("Total succesful executions: %d%n",total_executions);
		}
	} finally {
		if (queryExecution != null) {
			queryExecution.close();
		}
	}
}
 
開發者ID:SmartDeveloperHub,項目名稱:sdh-vocabulary,代碼行數:22,代碼來源:VocabularyTest.java

示例13: testMetric_TotalSuccesfulExecutions_Global_Period

import com.hp.hpl.jena.query.ResultSet; //導入方法依賴的package包/類
@Test
public void testMetric_TotalSuccesfulExecutions_Global_Period() {
	Query query =
		QueryFactory.
			create(
				loadResource("/metrics/total_succesful_executions_global_period.sparql"));
	QueryExecution queryExecution = null;
	try {
		queryExecution = QueryExecutionFactory.create(query, executionsDataSet());
		ResultSet results = queryExecution.execSelect();
		for(; results.hasNext();) {
			QuerySolution solution = results.nextSolution();
			long total_executions = solution.getLiteral("total_executions").getLong();
			String day = solution.getLiteral("day").getString();
			System.out.printf("Total succesful executions [%s]: %d%n",day,total_executions);
		}
	} finally {
		if (queryExecution != null) {
			queryExecution.close();
		}
	}
}
 
開發者ID:SmartDeveloperHub,項目名稱:sdh-vocabulary,代碼行數:23,代碼來源:VocabularyTest.java

示例14: hasSubCategory

import com.hp.hpl.jena.query.ResultSet; //導入方法依賴的package包/類
private boolean hasSubCategory(String uri) {
	final String query = "SELECT ?entities WHERE{ ?types <http://www.w3.org/2004/02/skos/core#broader> <"
			+ uri + ">. }";
	boolean hasSubtype = false;
	try {
		final com.hp.hpl.jena.query.Query cquery = QueryFactory
				.create(query);
		final QueryExecution qexec = QueryExecutionFactory
				.create(cquery, skosModel);
		final ResultSet results = qexec.execSelect();
		while (results.hasNext()) {
			hasSubtype = true;
			break;
		}

	} catch (final QueryException e) {
		Logger.getRootLogger().error(e.getStackTrace());
	}
	return hasSubtype;
}
 
開發者ID:quhfus,項目名稱:DoSeR,代碼行數:21,代碼來源:DbpediaGraphModification.java

示例15: testMetric_TotalBrokenExecutions_Global

import com.hp.hpl.jena.query.ResultSet; //導入方法依賴的package包/類
@Test
public void testMetric_TotalBrokenExecutions_Global() {
	Query query =
		QueryFactory.
			create(
				loadResource("/metrics/total_broken_executions_global.sparql"));
	QueryExecution queryExecution = null;
	try {
		queryExecution = QueryExecutionFactory.create(query, executionsDataSet());
		ResultSet results = queryExecution.execSelect();
		for(; results.hasNext();) {
			QuerySolution solution = results.nextSolution();
			long total_executions = solution.getLiteral("total_executions").getLong();
			System.out.printf("Total broken executions: %d%n",total_executions);
		}
	} finally {
		if (queryExecution != null) {
			queryExecution.close();
		}
	}
}
 
開發者ID:SmartDeveloperHub,項目名稱:sdh-vocabulary,代碼行數:22,代碼來源:VocabularyTest.java


注:本文中的com.hp.hpl.jena.query.ResultSet.hasNext方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。