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


Java ValueFactory.createLiteral方法代码示例

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


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

示例1: Literal

import org.openrdf.model.ValueFactory; //导入方法依赖的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: toLiteral

import org.openrdf.model.ValueFactory; //导入方法依赖的package包/类
/**
 * Create a datatyped literal from a blueprints property value.
 * <p>
 * Supports: Float, Double, Integer, Long, Boolean, Short, Byte, and String.
 */
default Literal toLiteral(final Object value) {

    final ValueFactory vf = Defaults.VF;
    
    if (value instanceof Float) {
        return vf.createLiteral((Float) value);
    } else if (value instanceof Double) {
        return vf.createLiteral((Double) value);
    } else if (value instanceof Integer) {
        return vf.createLiteral((Integer) value);
    } else if (value instanceof Long) {
        return vf.createLiteral((Long) value);
    } else if (value instanceof Boolean) {
        return vf.createLiteral((Boolean) value);
    } else if (value instanceof Short) {
        return vf.createLiteral((Short) value);
    } else if (value instanceof Byte) {
        return vf.createLiteral((Byte) value);
    } else if (value instanceof String) { 
        return vf.createLiteral((String) value);
    } else {
        throw new IllegalArgumentException(String.format("not supported: %s", value));
    }
    
}
 
开发者ID:blazegraph,项目名称:tinkerpop3,代码行数:31,代码来源:BlazeValueFactory.java

示例3: cleanValue

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

示例4: convertToValueArray

import org.openrdf.model.ValueFactory; //导入方法依赖的package包/类
public Value[] convertToValueArray( ValueFactory vf ) {
	int arrsize = propcache.size() + ( isRel() ? 2 : 1 );

	Value vals[] = new Value[arrsize];

	vals[0] = vf.createLiteral( getSubject() );
	int i = 0;
	if ( isRel() ) {
		vals[1] = vf.createLiteral( getObject() );
		i = 1;
	}

	for ( String prop : propcache.keySet() ) {
		vals[++i] = ( containsKey( prop ) ? get( prop ) : null );
	}

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

示例5: createObject

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

示例6: testAddProperty_String

import org.openrdf.model.ValueFactory; //导入方法依赖的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: actionPerformed

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

示例8: actionPerformed

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

示例9: contains

import org.openrdf.model.ValueFactory; //导入方法依赖的package包/类
private boolean contains(URI subject, String property, Object value) throws Exception {
    final ValueFactory vf = connection.getValueFactory();
    Value rdfVal = null;
    if (value instanceof URI) {
        rdfVal = vf.createURI(value.toString());
    } else if (value instanceof Integer) {
        rdfVal = vf.createLiteral((Integer) value);
    } else if (value instanceof Long) {
        rdfVal = vf.createLiteral((Long) value);
    } else if (value instanceof Double) {
        rdfVal = vf.createLiteral((Double) value);
    } else if (value instanceof Boolean) {
        rdfVal = vf.createLiteral((Boolean) value);
    } else if (value instanceof Date) {
        rdfVal = vf.createLiteral((Date) value);
    } else if (value instanceof String) {
        rdfVal = vf.createLiteral(value.toString());
    }
    return connection
            .getStatements(vf.createURI(subject.toString()), vf.createURI(property), rdfVal, false).hasNext();
}
 
开发者ID:kbss-cvut,项目名称:jb4jsonld-jackson,代码行数:22,代码来源:JsonLdSerializationTest.java

示例10: evaluate

import org.openrdf.model.ValueFactory; //导入方法依赖的package包/类
@Override
public Value evaluate(final ValueFactory valueFactory, final Value... args) throws ValueExprEvaluationException {
    if (args.length != 2) {
        throw new ValueExprEvaluationException(getURI() + " requires exactly 2 arguments, got " + args.length);
    }

    final String[] strInterval = args[1].stringValue().split("/");
    if (strInterval.length != 2) {
        throw new ValueExprEvaluationException(getURI() + " requires the second argument: " + args[1] + " to be 2 dates seperated by a \'/\'");
    }
    try {
        final ZonedDateTime date1 = ZonedDateTime.parse(args[0].stringValue());
        final ZonedDateTime[] interval = new ZonedDateTime[] {
                ZonedDateTime.parse(strInterval[0]),
                ZonedDateTime.parse(strInterval[1])
        };
        final boolean result = relation(date1, interval);

        return valueFactory.createLiteral(result);
    } catch (final DateTimeParseException e) {
        throw new ValueExprEvaluationException("Date/Times provided must be of the ISO-8601 format. Example: 2007-04-05T14:30Z");
    }
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:24,代码来源:TemporalIntervalRelationFunction.java

示例11: twoSubjOneFilter_test

import org.openrdf.model.ValueFactory; //导入方法依赖的package包/类
@Test
public void twoSubjOneFilter_test() throws Exception {
    final ValueFactory vf = new ValueFactoryImpl();
    final Value geo = vf.createLiteral("Point(0 0)", GeoConstants.XMLSCHEMA_OGC_WKT);
    final Value temp = vf.createLiteral(new TemporalInstantRfc3339(2015, 12, 30, 12, 00, 0).toString());
    final URI tempPred = vf.createURI(URI_PROPERTY_AT_TIME);
    final String query =
        "PREFIX geo: <http://www.opengis.net/ont/geosparql#>" +
        "PREFIX geos: <http://www.opengis.net/def/function/geosparql/>" +
        "PREFIX time: <tag:rya-rdf.org,2015:temporal#>" +
        "SELECT * WHERE { " +
            "?subj <" + tempPred + "> ?time ."+
            "?subj <" + GeoConstants.GEO_AS_WKT + "> ?loc . " +
            "?subj2 <" + tempPred + "> ?time2 ."+
            "?subj2 <" + GeoConstants.GEO_AS_WKT + "> ?loc2 . " +
            " FILTER(geos:sfContains(?loc, " + geo + ")) . " +
            " FILTER(time:equals(?time, " + temp + ")) . " +
        "}";
    final QuerySegment<EventQueryNode> node = getQueryNode(query);
    final List<EventQueryNode> nodes = provider.getExternalSets(node);
    assertEquals(1, nodes.size());
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:23,代码来源:GeoTemporalProviderTest.java

示例12: onePatternTwoFilters_test

import org.openrdf.model.ValueFactory; //导入方法依赖的package包/类
@Test
public void onePatternTwoFilters_test() throws Exception {
    final ValueFactory vf = new ValueFactoryImpl();
    final Value geo = vf.createLiteral("Point(0 0)", GeoConstants.XMLSCHEMA_OGC_WKT);
    final Value temp = vf.createLiteral(new TemporalInstantRfc3339(2015, 12, 30, 12, 00, 0).toString());
    final URI tempPred = vf.createURI(URI_PROPERTY_AT_TIME);
    final String query =
        "PREFIX geo: <http://www.opengis.net/ont/geosparql#>" +
        "PREFIX geos: <http://www.opengis.net/def/function/geosparql/>" +
        "PREFIX time: <tag:rya-rdf.org,2015:temporal#>" +
        "SELECT * WHERE { " +
            "?subj <" + tempPred + "> ?time ."+
            " FILTER(geos:sfContains(?loc, " + geo + ")) . " +
            " FILTER(time:equals(?time, " + temp + ")) . " +
        "}";
    final QuerySegment<EventQueryNode> node = getQueryNode(query);
    final List<EventQueryNode> nodes = provider.getExternalSets(node);
    assertEquals(0, nodes.size());
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:20,代码来源:GeoTemporalProviderTest.java

示例13: genericStatementGml

import org.openrdf.model.ValueFactory; //导入方法依赖的package包/类
private static Statement genericStatementGml(final Geometry geo, final URI encodingMethod) {
    final ValueFactory vf = new ValueFactoryImpl();
    final Resource subject = vf.createURI("uri:" + NAMES.get(geo));
    final URI predicate = GeoConstants.GEO_AS_GML;

    final String gml ;
    if (encodingMethod == USE_JTS_LIB_ENCODING) {
        gml = geoToGmlUseJtsLib(geo);
    } else if (encodingMethod == USE_ROUGH_ENCODING) {
        gml = geoToGmlRough(geo);
    }
    else {
        throw new Error("invalid encoding method: "+encodingMethod);
    //        System.out.println("===created GML====");
    //        System.out.println(gml);
    //        System.out.println("========== GML====");
    }

    final Value object = vf.createLiteral(gml, GeoConstants.XMLSCHEMA_OGC_GML);
    return new StatementImpl(subject, predicate, object);
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:22,代码来源:GeoIndexerSfTest.java

示例14: twoPatternsTwoFilters_test

import org.openrdf.model.ValueFactory; //导入方法依赖的package包/类
@Test
public void twoPatternsTwoFilters_test() throws Exception {
    final ValueFactory vf = new ValueFactoryImpl();
    final Value geo = vf.createLiteral("Point(0 0)", GeoConstants.XMLSCHEMA_OGC_WKT);
    final Value temp = vf.createLiteral(new TemporalInstantRfc3339(2015, 12, 30, 12, 00, 0).toString());
    final URI tempPred = vf.createURI(URI_PROPERTY_AT_TIME);
    final String query =
        "PREFIX geo: <http://www.opengis.net/ont/geosparql#>" +
        "PREFIX geos: <http://www.opengis.net/def/function/geosparql/>" +
        "PREFIX time: <tag:rya-rdf.org,2015:temporal#>" +
        "SELECT * WHERE { " +
            "?subj <" + tempPred + "> ?time ."+
            "?subj <" + GeoConstants.GEO_AS_WKT + "> ?loc . " +
            " FILTER(geos:sfContains(?loc, " + geo + ")) . " +
            " FILTER(time:equals(?time, " + temp + ")) . " +
        "}";
    final QuerySegment<EventQueryNode> node = getQueryNode(query);
    final List<EventQueryNode> nodes = provider.getExternalSets(node);
    assertEquals(1, nodes.size());
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:21,代码来源:GeoTemporalProviderTest.java

示例15: loadLegacyData

import org.openrdf.model.ValueFactory; //导入方法依赖的package包/类
/**
 * Loads data in the (legacy) properties format. Automatically upgrades the
 * legacy parameter style, too
 *
 * @param dreamerProp the properties containing the perspective trees
 */
public final void loadLegacyData( Properties dreamerProp ) {
	String persps = dreamerProp.getProperty( Constants.PERSPECTIVE, "" );

	perspectives.clear();

	log.debug( "Legacy Perspectives: " + persps );
	if ( !persps.isEmpty() ) {
		ValueFactory insightVF = new ValueFactoryImpl();

		Date now = new Date();
		Literal creator = insightVF.createLiteral( "Imported By "
				+ Utility.getBuildProperties( Utility.class ).getProperty( "name",
						"OS-EM Semantic Toolkit" ) );

		for ( String pname : persps.split( ";" ) ) {
			Perspective p = new Perspective( pname );
			p.setId( urib.build( pname ) );

			List<Insight> insightlist = loadLegacyQuestions( dreamerProp.getProperty( pname ),
					pname, dreamerProp, now, creator, urib );
			for ( Insight i : insightlist ) {
				insights.put( i.getId(), i );
			}

			p.setInsights( insightlist );

			perspectives.add( p );
		}

		dreamerProp.remove( Constants.PERSPECTIVE );
	}
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:39,代码来源:LegacyUpgradingInsightManagerImpl.java


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