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


Java RepositoryResult.hasNext方法代码示例

本文整理汇总了Java中org.openrdf.repository.RepositoryResult.hasNext方法的典型用法代码示例。如果您正苦于以下问题:Java RepositoryResult.hasNext方法的具体用法?Java RepositoryResult.hasNext怎么用?Java RepositoryResult.hasNext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.openrdf.repository.RepositoryResult的用法示例。


在下文中一共展示了RepositoryResult.hasNext方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: tuplePattern

import org.openrdf.repository.RepositoryResult; //导入方法依赖的package包/类
/**
 * Tuple pattern query - find all statements with the pattern, where null is
 * a wild card
 * 
 * @param s
 *            subject (null for wildcard)
 * @param p
 *            predicate (null for wildcard)
 * @param o
 *            object (null for wildcard)
 * @return serialized graph of results
 */
public List tuplePattern(URI s, URI p, Value o) {
	try {
		RepositoryConnection con = therepository.getConnection();
		try {
			RepositoryResult repres = con.getStatements(s, p, o, true, new Resource[0]);
			ArrayList reslist = new ArrayList();
			while (repres.hasNext()) {
				reslist.add(repres.next());
			}
			return reslist;
		} finally {
			con.close();
		}
	} catch (Exception e) {
		e.printStackTrace();
	}
	return null;
}
 
开发者ID:dvcama,项目名称:resource-to-sparqlresult,代码行数:31,代码来源:SimpleGraph.java

示例2: extractAllStatements

import org.openrdf.repository.RepositoryResult; //导入方法依赖的package包/类
@Override
public LinkedList<Statement> extractAllStatements(Repository repo, int nrTriples) {
	RepositoryConnection con = repo.getConnection();
	
	RepositoryResult<Statement> triples = con.getStatements(null, null,
			null, false);

	LinkedList<Statement> statements = new LinkedList<Statement>();
	try {
		System.out.println("triples to extract: "+nrTriples);
		if(nrTriples == -1)
			Iterations.addAll(triples, statements);
		else {
			int count = 0;
			while(triples.hasNext() && count < nrTriples){
				statements.add(triples.next());
				count++;
			}
		}
	} finally {
		triples.close();
		con.close();
	}
	return statements;
}
 
开发者ID:simonstey,项目名称:SecureLinkedData,代码行数:26,代码来源:Storage.java

示例3: testMMRTS152

import org.openrdf.repository.RepositoryResult; //导入方法依赖的package包/类
public void testMMRTS152() throws Exception {
        RepositoryConnection conn = repository.getConnection();
        URI loadPerc = vf.createURI(litdupsNS, "testPred");
        URI uri1 = vf.createURI(litdupsNS, "uri1");
        conn.add(cpu, loadPerc, uri1);
        conn.commit();

        RepositoryResult<Statement> result = conn.getStatements(cpu, loadPerc, null, false, new Resource[0]);
//        RdfCloudTripleStoreCollectionStatementsIterator iterator = new RdfCloudTripleStoreCollectionStatementsIterator(
//                cpu, loadPerc, null, store.connector,
//                vf, new Configuration(), null);

        while (result.hasNext()) {
            assertTrue(result.hasNext());
            assertNotNull(result.next());
        }

        conn.close();
    }
 
开发者ID:apache,项目名称:incubator-rya,代码行数:20,代码来源:RdfCloudTripleStoreConnectionTest.java

示例4: testDuplicateLiterals

import org.openrdf.repository.RepositoryResult; //导入方法依赖的package包/类
public void testDuplicateLiterals() throws Exception {
    RepositoryConnection conn = repository.getConnection();

    URI loadPerc = vf.createURI(litdupsNS, "loadPerc");
    Literal lit1 = vf.createLiteral(0.0);
    Literal lit2 = vf.createLiteral(0.0);
    Literal lit3 = vf.createLiteral(0.0);

    conn.add(cpu, loadPerc, lit1);
    conn.add(cpu, loadPerc, lit2);
    conn.add(cpu, loadPerc, lit3);
    conn.commit();

    RepositoryResult<Statement> result = conn.getStatements(cpu, loadPerc, null, true, new Resource[0]);
    int count = 0;
    while (result.hasNext()) {
        count++;
        result.next();
    }
    result.close();
    assertEquals(1, count);

    //clean up
    conn.remove(cpu, loadPerc, lit1);
    conn.close();
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:27,代码来源:RdfCloudTripleStoreConnectionTest.java

示例5: getNamespaces

import org.openrdf.repository.RepositoryResult; //导入方法依赖的package包/类
@Override
public Map<String,String> getNamespaces() {
	this.assertModel();
	Map<String,String> nsMap = new HashMap<String,String>();
	try {
		RepositoryResult<Namespace> openrdfMap = this.connection.getNamespaces();
		openrdfMap.enableDuplicateFilter();
		while (openrdfMap.hasNext()) {
			Namespace openrdfNamespace = openrdfMap.next();
			nsMap.put(openrdfNamespace.getPrefix(), openrdfNamespace.getName());
		}
		return nsMap;
	} catch(RepositoryException e) {
		throw new ModelRuntimeException(e);
	}
}
 
开发者ID:semweb4j,项目名称:semweb4j,代码行数:17,代码来源:RepositoryModelSet.java

示例6: testNamedGraphLoad2

import org.openrdf.repository.RepositoryResult; //导入方法依赖的package包/类
public void testNamedGraphLoad2() throws Exception {
    InputStream stream = Thread.currentThread().getContextClassLoader().getResourceAsStream("namedgraphs.trig");
    assertNotNull(stream);
    RepositoryConnection conn = repository.getConnection();
    conn.add(stream, "", RDFFormat.TRIG);
    conn.commit();

    RepositoryResult<Statement> statements = conn.getStatements(null, vf.createURI("http://www.example.org/vocabulary#name"), null, true, vf.createURI("http://www.example.org/exampleDocument#G1"));
    int count = 0;
    while (statements.hasNext()) {
        statements.next();
        count++;
    }
    statements.close();
    assertEquals(1, count);

    conn.close();
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:19,代码来源:RdfCloudTripleStoreConnectionTest.java

示例7: testGetNamespaces

import org.openrdf.repository.RepositoryResult; //导入方法依赖的package包/类
public void testGetNamespaces() throws Exception {
    String namespace = "urn:testNamespace#";
    String prefix = "pfx";
    connection.setNamespace(prefix, namespace);

    namespace = "urn:testNamespace2#";
    prefix = "pfx2";
    connection.setNamespace(prefix, namespace);

    RepositoryResult<Namespace> result = connection.getNamespaces();
    int count = 0;
    while (result.hasNext()) {
        result.next();
        count++;
    }

    assertEquals(2, count);
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:19,代码来源:RdfCloudTripleStoreTest.java

示例8: getStoredModelIds

import org.openrdf.repository.RepositoryResult; //导入方法依赖的package包/类
/**
 * Retrieve a collection of all file/stored model ids found in the repo.<br>
 * Note: Models may not be loaded at this point.
 * 
 * @return set of modelids.
 * @throws IOException
 */
public Set<IRI> getStoredModelIds() throws IOException {
	try {
		BigdataSailRepositoryConnection connection = repo.getReadOnlyConnection();
		try {
			RepositoryResult<Resource> graphs = connection.getContextIDs();
			Set<IRI> modelIds = new HashSet<>();
			while (graphs.hasNext()) {
				modelIds.add(IRI.create(graphs.next().stringValue()));
			}
			graphs.close();
			return Collections.unmodifiableSet(modelIds);
		} finally {
			connection.close();
		}	
	} catch (RepositoryException e) {
		throw new IOException(e);
	}		
}
 
开发者ID:geneontology,项目名称:minerva,代码行数:26,代码来源:BlazegraphMolecularModelManager.java

示例9: getTypes

import org.openrdf.repository.RepositoryResult; //导入方法依赖的package包/类
public Set<URI> getTypes(Resource res) throws RepositoryException {
	if (!readTypes)
		return Collections.emptySet();
	RepositoryResult<Statement> match = conn.getStatements(res, RDF.TYPE, null);
	try {
		if (!match.hasNext())
			return Collections.emptySet();
		Value obj = match.next().getObject();
		if (obj instanceof URI && !match.hasNext())
			return Collections.singleton((URI) obj);
		Set<URI> types = new HashSet<URI>(4);
		if (obj instanceof URI) {
			types.add((URI) obj);
		}
		while (match.hasNext()) {
			obj = match.next().getObject();
			if (obj instanceof URI) {
				types.add((URI) obj);
			}
		}
		return types;
	} finally {
		match.close();
	}
}
 
开发者ID:anno4j,项目名称:anno4j,代码行数:26,代码来源:TypeManager.java

示例10: getSize

import org.openrdf.repository.RepositoryResult; //导入方法依赖的package包/类
private int getSize(Repository repository) throws RepositoryException {
	int size = 0;
	RepositoryConnection connection = null;
	RepositoryResult<Statement> iter = null;
	try {
		connection = repository.getConnection();
		iter = connection.getStatements(null, null, null, false);
		while (iter.hasNext()) {
			iter.next();
			++size;
		}
	} finally {
		if (iter != null)
			iter.close();
		if (connection != null)
			connection.close();
	}
	return size;
}
 
开发者ID:anno4j,项目名称:anno4j,代码行数:20,代码来源:ListTest.java

示例11: test_naive

import org.openrdf.repository.RepositoryResult; //导入方法依赖的package包/类
public void test_naive() throws Exception {
	ValueFactory vf = con.getValueFactory();
	final URI Bean = vf.createURI(NS, "Bean");
	final URI name = vf.createURI(NS, "name");
	final URI parent = vf.createURI(NS, "parent");
	final URI friend = vf.createURI(NS, "friend");
	long start = System.currentTimeMillis();
	RepositoryResult<Statement> beans = con.getStatements(null, RDF.TYPE, Bean);
	while (beans.hasNext()) {
		Statement st = beans.next();
		Resource bean = st.getSubject();
		QueryResults.asList(con.getStatements(bean, name, null));
		RepositoryResult<Statement> match;
		match = con.getStatements(bean, parent, null);
		while (match.hasNext()) {
			QueryResults.asList(con.getStatements((Resource)match.next().getObject(), name, null));
		}
		match = con.getStatements(bean, friend, null);
		while (match.hasNext()) {
			QueryResults.asList(con.getStatements((Resource)match.next().getObject(), name, null));
		}
	}
	long end = System.currentTimeMillis();
	System.out.println((end - start) / 1000.0);
}
 
开发者ID:anno4j,项目名称:anno4j,代码行数:26,代码来源:AugurTest.java

示例12: loadHistory

import org.openrdf.repository.RepositoryResult; //导入方法依赖的package包/类
@Override
	public JSONArray loadHistory(String filename) throws Exception {
		File file = new File(filename);
//		String encoding = EncodingDetector.detect(file);
//		String contents = EncodingDetector.getString(file, encoding);
		
		SailRepository myRepository = new SailRepository(new MemoryStore());
		myRepository.initialize();
		SailRepositoryConnection con = myRepository.getConnection();
		con.add(file, "", RDFFormat.TURTLE);
		
		RepositoryResult<Statement> result = con.getStatements(null, new URIImpl("http://isi.edu/integration/karma/dev#hasWorksheetHistory"), null, false);
		if(result.hasNext()) {
			Statement stmt = result.next();
			String history = stmt.getObject().stringValue();
			return new JSONArray(history);
		}
		return new JSONArray();
	}
 
开发者ID:therelaxist,项目名称:spring-usc,代码行数:20,代码来源:R2RMLAlignmentFileSaver.java

示例13: toResultIterator

import org.openrdf.repository.RepositoryResult; //导入方法依赖的package包/类
public static <T> Iterator<T> toResultIterator (final RepositoryResult<T> result) {
	
	return new AbstractIterator<T>() {

		@Override
		protected T computeNext() {
			
			try {
				
				if(result.hasNext()) {
					return result.next();
				}
				
			} catch (RepositoryException e) {
				LOGGER.error(MessageCatalog._00025_CUMULUS_SYSTEM_INTERNAL_FAILURE_MSG + " Could not compute next result.", e);
			}
			return endOfData();
		}
	};
}
 
开发者ID:cumulusrdf,项目名称:cumulusrdf,代码行数:21,代码来源:Util.java

示例14: activate

import org.openrdf.repository.RepositoryResult; //导入方法依赖的package包/类
@Override
public void activate(final Collection<SesameSwitchSetMatch> matches) throws RepositoryException {
	final RepositoryConnection con = driver.getConnection();
	final ValueFactory vf = driver.getValueFactory();

	final URI currentPositionProperty = vf.createURI(BASE_PREFIX + CURRENTPOSITION);

	for (final SesameSwitchSetMatch match : matches) {
		final Resource sw = match.getSw();
		final Value position = match.getPosition();
		final Value currentPosition = match.getCurrentPosition();

		final RepositoryResult<Statement> statementsToRemove = con.getStatements(sw, currentPositionProperty, currentPosition, false);
		while (statementsToRemove.hasNext()) {
			con.remove(statementsToRemove.next());
		}

		con.add(sw, currentPositionProperty, position);
	}
}
 
开发者ID:FTSRG,项目名称:trainbenchmark,代码行数:21,代码来源:SesameTransformationRepairSwitchSet.java

示例15: activate

import org.openrdf.repository.RepositoryResult; //导入方法依赖的package包/类
@Override
public void activate(final Collection<SesameConnectedSegmentsMatch> matches) throws RepositoryException {
	final RepositoryConnection con = driver.getConnection();
	final ValueFactory vf = driver.getValueFactory();

	final URI connectsTo = vf.createURI(BASE_PREFIX + CONNECTS_TO);
	for (final SesameConnectedSegmentsMatch match : matches) {
		// delete segment2 by removing all (segment2, _, _) and (_, _, segment2) triples
		final RepositoryResult<Statement> outgoingEdges = con.getStatements(match.getSegment2(), null, null, true);
		while (outgoingEdges.hasNext()) {
			con.remove(outgoingEdges.next());
		}
		final RepositoryResult<Statement> incomingEdges = con.getStatements(null, null, match.getSegment2(), true);
		while (incomingEdges.hasNext()) {
			con.remove(incomingEdges.next());
		}

		// insert (segment1)-[:connectsTo]->(segment3) edge
		con.add(match.getSegment1(), connectsTo, match.getSegment3());
	}
}
 
开发者ID:FTSRG,项目名称:trainbenchmark,代码行数:22,代码来源:SesameTransformationRepairConnectedSegments.java


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