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


Java RepositoryResult.next方法代码示例

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


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

示例1: 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

示例2: testNotDuplicateUris

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

    URI loadPerc = vf.createURI(litdupsNS, "loadPerc");
    URI uri1 = vf.createURI(litdupsNS, "uri1");
    URI uri2 = vf.createURI(litdupsNS, "uri1");
    URI uri3 = vf.createURI(litdupsNS, "uri1");

    conn.add(cpu, loadPerc, uri1);
    conn.add(cpu, loadPerc, uri2);
    conn.add(cpu, loadPerc, uri3);
    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, uri1);
    conn.close();
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:27,代码来源:RdfCloudTripleStoreConnectionTest.java

示例3: 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

示例4: 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

示例5: testGetStatementsMalformedTypedLiteral

import org.openrdf.repository.RepositoryResult; //导入方法依赖的package包/类
@Test
public void testGetStatementsMalformedTypedLiteral()
	throws Exception
{

	testAdminCon.getParserConfig().addNonFatalError(BasicParserSettings.VERIFY_DATATYPE_VALUES);
	Literal invalidIntegerLiteral = vf.createLiteral("four", XMLSchema.INTEGER);
	try {
		testAdminCon.add(micah, homeTel, invalidIntegerLiteral, dirgraph);

		RepositoryResult<Statement> statements = testAdminCon.getStatements(micah, homeTel, null, true);

		assertNotNull(statements);
		assertTrue(statements.hasNext());
		Statement st = statements.next();
		assertTrue(st.getObject() instanceof Literal);
		assertTrue(st.getObject().equals(invalidIntegerLiteral));
	}
	catch (RepositoryException e) {
		// shouldn't happen
		fail(e.getMessage());
	}
}
 
开发者ID:marklogic,项目名称:marklogic-sesame,代码行数:24,代码来源:MarkLogicRepositoryConnectionTest.java

示例6: 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

示例7: 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

示例8: removeIndirectTriples

import org.openrdf.repository.RepositoryResult; //导入方法依赖的package包/类
/**Takes as input a set of triples and some important URIs and removes from the 
 * first set those triples that have one of the given URIS as their subject. 
 * If we imagine the given set of triples as a graph, this method will practically 
 * return a subgraph containing only the direct neighbours of the given URIs. 
 * 
 * @param nTriples a set of triples in NTriples format 
 * @param urisToKeep the URIs that will be used for determining which triples to keep (those appearing in subject, or object field)
 * @return a subgraph in the form of triples in NTriples format, containing only the direct neighbours of the given URIs. */
public static String removeIndirectTriples(String nTriples, List<String> urisToKeep){
    String triplesContext="http://triplesContext";
    String subTriplesContext="http://subgraphTriplesContext";
    Repository repository=new SailRepository(new ForwardChainingRDFSInferencer(new MemoryStore()));
    try{
        repository.initialize();
        RepositoryConnection repoConn=repository.getConnection();
        repoConn.add(new StringReader(nTriples), triplesContext, RDFFormat.NTRIPLES, repository.getValueFactory().createURI(triplesContext));
        RepositoryResult<Statement> results=repoConn.getStatements(null, null, null, false, repository.getValueFactory().createURI(triplesContext));
        while(results.hasNext()){
            Statement result=results.next();
            if(urisToKeep.contains(result.getSubject().stringValue()) || urisToKeep.contains(result.getObject().stringValue())){
                repoConn.add(result, repository.getValueFactory().createURI(subTriplesContext));
            }
        }
        ByteArrayOutputStream out=new ByteArrayOutputStream();
        RDFWriter writer=Rio.createWriter(RDFFormat.NTRIPLES, out);
        repoConn.export(writer, repository.getValueFactory().createURI(subTriplesContext));
        repoConn.close();
        return new String(out.toByteArray(),"UTF-8");
    }catch(RepositoryException | IOException | RDFParseException | RDFHandlerException ex) {
        logger.error("Cannot parse ntriples file - Return the original NTriples file",ex);
        return nTriples;
    }
}
 
开发者ID:isl,项目名称:LifeWatch_Greece,代码行数:34,代码来源:Utils.java

示例9: 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

示例10: activate

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

	final URI lengthProperty = vf.createURI(BASE_PREFIX + LENGTH);

	for (final SesamePosLengthMatch match : matches) {
		final Resource segment = match.getSegment();
		final Value length = match.getLength();

		final RepositoryResult<Statement> statementsToRemove = con.getStatements(segment, lengthProperty, length, true);
		while (statementsToRemove.hasNext()) {
			final Statement oldStatement = statementsToRemove.next();
			con.remove(oldStatement);
		}

		final Integer lengthInteger = new Integer(length.stringValue());
		final Integer newLengthInteger = -lengthInteger + 1;
		final Literal newLength = vf.createLiteral(newLengthInteger);
		final Statement newStatement = vf.createStatement(segment, lengthProperty, newLength);
		con.add(newStatement);
	}
}
 
开发者ID:FTSRG,项目名称:trainbenchmark,代码行数:25,代码来源:SesameTransformationRepairPosLength.java

示例11: 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

示例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: getStatementsSize

import org.openrdf.repository.RepositoryResult; //导入方法依赖的package包/类
/**
 * Counts all statements matching the pattern <code>(s p o)</code>.
 * 
 * @param s subject.
 * @param p predicate.
 * @param o object.
 * @return number of matches.
 * @throws RepositoryException
 */
protected int getStatementsSize(Resource s, org.openrdf.model.URI p, Value o) throws RepositoryException
{
	RepositoryResult<Statement> result = this.getStatements(s, p, o);
	int count = 0;
	try
	{
		while (result.hasNext())
		{
			result.next();
			count++;
		}
	} finally
	{
		result.close();
	}
	return count;
}
 
开发者ID:emir-munoz,项目名称:uraptor,代码行数:27,代码来源:HCardExtractor.java

示例14: delProperties

import org.openrdf.repository.RepositoryResult; //导入方法依赖的package包/类
private void delProperties(final FacadingPredicate predicate, final Locale loc) throws RepositoryException {
    for (String v : predicate.getProperties()) {
        final URI prop = connection.getValueFactory().createURI(v);

        if (!predicate.isInverse() && loc == null) {
            // remove all properties prop that have this subject;
            connection.remove(delegate, prop, null, context);
        } else if (predicate.isInverse() && loc == null) {
            // remove all properties prop that have this object;
            connection.remove((Resource) null, prop, delegate, context);
        } else if (!predicate.isInverse() && loc != null) {
            final RepositoryResult<Statement> statements = connection.getStatements(delegate, prop, null, false, context);
            try {
                while (statements.hasNext()) {
                    final Statement s = statements.next();
                    if (FacadingInvocationHelper.checkLocale(loc, s.getObject())) {
                        connection.remove(s);
                    }
                }
            } finally {
                statements.close();
            }
        } else if (predicate.isInverse() && loc != null) { throw new IllegalArgumentException("A combination of @RDFInverse and a Literal is not possible");
        }
    }
}
 
开发者ID:apache,项目名称:marmotta,代码行数:27,代码来源:FacadingInvocationHandler.java

示例15: queryOutgoingSingle

import org.openrdf.repository.RepositoryResult; //导入方法依赖的package包/类
/**
 * Return the single object of type C that is reachable from entity by rdf_property. Returns
 * null if there is no such object or if the type of the object does not match the type passed
 * as argument.
 * 
 */
private <C> C queryOutgoingSingle(Resource entity, String rdf_property, Class<C> returnType) throws RepositoryException {
    URI property = connection.getValueFactory().createURI(rdf_property);

    RepositoryResult<Statement> triples = connection.getStatements(entity, property, null, false);
    try {
        if (triples.hasNext()) {
            Statement triple = triples.next();

            Value object = triple.getObject();

            if (returnType.isInstance(object)) {
                return returnType.cast(object);
            } else {
                log.error("cannot cast retrieved object {} for property {} to return type {}", object, rdf_property, returnType);
                return null;
            }

        } else {
            return null;
        }
    } finally {
        triples.close();
    }

}
 
开发者ID:apache,项目名称:marmotta,代码行数:32,代码来源:FacadingInvocationHandler.java


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