本文整理匯總了Java中org.openrdf.model.ValueFactory.createURI方法的典型用法代碼示例。如果您正苦於以下問題:Java ValueFactory.createURI方法的具體用法?Java ValueFactory.createURI怎麽用?Java ValueFactory.createURI使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.openrdf.model.ValueFactory
的用法示例。
在下文中一共展示了ValueFactory.createURI方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: handleTuple
import org.openrdf.model.ValueFactory; //導入方法依賴的package包/類
@Override
public void handleTuple( BindingSet set, ValueFactory fac ) {
URI pred = fac.createURI( set.getValue( "p" ).stringValue() );
Value val = set.getValue( "o" );
// for baseuri, we need the subject, not the object
// and also, we use the VOID_DS as the key elsewhere in the code
if ( RDF.TYPE.equals( pred ) ) {
pred = SEMTOOL.Database;
val = set.getValue( "db" );
}
else if ( pred.getNamespace().equals( DC.NAMESPACE ) ) {
// silently handle the old DC namespace (ignore our DC-specific URIs)
if ( !( MetadataConstants.DCT_CREATED.equals( pred )
|| MetadataConstants.DCT_MODIFIED.equals( pred ) ) ) {
pred = fac.createURI( DCTERMS.NAMESPACE, pred.getLocalName() );
}
}
result.put( pred, val );
}
示例2: 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;
}
示例3: hasProperty
import org.openrdf.model.ValueFactory; //導入方法依賴的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;
}
示例4: 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();
}
示例5: 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);
}
示例6: 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());
}
示例7: activate
import org.openrdf.model.ValueFactory; //導入方法依賴的package包/類
@Override
public void activate(final Collection<SesameSwitchMonitoredMatch> matches) throws Exception {
final RepositoryConnection con = driver.getConnection();
final ValueFactory vf = driver.getValueFactory();
final URI sensorEdgeType = vf.createURI(BASE_PREFIX + MONITORED_BY);
final URI sensorType = vf.createURI(BASE_PREFIX + SENSOR);
final URI trackElementType = vf.createURI(BASE_PREFIX + TRACKELEMENT);
for (final SesameSwitchMonitoredMatch match : matches) {
final Resource sw = match.getSw();
final URI sensor = vf.createURI(BASE_PREFIX + ID_PREFIX + driver.generateNewVertexId());
// set vertex type
con.add(sensor, RDF.TYPE, sensorType);
// insert the supertype as well
if (!driver.isInferencing()) {
con.add(sensor, RDF.TYPE, trackElementType);
}
// insert edge
con.add(sw, sensorEdgeType, sensor);
}
}
示例8: 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());
}
示例9: 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());
}
示例10: URIref
import org.openrdf.model.ValueFactory; //導入方法依賴的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;
}
}
示例11: testDcSearchWithPredicate
import org.openrdf.model.ValueFactory; //導入方法依賴的package包/類
@Test
public void testDcSearchWithPredicate() throws Exception {
// test a ring around dc
try (final MongoGeoIndexer f = new MongoGeoIndexer()) {
f.setConf(conf);
f.init();
final ValueFactory vf = new ValueFactoryImpl();
final Resource subject = vf.createURI("foo:subj");
final URI predicate = GeoConstants.GEO_AS_WKT;
final Value object = vf.createLiteral("Point(-77.03524 38.889468)", GeoConstants.XMLSCHEMA_OGC_WKT);
final Resource context = vf.createURI("foo:context");
final Statement statement = new ContextStatementImpl(subject, predicate, object, context);
f.storeStatement(convertStatement(statement));
f.flush();
final double[] IN = { -78, 39, -77, 39, -77, 38, -78, 38, -78, 39 };
final LinearRing r1 = gf.createLinearRing(new PackedCoordinateSequence.Double(IN, 2));
final Polygon p1 = gf.createPolygon(r1, new LinearRing[] {});
// query with correct Predicate
assertEquals(Sets.newHashSet(statement),
getSet(f.queryWithin(p1, new StatementConstraints().setPredicates(Collections.singleton(predicate)))));
// query with wrong predicate
assertEquals(Sets.newHashSet(),
getSet(f.queryWithin(p1, new StatementConstraints().setPredicates(Collections.singleton(vf.createURI("other:pred"))))));
}
}
示例12: testCatchIllegalArgument
import org.openrdf.model.ValueFactory; //導入方法依賴的package包/類
public void testCatchIllegalArgument() throws Exception {
IConcept concept = con.addDesignation(
con.getObject("urn:test:concept"), IConcept.class);
ValueFactory vf = con.getValueFactory();
Resource subj = concept.getResource();
URI pred = vf.createURI("urn:test:time");
Literal lit = vf.createLiteral("noon", XMLSchema.DATETIME);
con.add(subj, pred, lit);
XMLGregorianCalendar zero = DatatypeFactory.newInstance().newXMLGregorianCalendar();
assertEquals(zero, concept.getTime());
}
示例13: testDcSearch
import org.openrdf.model.ValueFactory; //導入方法依賴的package包/類
@Test
public void testDcSearch() throws Exception {
// test a ring around dc
try (final GeoWaveGeoIndexer f = new GeoWaveGeoIndexer()) {
f.setConf(conf);
f.purge(conf);
final ValueFactory vf = new ValueFactoryImpl();
final Resource subject = vf.createURI("foo:subj");
final URI predicate = GeoConstants.GEO_AS_WKT;
final Value object = vf.createLiteral("Point(-77.03524 38.889468)", GeoConstants.XMLSCHEMA_OGC_WKT);
final Resource context = vf.createURI("foo:context");
final Statement statement = new ContextStatementImpl(subject, predicate, object, context);
f.storeStatement(convertStatement(statement));
f.flush();
final double[] IN = { -78, 39, -77, 39, -77, 38, -78, 38, -78, 39 };
final LinearRing r1 = gf.createLinearRing(new PackedCoordinateSequence.Double(IN, 2));
final Polygon p1 = gf.createPolygon(r1, new LinearRing[] {});
Assert.assertEquals(Sets.newHashSet(statement), getSet(f.queryWithin(p1, EMPTY_CONSTRAINTS)));
// test a ring outside the point
final double[] OUT = { -77, 39, -76, 39, -76, 38, -77, 38, -77, 39 };
final LinearRing rOut = gf.createLinearRing(new PackedCoordinateSequence.Double(OUT, 2));
final Polygon pOut = gf.createPolygon(rOut, new LinearRing[] {});
Assert.assertEquals(Sets.newHashSet(), getSet(f.queryWithin(pOut, EMPTY_CONSTRAINTS)));
}
}
示例14: setUp
import org.openrdf.model.ValueFactory; //導入方法依賴的package包/類
public void setUp() throws Exception {
ObjectRepositoryFactory orf = new ObjectRepositoryFactory();
SailRepository sail = new SailRepository(new MemoryStore());
sail.initialize();
repo = orf.createRepository(sail);
con = repo.getConnection();
ValueFactory vf = con.getValueFactory();
URI rel = vf.createURI(NS, "rel");
con.add(vf.createURI(NS, "copyOf"), rel, vf.createURI(NS, "copyOf"));
con.add(vf.createURI(NS, "renamedTo"), rel, vf.createLiteral("canonical"));
con.add(vf.createURI(NS, "alternative"), rel, vf.createLiteral("alternate"));
con.add(vf.createURI(NS, "describedBy"), rel, vf.createLiteral("describedby"));
con.add(vf.createURI(NS, "redirectsTo"), rel, vf.createURI(NS, "redirectsTo"));
}
示例15: populateSesame
import org.openrdf.model.ValueFactory; //導入方法依賴的package包/類
private void populateSesame(Repository testRepo) throws RepositoryException {
RepositoryConnection con = testRepo.getConnection();
ValueFactory f = testRepo.getValueFactory();
con.setNamespace("rdf", RDF_NS);
con.setNamespace("rdfs", RDFS_NS);
con.setNamespace("xsd", XSD_NS);
con.setNamespace("xsd", XSD_NS);
URI alice = f.createURI("http://example.org/people/alice");
URI bob = f.createURI("http://example.org/people/bob");
URI person = f.createURI("http://example.org/ontology/Person");
URI label = f.createURI(RDFS_NS, "label");
URI birthplace = f.createURI("http://example.org/ontology/birthplace");
Literal bobsName = f.createLiteral("Bob", "en");
Literal alicesName = f.createLiteral("Alice", "en");
Literal birthplaceLabel = f.createLiteral("birth place", "en");
Literal londonLabel = f.createLiteral("London", "en");
try {
con.add(birthplace, label, birthplaceLabel);
con.add(alice, RDF.TYPE, person);
con.add(alice, label, alicesName);
con.add(alice, birthplace, londonLabel);
con.add(bob, RDF.TYPE, person);
con.add(bob, label, bobsName);
con.add(bob, birthplace, londonLabel);
} finally {
con.close();
}
}