當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。