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


Java Value类代码示例

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


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

示例1: testAddProperty_String

import org.openrdf.model.Value; //导入依赖的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

示例2: getCopier

import org.openrdf.model.Value; //导入依赖的package包/类
private static RepositoryCopier getCopier( RepositoryConnection conn,
		Map<URI, URI> fromto, URI schema, URI data ) {
	final UriBuilder owlb = UriBuilder.getBuilder( schema );
	final UriBuilder datab = UriBuilder.getBuilder( data );

	return new RepositoryCopier( conn ) {

		@Override
		public void handleStatement( Statement stmt ) throws RDFHandlerException {
			URI sub = URI.class.cast( stmt.getSubject() );
			URI pred = stmt.getPredicate();
			Value obj = stmt.getObject();

			sub = upgrade( sub, fromto, owlb, datab );
			pred = upgrade( pred, fromto, owlb, datab );
			if ( obj instanceof URI ) {
				obj = upgrade( URI.class.cast( obj ), fromto, owlb, datab );
			}

			super.handleStatement( new StatementImpl( sub, pred, obj ) );
		}
	};
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:24,代码来源:LegacyUpgrader.java

示例3: testGetGraphRelsOnly

import org.openrdf.model.Value; //导入依赖的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

示例4: setType

import org.openrdf.model.Value; //导入依赖的package包/类
private void setType( Value o ) {
	if ( null == o ) {
		stringtype.setSelected( true );
	}
	else if ( o instanceof URI ) {
		uritype.setSelected( true );
	}
	else {
		Enumeration<AbstractButton> radios = typegroup.getElements();
		Class<?> typeclass = RDFDatatypeTools.getClassForValue( o );

		while ( radios.hasMoreElements() ) {
			AbstractButton radio = radios.nextElement();
			if ( radio.getActionCommand().equalsIgnoreCase( typeclass.getSimpleName() ) ) {
				radio.setSelected( true );
			}
		}
	}
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:20,代码来源:ConstraintPanel.java

示例5: internalEvaluate

import org.openrdf.model.Value; //导入依赖的package包/类
@Override
protected Value internalEvaluate(final Value... values) throws ExpressionEvaluationException {

    assertStringLiteral(values[0]);
    assertStringLiteral(values[1]);

    if ((values.length - 2) % 3 != 0) {
        throw new ExpressionEvaluationException("Incorrect parameter count");
    }

    for (int i = 2; i < values.length; i += 3) {
        assertStringLiteral(values[i]);
        assertStringLiteral(values[i + 1]);
        assertNumericLiteral(values[i + 2]);
    }

    return literal(getWeightedLevenshteinFunction(values).distance(values[0].stringValue(), values[1].stringValue()));
}
 
开发者ID:semantalytics,项目名称:stardog-plugin-string-similarity,代码行数:19,代码来源:WeightedLevenshtein.java

示例6: ConstraintPanel

import org.openrdf.model.Value; //导入依赖的package包/类
protected ConstraintPanel( URI proptype, String label, JComponent input,
		boolean checked, Value valForType, Map<URI, String> propmap ) {
	initComponents();

	inputarea.setLayout( new BorderLayout() );
	inputarea.add( input );
	this.label.setText( label );
	include.setSelected( checked );

	LabeledPairRenderer<URI> renderer
			= LabeledPairRenderer.getUriPairRenderer().cache( propmap );
	propmap = Utility.sortUrisByLabel( propmap );
	URI[] uris = propmap.keySet().toArray( new URI[0] );
	DefaultComboBoxModel<URI> model = new DefaultComboBoxModel<>( uris );

	property.setModel( model );
	property.setEditable( false );
	property.setRenderer( renderer );
	property.setSelectedItem( null == proptype ? Constants.ANYNODE : proptype );

	setType( valForType );
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:23,代码来源:ConstraintPanel.java

示例7: clear

import org.openrdf.model.Value; //导入依赖的package包/类
public static void clear( IEngine engine ) throws RepositoryException {
	try {
		final Map<URI, Value> metas = engine.query( new MetadataQuery() );
		metas.remove( SEMTOOL.Database );

		engine.execute( new ModificationExecutorAdapter( true ) {

			@Override
			public void exec( RepositoryConnection conn ) throws RepositoryException {
				conn.remove( (Resource) null, null, null );
				ValueFactory vf = conn.getValueFactory();

				// re-add the metadata
				for ( Map.Entry<URI, Value> en : metas.entrySet() ) {
					conn.add( engine.getBaseUri(),
							URI.class.cast( EngineLoader.cleanValue( en.getKey(), vf ) ),
							EngineLoader.cleanValue( en.getValue(), vf ) );
				}
			}
		} );
	}
	catch ( MalformedQueryException | QueryEvaluationException e ) {
		log.error( e, e );
	}
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:26,代码来源:EngineUtil2.java

示例8: create

import org.openrdf.model.Value; //导入依赖的package包/类
@Override
public void create( List<Value[]> valdata, List<String> headers, IEngine engine ) {
	setHeaders( headers );
	List<String[]> stringdata = convertEverythingToStrings( valdata, engine );

	int row = 0;
	String newdata[][] = new String[stringdata.size()][getHeaders().size()];
	for ( String[] rowdata : stringdata ) {
		newdata[row++] = rowdata;
	}

	TreeNode<String> root = new TreeNode<>( "Root" );
	buildTree( root, newdata, 0, newdata.length, 0 );
	// printTree( root, 0 );
	addDataHash( buildAllHash( root ) );
	createView();
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:18,代码来源:DendrogramPlaySheet.java

示例9: cleanValue

import org.openrdf.model.Value; //导入依赖的package包/类
/**
 * "Cleans" a value for BigData
 *
 * @param v the value that needs cleaning
 * @param vf the value factory to make the new Value from
 * @return a value that won't make BigData bomb
 */
public static Value cleanValue( Value v, ValueFactory vf ) {
	Value newv;
	if ( v instanceof URI ) {
		newv = vf.createURI( v.stringValue() );
	}
	else if ( v instanceof BNode ) {
		newv = vf.createBNode( v.stringValue() );
	}
	else {
		Literal oldv = Literal.class.cast( v );
		if ( null != oldv.getLanguage() ) {
			newv = vf.createLiteral( oldv.stringValue(), oldv.getLanguage() );
		}
		else {
			newv = vf.createLiteral( oldv.stringValue(), oldv.getDatatype() );
		}
	}

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

示例10: create

import org.openrdf.model.Value; //导入依赖的package包/类
/**
 * Creates graph nodes from the given data. If the {@code Value[]}s have
 * length 1, the values are expected to be nodes ({@link Resource}s. If they
 * have length 3, then they are repackaged as Statements, and forwarded on to
 * {@link #create(org.openrdf.model.Model, com.ostrichemulators.semtool.rdf.engine.api.IEngine) }.
 * Anything else will throw an exception
 *
 * @param data the data to add are expected to be
 * @param headers ignored
 * @param engine
 * @throws IllegalArgumentException
 *
 */
@Override
public void create( List<Value[]> data, List<String> headers, IEngine engine ) {
	List<URI> nodes = new ArrayList<>();
	Model model = new LinkedHashModel();
	for ( Value[] row : data ) {
		URI s = URI.class.cast( row[0] );
		if ( 1 == row.length ) {
			nodes.add( s );
		}
		else if ( 3 == row.length ) {
			URI p = URI.class.cast( row[1] );
			Value o = row[2];

			model.add( s, p, o );
		}
		else {
			throw new IllegalArgumentException( "Values cannot be converted for graph usage" );
		}
	}

	add( model, nodes, engine );
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:36,代码来源:GraphPlaySheet.java

示例11: setRenderer

import org.openrdf.model.Value; //导入依赖的package包/类
private void setRenderer( RetrievingLabelCache cacher ) {
	cacher.put( Constants.ANYNODE, "SELECT ALL" );
	cacher.put( RDF.SUBJECT, "URI" );
	cacher.put( RDFS.LABEL, "Label" );
	cacher.put( RDF.TYPE, "Type" );
	cacher.put( Constants.IN_EDGE_CNT, "Inputs" );
	cacher.put( Constants.OUT_EDGE_CNT, "Outputs" );

	LabeledPairTableCellRenderer<Value> renderer
			= LabeledPairTableCellRenderer.getValuePairRenderer( cacher );
	for ( JTable jt : new JTable[]{ nodes, edges, nodelabels, edgelabels, selecteds } ) {
		jt.setDefaultRenderer( URI.class, renderer );
		jt.setDefaultRenderer( Value.class, renderer );
	}

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

示例12: create

import org.openrdf.model.Value; //导入依赖的package包/类
@Override
public void create( List<Value[]> newdata, List<String> headers, IEngine engine ) {
	setHeaders( headers );
	convertUrisToLabels( newdata, engine );

	Map<String, List<Object>> data = new HashMap<>();
	for ( Value[] elemValues : newdata ) {
		List<Object> values = new ArrayList<>();
		for ( int j = 1; j < elemValues.length; j++ ) {
			Literal v = Literal.class.cast( elemValues[j] );
			double dbl = v.doubleValue();
			values.add( dbl );
		}
		data.put( elemValues[0].stringValue(), values );
	}

	Map<String, Object> columnChartHash = new HashMap<>();
	columnChartHash.put( "xAxis",
			headers.subList( 1, headers.size() ).toArray( new String[0] ) );
	columnChartHash.put( "type", "column" );
	columnChartHash.put( "title", getTitle() );
	columnChartHash.put( "dataSeries", data );

	addDataHash( columnChartHash );
	createView();
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:27,代码来源:ColumnChartPlaySheet.java

示例13: addProperties

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

	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, true );
			predicate = getCachedRelationClass( sheet.getSubjectType()
					+ sheet.getObjectType() + propname );
		}

		myrc.add( subject, predicate, value );
	}
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:23,代码来源:AbstractEdgeModeler.java

示例14: testHasProp2

import org.openrdf.model.Value; //导入依赖的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

示例15: getSmithWatermanFunction

import org.openrdf.model.Value; //导入依赖的package包/类
private org.simmetrics.metrics.SmithWaterman getSmithWatermanFunction(final Value... values) throws ExpressionEvaluationException {
    if (smithWaterman == null) {
        if (values.length == 7) {
            for(final Expression expression : getArgs()) {
                if(!(expression instanceof Constant)) {
                    throw new ExpressionEvaluationException("Parameters 2 through 7 must be constant expressions");
                }
            }
            final float gapA = assertNumericLiteral(values[2]).floatValue();
            final float gapB = assertNumericLiteral(values[3]).floatValue();
            
            final float subPenaltyA = assertNumericLiteral(values[4]).floatValue();
            final float subPenaltyB = assertNumericLiteral(values[5]).floatValue();
            
            final int windowSize = assertNumericLiteral(values[6]).intValue();
            
            smithWaterman = new org.simmetrics.metrics.SmithWaterman(new AffineGap(gapA, gapB), new MatchMismatch(subPenaltyA, subPenaltyB), windowSize);
        } else {
            smithWaterman = new org.simmetrics.metrics.SmithWaterman();
        }
    }
    return smithWaterman;
}
 
开发者ID:semantalytics,项目名称:stardog-plugin-string-similarity,代码行数:24,代码来源:SmithWaterman.java


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