本文整理汇总了Java中org.openrdf.model.impl.ValueFactoryImpl.getInstance方法的典型用法代码示例。如果您正苦于以下问题:Java ValueFactoryImpl.getInstance方法的具体用法?Java ValueFactoryImpl.getInstance怎么用?Java ValueFactoryImpl.getInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openrdf.model.impl.ValueFactoryImpl
的用法示例。
在下文中一共展示了ValueFactoryImpl.getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ValueOfMarshall
import org.openrdf.model.impl.ValueFactoryImpl; //导入方法依赖的package包/类
public ValueOfMarshall(ValueFactory vf, Class<T> type)
throws NoSuchMethodException {
this.vf = vf;
ValueFactoryImpl uf = ValueFactoryImpl.getInstance();
this.datatype = uf.createURI("java:", type.getName());
try {
this.valueOfMethod = type.getDeclaredMethod("valueOf",
new Class[] { String.class });
if (!Modifier.isStatic(valueOfMethod.getModifiers()))
throw new NoSuchMethodException("valueOf Method is not static");
if (!type.equals(valueOfMethod.getReturnType()))
throw new NoSuchMethodException("Invalid return type");
} catch (NoSuchMethodException e) {
try {
this.valueOfMethod = type.getDeclaredMethod("getInstance",
new Class[] { String.class });
if (!Modifier.isStatic(valueOfMethod.getModifiers()))
throw new NoSuchMethodException(
"getInstance Method is not static");
if (!type.equals(valueOfMethod.getReturnType()))
throw new NoSuchMethodException("Invalid return type");
} catch (NoSuchMethodException e2) {
throw e;
}
}
}
示例2: makeValue
import org.openrdf.model.impl.ValueFactoryImpl; //导入方法依赖的package包/类
private static Value makeValue(final String valueString, final URI typeURI) {
// Convert the String Value into a Value.
final ValueFactory valueFactory = ValueFactoryImpl.getInstance();
if (typeURI.equals(XMLSchema.ANYURI)) {
return valueFactory.createURI(valueString);
} else {
return valueFactory.createLiteral(valueString, typeURI);
}
}
示例3: partialQuery_Test
import org.openrdf.model.impl.ValueFactoryImpl; //导入方法依赖的package包/类
@Test
public void partialQuery_Test() throws Exception {
final Sail sail = RyaSailFactory.getInstance(conf);
SailRepositoryConnection conn = new SailRepository(sail).getConnection();
conn.begin();
try(MongoEntityIndexer indexer = new MongoEntityIndexer()) {
indexer.setConf(conf);
indexer.init();
setupTypes(indexer);
addStatements(conn);
conn.commit();
final String query = "SELECT * WHERE { " +
"<urn:george> <" + RDF.TYPE + "> <urn:person> ."+
"<urn:george> <urn:name> ?name . " +
"<urn:george> <urn:eye> ?eye . " +
"}";
final TupleQueryResult rez = conn.prepareTupleQuery(QueryLanguage.SPARQL, query).evaluate();
final Set<BindingSet> results = new HashSet<>();
while(rez.hasNext()) {
final BindingSet bs = rez.next();
System.out.println(bs);
results.add(bs);
}
final ValueFactory vf = ValueFactoryImpl.getInstance();
final MapBindingSet expected = new MapBindingSet();
//expected.addBinding("name", vf.createURI("http://www.w3.org/2001/SMLSchema#string", "George"));
expected.addBinding("name", vf.createLiteral("George"));
expected.addBinding("eye", vf.createLiteral("blue"));
assertEquals(1, results.size());
assertEquals(expected, results.iterator().next());
} finally {
conn.close();
}
}
示例4: evaluate_constantSubject
import org.openrdf.model.impl.ValueFactoryImpl; //导入方法依赖的package包/类
@Test
public void evaluate_constantSubject() throws Exception {
final EntityStorage storage = new MongoEntityStorage(super.getMongoClient(), "testDB");
final ValueFactory vf = ValueFactoryImpl.getInstance();
final RyaURI subject = new RyaURI("urn:SSN:111-11-1111");
final Entity entity = Entity.builder()
.setSubject(subject)
.setExplicitType(PERSON_TYPE.getId())
.setProperty(PERSON_TYPE.getId(), new Property(new RyaURI("urn:age"), RdfToRyaConversions.convertLiteral(vf.createLiteral(20))))
.setProperty(PERSON_TYPE.getId(), new Property(new RyaURI("urn:eye"), RdfToRyaConversions.convertLiteral(vf.createLiteral("blue"))))
.setProperty(PERSON_TYPE.getId(), new Property(new RyaURI("urn:name"), RdfToRyaConversions.convertLiteral(vf.createLiteral("Bob"))))
.build();
storage.create(entity);
// A set of patterns that match a sepecific Entity subject.
final List<StatementPattern> patterns = getSPs(
"SELECT * WHERE { " +
"<urn:SSN:111-11-1111> <" + RDF.TYPE + "> <urn:person> ."+
"<urn:SSN:111-11-1111> <urn:age> ?age . " +
"<urn:SSN:111-11-1111> <urn:eye> ?eye . " +
"<urn:SSN:111-11-1111> <urn:name> ?name . " +
"}");
final EntityQueryNode node = new EntityQueryNode(PERSON_TYPE, patterns, storage);
final CloseableIteration<BindingSet, QueryEvaluationException> rez = node.evaluate(new MapBindingSet());
final MapBindingSet expected = new MapBindingSet();
expected.addBinding("age", vf.createLiteral("20"));
expected.addBinding("eye", vf.createLiteral("blue"));
expected.addBinding("name", vf.createLiteral("Bob"));
while(rez.hasNext()) {
assertEquals(expected, rez.next());
break;
}
}
示例5: evaluate_constantObject
import org.openrdf.model.impl.ValueFactoryImpl; //导入方法依赖的package包/类
@Test
public void evaluate_constantObject() throws Exception {
final EntityStorage storage = new MongoEntityStorage(super.getMongoClient(), "testDB");
final ValueFactory vf = ValueFactoryImpl.getInstance();
final RyaURI subject = new RyaURI("urn:SSN:111-11-1111");
final Entity entity = Entity.builder()
.setSubject(subject)
.setExplicitType(PERSON_TYPE.getId())
.setProperty(PERSON_TYPE.getId(), new Property(new RyaURI("urn:age"), RdfToRyaConversions.convertLiteral(vf.createLiteral(20))))
.setProperty(PERSON_TYPE.getId(), new Property(new RyaURI("urn:eye"), RdfToRyaConversions.convertLiteral(vf.createLiteral("blue"))))
.setProperty(PERSON_TYPE.getId(), new Property(new RyaURI("urn:name"), RdfToRyaConversions.convertLiteral(vf.createLiteral("Bob"))))
.build();
storage.create(entity);
// A set of patterns that match a sepecific Entity subject.
final List<StatementPattern> patterns = getSPs(
"SELECT * WHERE { " +
"<urn:SSN:111-11-1111> <" + RDF.TYPE + "> <urn:person> ."+
"<urn:SSN:111-11-1111> <urn:age> ?age . " +
"<urn:SSN:111-11-1111> <urn:eye> \"blue\" . " +
"<urn:SSN:111-11-1111> <urn:name> ?name . " +
"}");
final EntityQueryNode node = new EntityQueryNode(PERSON_TYPE, patterns, storage);
final CloseableIteration<BindingSet, QueryEvaluationException> rez = node.evaluate(new MapBindingSet());
final MapBindingSet expected = new MapBindingSet();
expected.addBinding("age", vf.createLiteral("20"));
expected.addBinding("-const-blue", vf.createLiteral("blue"));
expected.addBinding("name", vf.createLiteral("Bob"));
while(rez.hasNext()) {
assertEquals(expected, rez.next());
break;
}
}
示例6: testTurtle
import org.openrdf.model.impl.ValueFactoryImpl; //导入方法依赖的package包/类
@Test
public void testTurtle() throws Exception {
final String visibilities = "a|b|c";
// Load the statements into the kafka topic.
try(final Producer<?, VisibilityStatement> producer =
KafkaTestUtil.makeProducer(rule, StringSerializer.class, VisibilityStatementSerializer.class)) {
final KafkaLoadStatements command = new KafkaLoadStatements(rule.getKafkaTopicName(), producer);
command.fromFile(TURTLE_FILE, visibilities);
}
// Read a VisibilityBindingSets from the test topic.
final List<VisibilityStatement> read;// = new ArrayList<>();
try(Consumer<String, VisibilityStatement> consumer =
KafkaTestUtil.fromStartConsumer(rule, StringDeserializer.class, VisibilityStatementDeserializer.class)) {
consumer.subscribe(Arrays.asList(rule.getKafkaTopicName()));
read = KafkaTestUtil.pollForResults(500, 6, 3, consumer);
}
final List<VisibilityStatement> original = new ArrayList<>();
final ValueFactory VF = ValueFactoryImpl.getInstance();
original.add(new VisibilityStatement(
VF.createStatement(VF.createURI("http://example#alice"), VF.createURI("http://example#talksTo"), VF.createURI("http://example#bob")),
visibilities));
original.add(new VisibilityStatement(
VF.createStatement(VF.createURI("http://example#bob"), VF.createURI("http://example#talksTo"), VF.createURI("http://example#charlie")),
visibilities));
original.add(new VisibilityStatement(
VF.createStatement(VF.createURI("http://example#charlie"), VF.createURI("http://example#likes"), VF.createURI("http://example#icecream")),
visibilities));
// Show the written statement matches the read one.
assertEquals(original, read);
}
示例7: performNodeBindings
import org.openrdf.model.impl.ValueFactoryImpl; //导入方法依赖的package包/类
private void performNodeBindings(final Map<String, Node> bindings, final Query query) {
ValueFactory valueFactory = ValueFactoryImpl.getInstance();
for (String i : bindings.keySet()) {
Node n = bindings.get(i);
if (n != null) {
query.setBinding(i, getSesameValue(n, valueFactory));
}
}
}
示例8: export
import org.openrdf.model.impl.ValueFactoryImpl; //导入方法依赖的package包/类
@Override
public Resource export(Graph model) {
ValueFactoryImpl vf = ValueFactoryImpl.getInstance();
BNode implNode = vf.createBNode();
if (type != null) {
model.add(implNode, this.typePredicate, vf.createLiteral(type));
}
return implNode;
}
示例9: testMixinName
import org.openrdf.model.impl.ValueFactoryImpl; //导入方法依赖的package包/类
public void testMixinName() throws Exception {
RoleMapper rm = new RoleMapper();
ValueFactoryImpl vf = ValueFactoryImpl.getInstance();
rm.addConcept(MixedClassName.class, vf.createURI("urn:MixedClass"));
Collection<Class<?>> roles = rm.findRoles(vf.createURI("urn:MixedClass"));
assertTrue(roles.contains(BehaviourClass.class));
}
示例10: exportAssocation
import org.openrdf.model.impl.ValueFactoryImpl; //导入方法依赖的package包/类
private void exportAssocation(Resource subj, Map<Class<?>, List<URI>> assocation,
URI relation, Graph model) {
ValueFactory vf = ValueFactoryImpl.getInstance();
for (Map.Entry<Class<?>, List<URI>> e : assocation.entrySet()) {
URI name = vf.createURI(JAVA_NS, e.getKey().getName());
model.add(subj, relation, name);
if (e.getValue() != null) {
for (URI value : e.getValue()) {
model.add(name, KNOWN_AS, value);
}
}
}
}
示例11: export
import org.openrdf.model.impl.ValueFactoryImpl; //导入方法依赖的package包/类
@Override
public Resource export(Graph model) {
ValueFactory vf = ValueFactoryImpl.getInstance();
Resource self = super.export(model);
model.add(self, USE_TYPE_STATS, vf.createLiteral(this.useTypeStats));
return self;
}
示例12: evaluate_variableSubject
import org.openrdf.model.impl.ValueFactoryImpl; //导入方法依赖的package包/类
@Test
public void evaluate_variableSubject() throws Exception {
final EntityStorage storage = new MongoEntityStorage(super.getMongoClient(), "testDB");
final ValueFactory vf = ValueFactoryImpl.getInstance();
RyaURI subject = new RyaURI("urn:SSN:111-11-1111");
final Entity bob = Entity.builder()
.setSubject(subject)
.setExplicitType(PERSON_TYPE.getId())
.setProperty(PERSON_TYPE.getId(), new Property(new RyaURI("urn:age"), RdfToRyaConversions.convertLiteral(vf.createLiteral(20))))
.setProperty(PERSON_TYPE.getId(), new Property(new RyaURI("urn:eye"), RdfToRyaConversions.convertLiteral(vf.createLiteral("blue"))))
.setProperty(PERSON_TYPE.getId(), new Property(new RyaURI("urn:name"), RdfToRyaConversions.convertLiteral(vf.createLiteral("Bob"))))
.build();
subject = new RyaURI("urn:SSN:222-22-2222");
final Entity fred = Entity.builder()
.setSubject(subject)
.setExplicitType(PERSON_TYPE.getId())
.setProperty(PERSON_TYPE.getId(), new Property(new RyaURI("urn:age"), RdfToRyaConversions.convertLiteral(vf.createLiteral(25))))
.setProperty(PERSON_TYPE.getId(), new Property(new RyaURI("urn:eye"), RdfToRyaConversions.convertLiteral(vf.createLiteral("brown"))))
.setProperty(PERSON_TYPE.getId(), new Property(new RyaURI("urn:name"), RdfToRyaConversions.convertLiteral(vf.createLiteral("Fred"))))
.build();
storage.create(bob);
storage.create(fred);
// A set of patterns that match a sepecific Entity subject.
final List<StatementPattern> patterns = getSPs(
"SELECT * WHERE { " +
"?ssn <" + RDF.TYPE + "> <urn:person> ."+
"?ssn <urn:age> ?age . " +
"?ssn <urn:eye> ?eye . " +
"?ssn <urn:name> ?name . " +
"}");
final EntityQueryNode node = new EntityQueryNode(PERSON_TYPE, patterns, storage);
final CloseableIteration<BindingSet, QueryEvaluationException> rez = node.evaluate(new MapBindingSet());
final List<BindingSet> expectedBindings = new ArrayList<>();
final MapBindingSet expectedBob = new MapBindingSet();
expectedBob.addBinding("age", vf.createLiteral("20"));
expectedBob.addBinding("eye", vf.createLiteral("blue"));
expectedBob.addBinding("name", vf.createLiteral("Bob"));
final MapBindingSet expectedFred = new MapBindingSet();
expectedFred.addBinding("age", vf.createLiteral("25"));
expectedFred.addBinding("eye", vf.createLiteral("brown"));
expectedFred.addBinding("name", vf.createLiteral("Fred"));
expectedBindings.add(expectedBob);
expectedBindings.add(expectedFred);
while(rez.hasNext()) {
final BindingSet bs = rez.next();
assertTrue(expectedBindings.contains(bs));
}
}
示例13: shortParams
import org.openrdf.model.impl.ValueFactoryImpl; //导入方法依赖的package包/类
@Test
public void shortParams() throws Exception {
// Load a file of statements into Kafka.
final String visibilities = "a|b|c";
final String[] args = new String[] {
"-r", "" + ryaInstance,
"-i", kafka.getKafkaHostname(),
"-p", kafka.getKafkaPort(),
"-f", TURTLE_FILE.toString(),
"-v", visibilities
};
// Load the file of statements into the Statements topic.
new LoadStatementsCommand().execute(args);
// Show that the statements were loaded into the topic.
final List<VisibilityStatement> read = new ArrayList<>();
try(final Consumer<String, VisibilityStatement> consumer =
KafkaTestUtil.fromStartConsumer(kafka, StringDeserializer.class, VisibilityStatementDeserializer.class)) {
// Subscribe for messages.
consumer.subscribe( Arrays.asList(KafkaTopics.statementsTopic(ryaInstance)) );
// Read the messages and extract their values.
final Iterator<ConsumerRecord<String, VisibilityStatement>> iter = consumer.poll(3000).iterator();
while(iter.hasNext()) {
read.add( iter.next().value() );
}
}
final ValueFactory VF = ValueFactoryImpl.getInstance();
final List<VisibilityStatement> expected = new ArrayList<>();
expected.add(new VisibilityStatement(
VF.createStatement(VF.createURI("http://example#alice"), VF.createURI("http://example#talksTo"), VF.createURI("http://example#bob")),
visibilities));
expected.add(new VisibilityStatement(
VF.createStatement(VF.createURI("http://example#bob"), VF.createURI("http://example#talksTo"), VF.createURI("http://example#charlie")),
visibilities));
expected.add(new VisibilityStatement(
VF.createStatement(VF.createURI("http://example#charlie"), VF.createURI("http://example#likes"), VF.createURI("http://example#icecream")),
visibilities));
// Show the written statements matches the read ones.
assertEquals(expected, read);
}
示例14: transform
import org.openrdf.model.impl.ValueFactoryImpl; //导入方法依赖的package包/类
@Override
public final boolean transform(final TaskInfo taskInfo,
final JsonNode subtask,
final HashMap<String, String> results) {
boolean result = true;
// Get the metadata values to be inserted.
Version version = taskInfo.getVersion();
// Use the release date as it is. As it may be
// YYYY, YYYY-MM, or YYYY-MM-DD, can't use a date
// formatter.
String issuedDate = version.getReleaseDate();
String versionTitle = version.getTitle();
// Construct bindings for SPARQL Update.
ValueFactory factory = ValueFactoryImpl.getInstance();
HashMap<String, Value> bindings = new HashMap<String, Value>();
if (issuedDate != null) {
bindings.put("issuedDate", factory.createLiteral(issuedDate));
result = SesameTransformUtils.runUpdate(taskInfo, subtask, results,
INSERT_DCTERMS_ISSUED_METADATA_UPDATE, bindings);
if (!result) {
// Failure applying the Update. Stop here.
return false;
}
}
if (versionTitle != null) {
// Reset bindings and apply the version title Update.
bindings.clear();
bindings.put("versionTitle", factory.createLiteral(versionTitle));
result = SesameTransformUtils.runUpdate(taskInfo, subtask, results,
INSERT_OWL_VERSIONINFO_METADATA_UPDATE, bindings);
if (!result) {
// Failure applying the Update. Stop here.
return false;
}
}
/* Future work: Add ADMS status. The problem is, that the
* publication workflow is not so great, so metadata injection
* doesn't happen when the status changes. So once set, always
* set with the same value. If/when publication workflow is
* improved, uncomment this.
*/
/*
String versionStatus = admsStatusMap.get(version.getStatus());
if (versionStatus != null) {
// Reset bindings and apply the ADMS status Update.
bindings.clear();
bindings.put("versionStatus", factory.createURI(versionStatus));
return SesameTransformUtils.runUpdate(taskInfo, subtask, results,
INSERT_ADMS_STATUS_METADATA_UPDATE, bindings);
}
*/
return result;
}
示例15: entitiesFor
import org.openrdf.model.impl.ValueFactoryImpl; //导入方法依赖的package包/类
private List<Entity> entitiesFor(String identifier) {
ValueFactoryImpl vf = ValueFactoryImpl.getInstance();
Collection<Statement> statements = asList(
vf.createStatement(
vf.createURI("http://" + identifier),
vf.createURI("http://predicate/a"),
vf.createLiteral("object value a")
),
vf.createStatement(
vf.createURI("http://" + identifier),
vf.createURI("http://predicate/b"),
vf.createLiteral("object value b")
),
vf.createStatement(
vf.createURI("http://" + identifier),
vf.createURI("http://predicate/c"),
vf.createLiteral("object value c")
)
);
Resource[] graphs = new Resource[]{vf.createURI("http://foo/graph/" + identifier)};
Entity entity = new Entity(statements, graphs);
Collection<Statement> graphStatements = asList(
vf.createStatement(
vf.createURI("http://foo/graph/" + identifier),
vf.createURI("http://graph/timestamp"),
vf.createLiteral(System.currentTimeMillis())
),
vf.createStatement(
vf.createURI("http://foo/graph/" + identifier),
vf.createURI("http://graph/version"),
vf.createLiteral("the graph version")
)
);
Resource[] graphContext = new Resource[]{vf.createURI("http://graph/meta")};
Entity entity1 = new Entity(graphStatements, graphContext);
return asList(entity, entity1);
}