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


Java RepositoryConnection.getValueFactory方法代码示例

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


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

示例1: Literal

import org.openrdf.repository.RepositoryConnection; //导入方法依赖的package包/类
/**
 * Literal factory
 * 
 * @param s
 *            the literal value
 * @param typeuri
 *            uri representing the type (generally xsd)
 * @return
 */
public org.openrdf.model.Literal Literal(String s, URI typeuri) {
	try {
		RepositoryConnection con = therepository.getConnection();
		try {
			ValueFactory vf = con.getValueFactory();
			if (typeuri == null) {
				return vf.createLiteral(s);
			} else {
				return vf.createLiteral(s, typeuri);
			}
		} finally {
			con.close();
		}
	} catch (Exception e) {
		e.printStackTrace();
		return null;
	}
}
 
开发者ID:dvcama,项目名称:resource-to-sparqlresult,代码行数:28,代码来源:SimpleGraph.java

示例2: URIref

import org.openrdf.repository.RepositoryConnection; //导入方法依赖的package包/类
/**
 * URIref factory
 * 
 * @param uri
 * @return
 */
public URI URIref(String uri) {
	try {
		RepositoryConnection con = therepository.getConnection();
		try {
			ValueFactory vf = con.getValueFactory();
			return vf.createURI(uri);
		} finally {
			con.close();
		}
	} catch (Exception e) {
		e.printStackTrace();
		return null;
	}
}
 
开发者ID:dvcama,项目名称:resource-to-sparqlresult,代码行数:21,代码来源:SimpleGraph.java

示例3: bnode

import org.openrdf.repository.RepositoryConnection; //导入方法依赖的package包/类
/**
 * BNode factory
 * 
 * @return
 */
public BNode bnode() {
	try {
		RepositoryConnection con = therepository.getConnection();
		try {
			ValueFactory vf = con.getValueFactory();
			return vf.createBNode();
		} finally {
			con.close();
		}
	} catch (Exception e) {
		e.printStackTrace();
		return null;
	}
}
 
开发者ID:dvcama,项目名称:resource-to-sparqlresult,代码行数:20,代码来源:SimpleGraph.java

示例4: add

import org.openrdf.repository.RepositoryConnection; //导入方法依赖的package包/类
/**
 * Insert Triple/Statement into graph
 * 
 * @param s
 *            subject uriref
 * @param p
 *            predicate uriref
 * @param o
 *            value object (URIref or Literal)
 */
public void add(URI s, URI p, Value o) {
	try {
		RepositoryConnection con = therepository.getConnection();
		try {
			ValueFactory myFactory = con.getValueFactory();
			Statement st = myFactory.createStatement((Resource) s, p, (Value) o);
			con.add(st, new Resource[0]);
		} finally {
			con.close();
		}
	} catch (Exception e) {
		// handle exception
	}
}
 
开发者ID:dvcama,项目名称:resource-to-sparqlresult,代码行数:25,代码来源:SimpleGraph.java

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

示例6: addNode

import org.openrdf.repository.RepositoryConnection; //导入方法依赖的package包/类
@Override
public URI addNode( LoadingNodeAndPropertyValues nap, Map<String, String> namespaces,
		LoadingSheetData sheet, ImportMetadata metas, RepositoryConnection myrc ) throws RepositoryException {

	String typename = nap.getSubjectType();
	String rawlabel = nap.getSubject();
	URI subject = addSimpleNode( typename, rawlabel, namespaces, metas, myrc );

	ValueFactory vf = myrc.getValueFactory();
	boolean savelabel = metas.isAutocreateMetamodel();
	if ( !metas.isLegacyMode() && rawlabel.contains( ":" ) ) {
		// we have something with a colon in it, so we need to figure out if it's
		// a namespace-prefixed string, or just a string with a colon in it

		Value val = getRDFStringValue( rawlabel, namespaces, vf );
		// check if we have a prefixed URI
		URI u = getUriFromRawString( rawlabel, namespaces );
		savelabel = ( savelabel && null == u );
		rawlabel = val.stringValue();
	}

	// if we have a label property, skip this label-making
	// (it'll get handled in the addProperties function later)
	if ( savelabel && !nap.hasProperty( RDFS.LABEL, namespaces ) ) {
		myrc.add( subject, RDFS.LABEL, vf.createLiteral( rawlabel ) );
	}

	addProperties( subject, nap, namespaces, sheet, metas, myrc );

	return subject;
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:32,代码来源:LegacyEdgeModeler.java

示例7: addProperties

import org.openrdf.repository.RepositoryConnection; //导入方法依赖的package包/类
@Override
public void addProperties( URI subject, Map<String, Value> properties,
		Map<String, String> namespaces, LoadingSheetData sheet,
		ImportMetadata metas, RepositoryConnection myrc ) throws RepositoryException {

	ValueFactory vf = myrc.getValueFactory();

	for ( Map.Entry<String, Value> entry : properties.entrySet() ) {
		String propname = entry.getKey();
		URI predicate = getCachedPropertyClass( propname );

		Value value = entry.getValue();
		if ( sheet.isLink( propname ) ) {
			// our "value" is really the label of another node, so find that node
			value = addSimpleNode( propname, value.stringValue(), namespaces, metas, myrc );
			predicate = getCachedRelationClass( sheet.getSubjectType()
					+ sheet.getObjectType() + propname );
		}

		// not sure if we even use these values anymore
		switch ( value.toString() ) {
			case Constants.PROCESS_CURRENT_DATE:
				myrc.add( subject, predicate,
						vf.createLiteral( getCal( new Date() ) ) );
				break;
			case Constants.PROCESS_CURRENT_USER:
				myrc.add( subject, predicate,
						vf.createLiteral( System.getProperty( "user.name" ) ) );
				break;
			default:
				myrc.add( subject, predicate, value );
		}
	}
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:35,代码来源:LegacyEdgeModeler.java

示例8: addNode

import org.openrdf.repository.RepositoryConnection; //导入方法依赖的package包/类
@Override
public URI addNode( LoadingSheetData.LoadingNodeAndPropertyValues nap,
		Map<String, String> namespaces, LoadingSheetData sheet, ImportMetadata metas,
		RepositoryConnection myrc ) throws RepositoryException {

	String typename = nap.getSubjectType();
	String rawlabel = nap.getSubject();

	URI subject = addSimpleNode( typename, rawlabel, namespaces, metas, myrc, true );

	ValueFactory vf = myrc.getValueFactory();
	boolean savelabel = metas.isAutocreateMetamodel();
	if ( rawlabel.contains( ":" ) ) {
		// we have something with a colon in it, so we need to figure out if it's
		// a namespace-prefixed string, or just a string with a colon in it

		Value val = getRDFStringValue( rawlabel, namespaces, vf );
		// check if we have a prefixed URI
		URI u = getUriFromRawString( rawlabel, namespaces );
		savelabel = ( savelabel && null == u );
		rawlabel = val.stringValue();
	}

	// if we have a label property, skip this label-making
	// (it'll get handled in the addProperties function later)
	if ( savelabel && !nap.hasProperty( RDFS.LABEL, namespaces ) ) {
		myrc.add( subject, RDFS.LABEL, vf.createLiteral( rawlabel ) );
	}

	addProperties( subject, nap, namespaces, sheet, metas, myrc );

	return subject;
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:34,代码来源:AbstractEdgeModeler.java

示例9: setupClass

import org.openrdf.repository.RepositoryConnection; //导入方法依赖的package包/类
@BeforeClass
public static void setupClass() {
	TimeZone.setDefault( TimeZone.getTimeZone( "GMT-04:00" ) );
	engine = InMemorySesameEngine.open();
	try {
		RepositoryConnection rc = engine.getRawConnection();

		GregorianCalendar gCalendar = new GregorianCalendar();
		gCalendar.setTime( date );
		XMLGregorianCalendar xmlcal = null;
		try {
			xmlcal = DatatypeFactory.newInstance().newXMLGregorianCalendar( gCalendar );
		}
		catch ( DatatypeConfigurationException ex ) {
		}

		ValueFactory vf = rc.getValueFactory();
		rc.add( new StatementImpl( ENTITYONE, RDF.TYPE, TYPEONE ) );
		rc.add( new StatementImpl( ENTITYONE, TYPEB, vf.createLiteral( true ) ) );
		rc.add( new StatementImpl( ENTITYONE, TYPED, vf.createLiteral( 1.0 ) ) );
		rc.add( new StatementImpl( ENTITYONE, TYPEI, vf.createLiteral( 1 ) ) );
		rc.add( new StatementImpl( ENTITYONE, TYPES, vf.createLiteral( "string" ) ) );
		rc.add( new StatementImpl( ENTITYONE, TYPES, vf.createLiteral( "cuerda", "es" ) ) );
		rc.add( new StatementImpl( ENTITYONE, TYPEA, vf.createLiteral( xmlcal ) ) );
	}
	catch ( Exception e ) {

	}
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:30,代码来源:QueryExecutorAdapterTest.java


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