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


Java BindingSet.iterator方法代碼示例

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


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

示例1: testSesameQueryHandler

import org.openrdf.query.BindingSet; //導入方法依賴的package包/類
@Test
@FileParameters("src/test/resources/SesameQueryHandlerTest.csv")
public void testSesameQueryHandler(
		String query,
		@ConvertParam(value = ParamsConverterTest.StringToStatementsConverter.class) Set<Statement> statements,
		@ConvertParam(value = ParamsConverterTest.StringToBindingMapSet.class) Set<Map<String, String>> e,
		String assertType) throws MalformedQueryException {
	SPARQLParser p = new SPARQLParser();
	ParsedQuery q = p.parseQuery(query, null);

	SesameQueryHandler h = new SesameQueryHandler(new ThisQueryHandler(statements), q);
	ResultSet<BindingSet> r = h.evaluate();
	
	Set<Map<String, String>> a = new HashSet<Map<String, String>>();
	
	while (r.hasNext()) {
		BindingSet bs = r.next();
		Map<String, String> m = new HashMap<String, String>();
		a.add(m);
		
		Iterator<Binding> it = bs.iterator();
		
		while (it.hasNext()) {
			Binding b = it.next();
			
			m.put(b.getName(), b.getValue().stringValue());
		}
	}
	
	if (assertType.equals("assertEquals")) {
		assertTrue(CollectionUtils.isEqualCollection(e, a));
		return;
	}

	assertFalse(CollectionUtils.isEqualCollection(e, a));
}
 
開發者ID:markusstocker,項目名稱:emrooz,代碼行數:37,代碼來源:SesameQueryHandlerTest.java

示例2: testEmrooz

import org.openrdf.query.BindingSet; //導入方法依賴的package包/類
@Test
@FileParameters("src/test/resources/EmroozTest.csv")
public void testEmrooz(
		String kb,
		@ConvertParam(value = ParamsConverterTest.StringToURIConverter.class) URI specificationId,
		@ConvertParam(value = ParamsConverterTest.StringToStatementsConverter.class) Set<Statement> statements,
		String query,
		@ConvertParam(value = ParamsConverterTest.StringToBindingMapSet.class) Set<Map<String, String>> e,
		String assertType) {
	Emrooz em = new Emrooz(new SesameKnowledgeStore(new SailRepository(
			new MemoryStore())), new ThisDataStore());
	em.loadKnowledgeBase(new File(kb));
	em.addSensorObservations(statements);
	ResultSet<BindingSet> rs = em.evaluate(QueryType.SENSOR_OBSERVATION,
			query);

	Set<Map<String, String>> a = new HashSet<Map<String, String>>();

	while (rs.hasNext()) {
		BindingSet bs = rs.next();

		Map<String, String> m = new HashMap<String, String>();
		a.add(m);

		Iterator<Binding> it = bs.iterator();

		while (it.hasNext()) {
			Binding b = it.next();
			m.put(b.getName(), b.getValue().stringValue());
		}
	}

	if (assertType.equals("assertEquals")) {
		assertTrue(CollectionUtils.isEqualCollection(e, a));
		return;
	}

	assertFalse(CollectionUtils.isEqualCollection(e, a));

	em.close();
}
 
開發者ID:markusstocker,項目名稱:emrooz,代碼行數:42,代碼來源:EmroozTest.java

示例3: queryOrderAscTest

import org.openrdf.query.BindingSet; //導入方法依賴的package包/類
@Test
public void queryOrderAscTest() throws RepositoryException, MalformedQueryException, QueryEvaluationException {
	Iterator<String> iter = _orderByAscQueries.iterator();

	while (iter.hasNext()) {
		String query = iter.next();

		TupleQuery cq = CUMULUS_CONNECTION.prepareTupleQuery(QueryLanguage.SPARQL, query);
		TupleQueryResult cRes = cq.evaluate();
		String last = null;
		String current = null;
		while (cRes.hasNext()) {
			BindingSet bs = cRes.next();
			Iterator<Binding> bindings = bs.iterator();
			while (bindings.hasNext()) {
				Binding b = bindings.next();
				Value v = b.getValue();
				if (v instanceof Literal) {
					current = v.stringValue();
					try {
						double currDouble = Double.parseDouble(current);
						double lastDouble;
						if (last == null) {
							lastDouble = -Double.MAX_VALUE;
						} else {
							lastDouble = Double.parseDouble(last);
						}
						assertTrue(currDouble >= lastDouble);
						last = current;
					} catch (NumberFormatException ne) {
						if (last == null) {
							last = "";
						}
						assertTrue(last.compareTo(current) <= 0);
						last = current;
					}
				}
			}
		}
	}
}
 
開發者ID:cumulusrdf,項目名稱:cumulusrdf,代碼行數:42,代碼來源:RangeQueryOptimizationTest.java

示例4: queryOrderDescTest

import org.openrdf.query.BindingSet; //導入方法依賴的package包/類
@Test
public void queryOrderDescTest() throws RepositoryException, MalformedQueryException, QueryEvaluationException {
	Iterator<String> iter = _orderByDescQueries.iterator();

	while (iter.hasNext()) {
		String query = iter.next();

		TupleQuery cq = CUMULUS_CONNECTION.prepareTupleQuery(QueryLanguage.SPARQL, query);
		TupleQueryResult cRes = cq.evaluate();
		String last = null;
		String current = null;
		while (cRes.hasNext()) {
			BindingSet bs = cRes.next();
			Iterator<Binding> bindings = bs.iterator();
			while (bindings.hasNext()) {
				Binding b = bindings.next();
				Value v = b.getValue();
				if (v instanceof Literal) {
					current = v.stringValue();
					try {
						double currDouble = Double.parseDouble(current);
						double lastDouble;
						if (last == null) {
							lastDouble = Double.MAX_VALUE;
						} else {
							lastDouble = Double.parseDouble(last);
						}
						assertTrue(currDouble <= lastDouble);
						last = current;
					} catch (NumberFormatException ne) {
						if (last == null) {
							last = "_";
						}
						assertTrue(last.compareTo(current) >= 0);
						last = current;
					}
				}
			}
		}
	}
}
 
開發者ID:cumulusrdf,項目名稱:cumulusrdf,代碼行數:42,代碼來源:RangeQueryOptimizationTest.java


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