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


Java ValueFactoryImpl类代码示例

本文整理汇总了Java中org.openrdf.model.impl.ValueFactoryImpl的典型用法代码示例。如果您正苦于以下问题:Java ValueFactoryImpl类的具体用法?Java ValueFactoryImpl怎么用?Java ValueFactoryImpl使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: doUpdate

import org.openrdf.model.impl.ValueFactoryImpl; //导入依赖的package包/类
public static final void doUpdate( UpdateExecutor query,
		RepositoryConnection rc, boolean dobindings ) throws RepositoryException,
		MalformedQueryException, UpdateExecutionException {

	String sparql = processNamespaces( dobindings ? query.getSparql()
			: query.bindAndGetSparql(), query.getNamespaces() );

	ValueFactory vfac = new ValueFactoryImpl();
	Update upd = rc.prepareUpdate( QueryLanguage.SPARQL, sparql );

	if ( dobindings ) {
		upd.setIncludeInferred( query.usesInferred() );
		query.setBindings( upd, vfac );
	}

	upd.execute();
	query.done();
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:19,代码来源:AbstractSesameEngine.java

示例2: getModel

import org.openrdf.model.impl.ValueFactoryImpl; //导入依赖的package包/类
public static Model getModel( InsightManager im, User user ) {
	Model statements = new LinkedHashModel();
	int idx = 0;

	RDFParser parser = new TurtleParser();
	StatementCollector coll = new StatementCollector();
	parser.setRDFHandler( coll );
	try ( InputStream is = IEngine.class.getResourceAsStream( "/models/sempers.ttl" ) ) {
		parser.parse( is, SEMPERS.BASE_URI );
	}
	catch ( Exception e ) {
		log.warn( "could not include sempers.ttl ontology in statements", e );
	}

	statements.addAll( coll.getStatements() );

	ValueFactory vf = new ValueFactoryImpl();
	for ( Perspective p : im.getPerspectives() ) {
		statements.addAll( getStatements( p, user ) );
		statements.add( new StatementImpl( p.getId(), OLO.index,
				vf.createLiteral( idx++ ) ) );
	}

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

示例3: hasProperty

import org.openrdf.model.impl.ValueFactoryImpl; //导入依赖的package包/类
public boolean hasProperty( URI needle, Map<String, String> namespaces ) {
	ValueFactory vf = new ValueFactoryImpl();
	for ( String head : keySet() ) {
		if ( head.contains( ":" ) ) {
			int idx = head.indexOf( ":" );
			String headns = head.substring( 0, idx );
			String localname = head.substring( idx + 1 );

			if ( namespaces.containsKey( headns ) ) {
				URI uri = vf.createURI( namespaces.get( headns ), localname );
				if ( uri.equals( needle ) ) {
					return true;
				}
			}
		}
	}

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

示例4: createObject

import org.openrdf.model.impl.ValueFactoryImpl; //导入依赖的package包/类
private Value createObject( String object, Map<String, String> jcrMap ) {
	ValueFactory vf = new ValueFactoryImpl();

	// need to do the class vs. object magic
	if ( object.contains( "+" ) ) {
		StringBuilder strBuilder = new StringBuilder();
		String[] objList = object.split( "\\+" );
		for ( String objList1 : objList ) {
			strBuilder.append( jcrMap.get( objList1 ) );
		}
		return vf.createLiteral( strBuilder.toString() );
	}

	Object o = jcrMap.get( object );
	if ( null == o ) {
		return null;
	}

	String val = o.toString();
	// see if we have a special datatype to worry about
	if ( datatypes.containsKey( object ) ) {
		return vf.createLiteral( val, datatypes.get( object ) );
	}
	return vf.createLiteral( val );
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:26,代码来源:CSVReader.java

示例5: testAddNode

import org.openrdf.model.impl.ValueFactoryImpl; //导入依赖的package包/类
@Test
public void testAddNode() throws Exception {
	Map<String, Value> props = new HashMap<>();
	props.put( "First Name", vf.createLiteral( "Yuri" ) );
	props.put( "Last Name", vf.createLiteral( "Gagarin" ) );
	LoadingSheetData.LoadingNodeAndPropertyValues node = nodes.add( "Yuri", props );

	TestModeler instance = new TestModeler( qaer );
	Model model = instance.createMetamodel( data, new HashMap<>(),
			new ValueFactoryImpl() );
	engine.getRawConnection().add( model );

	instance.addNode( node, new HashMap<>(), rels, data.getMetadata(),
			engine.getRawConnection() );

	compare( engine, NODE );
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:18,代码来源:AbstractEdgeModelerTest.java

示例6: testAddProperty_String

import org.openrdf.model.impl.ValueFactoryImpl; //导入依赖的package包/类
@Test
public void testAddProperty_String() {
	LoadingSheetData lsd = LoadingSheetData.nodesheet( "tabname", "sbj" );
	lsd.addProperty( "xx" );
	lsd.addProperty( "yy" );
	Map<String, Value> props = new HashMap<>();
	ValueFactory vf = new ValueFactoryImpl();
	props.put( "xx", vf.createLiteral( "testval" ) );
	LoadingNodeAndPropertyValues naps = lsd.add( "instance", props );

	Value expected[] = { vf.createLiteral( "instance" ),
		vf.createLiteral( "testval" ), null };

	Value[] vals = naps.convertToValueArray( vf );
	assertArrayEquals( expected, vals );
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:17,代码来源:LoadingSheetDataTest.java

示例7: testHasProp2

import org.openrdf.model.impl.ValueFactoryImpl; //导入依赖的package包/类
@Test
public void testHasProp2() {
	LoadingSheetData lsd = LoadingSheetData.nodesheet( "sbj" );
	lsd.addProperties( Arrays.asList( "xx:label", "yy", "yy:junk" ) );
	Map<String, Value> props = new HashMap<>();
	ValueFactory vf = new ValueFactoryImpl();
	props.put( "xx:label", vf.createLiteral( "my label" ) );
	props.put( "yy", vf.createLiteral( "my y val" ) );
	props.put( "yy:junk", vf.createLiteral( "my junk val" ) );
	LoadingNodeAndPropertyValues nap = lsd.add( "instance", "object", props );

	Map<String, String> nsmap = new HashMap<>();
	nsmap.put( RDFS.PREFIX, RDFS.NAMESPACE );
	nsmap.put( "xx", "http://google.com/" );
	assertFalse( nap.hasProperty( RDFS.LABEL, nsmap ) );
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:17,代码来源:LoadingSheetDataTest.java

示例8: setUp

import org.openrdf.model.impl.ValueFactoryImpl; //导入依赖的package包/类
@Before
public void setUp() {
	LoadingSheetData rels
			= LoadingSheetData.relsheet( "Human Being", "Car", "Purchased" );
	rels.addProperties( Arrays.asList( "Price", "Date" ) );

	LoadingSheetData nodes = LoadingSheetData.nodesheet( "Human Being" );
	nodes.addProperties( Arrays.asList( "First Name", "Last Name" ) );

	data = new ImportData();
	data.add( rels );
	data.add( nodes );

	ValueFactory vf = new ValueFactoryImpl();
	Map<String, Value> props = new HashMap<>();
	props.put( "Price", vf.createLiteral( "3000 USD" ) );
	rels.add( "Yuri", "Yugo", props );
	rels.add( "Yuri", "Pinto" );

	Map<String, Value> hprop = new HashMap<>();
	hprop.put( "First Name", vf.createLiteral( "Yuri" ) );
	hprop.put( "Last Name", vf.createLiteral( "Gagarin" ) );
	nodes.add( "Yuri", hprop );
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:25,代码来源:GsonWriterTest.java

示例9: testGetGraphRelsOnly

import org.openrdf.model.impl.ValueFactoryImpl; //导入依赖的package包/类
@Test
public void testGetGraphRelsOnly() {
	LoadingSheetData rels
			= LoadingSheetData.relsheet( "Human Being", "Car", "Purchased" );
	rels.addProperties( Arrays.asList( "Price", "Date" ) );
	ValueFactory vf = new ValueFactoryImpl();
	Map<String, Value> props = new HashMap<>();
	props.put( "Price", vf.createLiteral( "3000 USD" ) );
	rels.add( "Yuri", "Yugo", props );
	rels.add( "Yuri", "Pinto" );

	Graph g = GsonWriter.getGraph( data );
	int vsize = 0;
	int esize = 0;
	for ( Vertex v : g.getVertices() ) {
		vsize++;
	}
	for ( Edge e : g.getEdges() ) {
		esize++;
	}

	assertEquals( 3, vsize );
	assertEquals( 2, esize );
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:25,代码来源:GsonWriterTest.java

示例10: actionPerformed

import org.openrdf.model.impl.ValueFactoryImpl; //导入依赖的package包/类
/**
 * Method actionPerformed. Dictates what actions to take when an Action Event
 * is performed.
 *
 * @param arg0 ActionEvent - The event that triggers the actions in the
 * method.
 */
@Override
public void actionPerformed( ActionEvent arg0 ) {
	logger.debug( "Export button has been pressed" );

	DirectedGraph<SEMOSSVertex, SEMOSSEdge> graph = gps.getVisibleGraph();

	ValueFactory vf = new ValueFactoryImpl();
	List<Value[]> vals = new ArrayList<>();

	for ( SEMOSSEdge edge : graph.getEdges() ) {
		SEMOSSVertex src = graph.getSource( edge );
		SEMOSSVertex dst = graph.getDest( edge );

		Value subj = vf.createLiteral( src.getLabel() );
		Value obj = vf.createLiteral( dst.getLabel() );
		vals.add( new Value[] { subj, obj } );
	}

	GridRAWPlaySheet.convertUrisToLabels( vals, gps.getEngine() );

	GridRAWPlaySheet newGps = new GridRAWPlaySheet();
	newGps.setTitle( "EXPORT: " + gps.getTitle() );
	newGps.create( vals, Arrays.asList( "Source", "Destination" ), gps.getEngine() );
	gps.addSibling( "Graph Edge List", newGps );
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:33,代码来源:GraphPlaySheetEdgeListExporter.java

示例11: actionPerformed

import org.openrdf.model.impl.ValueFactoryImpl; //导入依赖的package包/类
@Override
public void actionPerformed( ActionEvent ae ) {
	MultiMap<URI, GraphElement> typeCounts = new MultiMap<>();
	for ( GraphElement v : pickedVertex ) {
		URI vType = v.getType();
		typeCounts.add( vType, v );
	}

	ValueFactory vf = new ValueFactoryImpl();
	List<Value[]> data = new ArrayList<>();
	int total = 0;
	for ( Map.Entry<URI, List<GraphElement>> en : typeCounts.entrySet() ) {
		Value[] row = { en.getKey(), vf.createLiteral( en.getValue().size() ) };
		data.add( row );
		total += en.getValue().size();
	}

	data.add( new Value[]{ vf.createLiteral( "Total Vertex Count" ),
		vf.createLiteral( total ) } );

	GridPlaySheet grid = new GridPlaySheet();
	grid.setTitle( "Selected Node/Edge Information" );
	grid.create( data, Arrays.asList( "Property Name", "Value" ), gps.getEngine() );
	gps.addSibling( grid );
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:26,代码来源:NodeInfoPopup.java

示例12: changesNothing

import org.openrdf.model.impl.ValueFactoryImpl; //导入依赖的package包/类
/**
 * This Projection enumerates all of the variables that were in the query, none of them are anonymous, and
 * none of them insert constants.
 */
@Test
public void changesNothing() throws Exception {
    // Read the projection object from a SPARQL query.
    final Projection projection = getProjection(
            "SELECT ?person ?employee ?business " +
            "WHERE { " +
                "?person <urn:talksTo> ?employee . " +
                "?employee <urn:worksAt> ?business . " +
            "}");

    // Create a Binding Set that contains the result of the WHERE clause.
    final ValueFactory vf = new ValueFactoryImpl();
    final MapBindingSet bs = new MapBindingSet();
    bs.addBinding("person", vf.createURI("urn:Alice"));
    bs.addBinding("employee", vf.createURI("urn:Bob"));
    bs.addBinding("business", vf.createURI("urn:TacoJoint"));
    final VisibilityBindingSet original = new VisibilityBindingSet(bs, "a|b");

    // Execute the projection.
    final VisibilityBindingSet result = ProjectionEvaluator.make(projection).project(original);
    assertEquals(original, result);
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:27,代码来源:ProjectionEvaluatorTest.java

示例13: matchesSubject

import org.openrdf.model.impl.ValueFactoryImpl; //导入依赖的package包/类
@Test
public void matchesSubject() throws Exception {
    // Create the matcher against a pattern that matches a specific subject.
    final StatementPatternMatcher matcher = new StatementPatternMatcher(getSp(
            "SELECT * WHERE {" +
                "<urn:Alice> ?p ?o ." +
            "}"));

    // Create a statement that matches the pattern.
    final ValueFactory vf = new ValueFactoryImpl();
    final Statement statement = vf.createStatement(vf.createURI("urn:Alice"), vf.createURI("urn:talksTo"), vf.createURI("urn:Bob"), vf.createURI("urn:testGraph"));

    // Create the expected resulting Binding Set.
    final QueryBindingSet expected = new QueryBindingSet();
    expected.addBinding("p", vf.createURI("urn:talksTo"));
    expected.addBinding("o", vf.createURI("urn:Bob"));

    // Show the expected Binding Set matches the resulting Binding Set.
    final Optional<BindingSet> bs = matcher.match(statement);
    assertEquals(expected, bs.get());
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:22,代码来源:StatementPatternMatcherTest.java

示例14: matchesPredicate

import org.openrdf.model.impl.ValueFactoryImpl; //导入依赖的package包/类
@Test
public void matchesPredicate() throws Exception {
    // Create the matcher against a pattern that matches a specific predicate.
    final StatementPatternMatcher matcher = new StatementPatternMatcher(getSp(
            "SELECT * WHERE {" +
                "?s <urn:talksTo> ?o ." +
            "}"));

    // Create a statement that matches the pattern.
    final ValueFactory vf = new ValueFactoryImpl();
    final Statement statement = vf.createStatement(vf.createURI("urn:Alice"), vf.createURI("urn:talksTo"), vf.createURI("urn:Bob"), vf.createURI("urn:testGraph"));

    // Create the expected resulting Binding Set.
    final QueryBindingSet expected = new QueryBindingSet();
    expected.addBinding("s", vf.createURI("urn:Alice"));
    expected.addBinding("o", vf.createURI("urn:Bob"));

    // Show the expected Binding Set matches the resulting Binding Set.
    final Optional<BindingSet> bs = matcher.match(statement);
    assertEquals(expected, bs.get());
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:22,代码来源:StatementPatternMatcherTest.java

示例15: matchesObject

import org.openrdf.model.impl.ValueFactoryImpl; //导入依赖的package包/类
@Test
public void matchesObject() throws Exception {
    // Create the matcher against a pattern that matches a specific object.
    final StatementPatternMatcher matcher = new StatementPatternMatcher(getSp(
            "SELECT * WHERE {" +
                "?s ?p <urn:Bob> ." +
            "}"));

    // Create a statement that matches the pattern.
    final ValueFactory vf = new ValueFactoryImpl();
    final Statement statement = vf.createStatement(vf.createURI("urn:Alice"), vf.createURI("urn:talksTo"), vf.createURI("urn:Bob"), vf.createURI("urn:testGraph"));

    // Create the expected resulting Binding Set.
    final QueryBindingSet expected = new QueryBindingSet();
    expected.addBinding("s", vf.createURI("urn:Alice"));
    expected.addBinding("p", vf.createURI("urn:talksTo"));

    // Show the expected Binding Set matches the resulting Binding Set.
    final Optional<BindingSet> bs = matcher.match(statement);
    assertEquals(expected, bs.get());
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:22,代码来源:StatementPatternMatcherTest.java


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