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


Java RepositoryConnection.getStatements方法代碼示例

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


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

示例1: tuplePattern

import org.openrdf.repository.RepositoryConnection; //導入方法依賴的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.RepositoryConnection; //導入方法依賴的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: updateLastModifiedDate

import org.openrdf.repository.RepositoryConnection; //導入方法依賴的package包/類
public static void updateLastModifiedDate( RepositoryConnection rc,
		Resource baseuri ) {
	// updates the base uri's last modified key
	// 1) if we don't know it already, figure out what our base uri is
	// 2) remove any last modified value
	// 3) add the new last modified value

	ValueFactory vf = rc.getValueFactory();
	try {
		if ( null == baseuri ) {
			RepositoryResult<Statement> rr = rc.getStatements( null, RDF.TYPE,
					SEMTOOL.Database, false );
			List<Statement> stmts = Iterations.asList( rr );
			for ( Statement s : stmts ) {
				baseuri = s.getSubject();
			}
		}

		if ( null == baseuri ) {
			log.warn( "cannot update last modified date when no base uri is set" );
		}
		else {
			rc.remove( baseuri, MetadataConstants.DCT_MODIFIED, null );

			rc.add( new StatementImpl( baseuri, MetadataConstants.DCT_MODIFIED,
					vf.createLiteral( QueryExecutorAdapter.getCal( new Date() ) ) ) );
		}
	}
	catch ( RepositoryException e ) {
		log.warn( "could not update last modified date", e );
	}
}
 
開發者ID:Ostrich-Emulators,項目名稱:semtool,代碼行數:33,代碼來源:AbstractSesameEngine.java

示例4: setRepositoryConnection

import org.openrdf.repository.RepositoryConnection; //導入方法依賴的package包/類
/**
 * Method setRepositoryConnection. Sets the repository connection.
 *
 * @param rc RepositoryConnection. The repository connection that this is
 * being set to.
 */
private void setRepositoryConnection( RepositoryConnection rc,
		boolean takeControl ) {

	this.rc = rc;
	iControlMyRc = takeControl;

	try {

		URI baseuri = null;
		// if the baseuri isn't already set, then query the kb for void:Dataset
		RepositoryResult<Statement> rr
				= rc.getStatements( null, RDF.TYPE, SEMTOOL.Database, false );
		List<Statement> stmts = Iterations.asList( rr );
		for ( Statement s : stmts ) {
			baseuri = URI.class.cast( s.getSubject() );
			break;
		}

		if ( null == baseuri ) {
			// no base uri in the DB, so make a new one
			baseuri = getNewBaseUri();
			//rc.begin();
			rc.add( baseuri, RDF.TYPE, SEMTOOL.Database );
			//rc.add(  baseuri, SEMTOOL.ReificationModel, SEMTOOL.SEMTOOL_Reification );
			//rc.commit();
		}

		setBaseUri( baseuri );
	}
	catch ( RepositoryException re ) {
		log.warn( re, re );
	}
}
 
開發者ID:Ostrich-Emulators,項目名稱:semtool,代碼行數:40,代碼來源:InMemorySesameEngine.java


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