本文整理汇总了Java中org.eclipse.rdf4j.query.BindingSet.getValue方法的典型用法代码示例。如果您正苦于以下问题:Java BindingSet.getValue方法的具体用法?Java BindingSet.getValue怎么用?Java BindingSet.getValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.rdf4j.query.BindingSet
的用法示例。
在下文中一共展示了BindingSet.getValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testSPARQLQueryWithRuleset
import org.eclipse.rdf4j.query.BindingSet; //导入方法依赖的package包/类
@Test
public void testSPARQLQueryWithRuleset()
throws Exception {
String queryString = "select ?s ?p ?o { ?s ?p ?o } limit 100 ";
MarkLogicTupleQuery tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, queryString);
tupleQuery.setRulesets(SPARQLRuleset.RDFS_FULL);
TupleQueryResult results = tupleQuery.evaluate();
Assert.assertEquals(results.getBindingNames().get(0), "s");
Assert.assertEquals(results.getBindingNames().get(1), "p");
Assert.assertEquals(results.getBindingNames().get(2), "o");
BindingSet bindingSet = results.next();
Value sV = bindingSet.getValue("s");
Value pV = bindingSet.getValue("p");
Value oV = bindingSet.getValue("o");
Assert.assertEquals("http://semanticbible.org/ns/2006/NTNames#AttaliaGeodata", sV.stringValue());
Assert.assertEquals("http://semanticbible.org/ns/2006/NTNames#altitude", pV.stringValue());
Assert.assertEquals("0", oV.stringValue());
results.close();
}
示例2: testSPARQLQueryWithMultipleRulesets
import org.eclipse.rdf4j.query.BindingSet; //导入方法依赖的package包/类
@Test
public void testSPARQLQueryWithMultipleRulesets()
throws Exception {
String queryString = "select ?s ?p ?o { ?s ?p ?o } limit 100 ";
MarkLogicTupleQuery tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, queryString);
tupleQuery.setRulesets(SPARQLRuleset.RDFS_FULL,SPARQLRuleset.DOMAIN);
TupleQueryResult results = tupleQuery.evaluate();
Assert.assertEquals(results.getBindingNames().get(0), "s");
Assert.assertEquals(results.getBindingNames().get(1), "p");
Assert.assertEquals(results.getBindingNames().get(2), "o");
BindingSet bindingSet = results.next();
Value sV = bindingSet.getValue("s");
Value pV = bindingSet.getValue("p");
Value oV = bindingSet.getValue("o");
Assert.assertEquals("http://semanticbible.org/ns/2006/NTNames#AttaliaGeodata", sV.stringValue());
Assert.assertEquals("http://semanticbible.org/ns/2006/NTNames#altitude", pV.stringValue());
Assert.assertEquals("0", oV.stringValue());
results.close();
}
示例3: getModifiedDate
import org.eclipse.rdf4j.query.BindingSet; //导入方法依赖的package包/类
@Override
public Optional<Date> getModifiedDate(Resource cpt) {
Optional<Date> date = Optional.empty();
try (RepositoryConnection connect = triplestore.getConnection()) {
// read a dcterms:modified property on the concept
String queryString =
"PREFIX dcterms: <http://purl.org/dc/terms/> " +
"PREFIX skos: <http://www.w3.org/2004/02/skos/core#> " +
"select ?date where {<"+cpt+"> dcterms:modified ?date} ";
TupleQuery tupleQuery = connect.prepareTupleQuery(QueryLanguage.SPARQL,queryString);
try (TupleQueryResult res = tupleQuery.evaluate()) {
while (res.hasNext()) { // iterate over the result
BindingSet bindingSet = res.next();
if(bindingSet.getValue("date")!=null) {
date = Optional.of(((Literal)bindingSet.getValue("date")).calendarValue().toGregorianCalendar().getTime());
}
}
}
} catch (RepositoryException e) {
e.printStackTrace();
// return empty date
return date;
}
return date;
}
示例4: evaluateZeroLengthPath
import org.eclipse.rdf4j.query.BindingSet; //导入方法依赖的package包/类
/**
* Evaluate {@link ZeroLengthPath} query model nodes
* @param parent
* @param zlp
* @param bindings
*/
private void evaluateZeroLengthPath(BindingSetPipe parent, ZeroLengthPath zlp, BindingSet bindings) {
final Var subjectVar = zlp.getSubjectVar();
final Var objVar = zlp.getObjectVar();
final Var contextVar = zlp.getContextVar();
Value subj = subjectVar.getValue() == null ? bindings.getValue(subjectVar.getName()) : subjectVar.getValue();
Value obj = objVar.getValue() == null ? bindings.getValue(objVar.getName()) : objVar.getValue();
if (subj != null && obj != null) {
if (!subj.equals(obj)) {
try {
parent.push(null);
} catch (InterruptedException e) {
parent.handleException(e);
}
return;
}
}
//temporary solution using copy of the original iterator
//re-writing this to push model is a bit more complex task
HalyardStatementPatternEvaluation.enqueue(parent, new ZeroLengthPathIteration(parentStrategy, subjectVar, objVar, subj, obj, contextVar, bindings), zlp);
}
示例5: evaluate
import org.eclipse.rdf4j.query.BindingSet; //导入方法依赖的package包/类
/**
* Evaluate an {@link In} node
* @param node the node to evaluate
* @param bindings the set of named value bindings
* @return
* @throws ValueExprEvaluationException
* @throws QueryEvaluationException
*/
private Value evaluate(In node, BindingSet bindings) throws ValueExprEvaluationException, QueryEvaluationException {
Value leftValue = evaluate(node.getArg(), bindings);
// Result is false until a match has been found
boolean result = false;
// Use first binding name from tuple expr to compare values
String bindingName = node.getSubQuery().getBindingNames().iterator().next();
try (CloseableIteration<BindingSet, QueryEvaluationException> iter = parentStrategy.evaluate(node.getSubQuery(), bindings)) {
while (result == false && iter.hasNext()) {
BindingSet bindingSet = iter.next();
Value rightValue = bindingSet.getValue(bindingName);
result = leftValue == null && rightValue == null || leftValue != null
&& leftValue.equals(rightValue);
}
}
return BooleanLiteral.valueOf(result);
}
示例6: testJoins
import org.eclipse.rdf4j.query.BindingSet; //导入方法依赖的package包/类
@Test
public void testJoins() throws Exception {
addTestFile();
SPARQLParser parser = new SPARQLParser();
BindingSet bindings = new EmptyBindingSet();
String baseIRI = "http://example.org/bogus/";
try (SailConnection sc = getConnection()) {
CloseableIteration<? extends BindingSet, QueryEvaluationException> results;
int count;
String queryStr = "PREFIX : <urn:com.tinkerpop.blueprints.pgm.oupls.sail.test/>\n" +
"PREFIX foaf: <http://xmlns.com/foaf/0.1/>\n" +
"SELECT ?foaf WHERE {\n" +
" :ford foaf:knows ?friend .\n" +
" ?friend foaf:knows ?foaf .\n" +
"}";
ParsedQuery query = parser.parseQuery(queryStr, baseIRI);
results = sc.evaluate(query.getTupleExpr(), query.getDataset(), bindings, false);
count = 0;
while (results.hasNext()) {
count++;
BindingSet set = results.next();
IRI foaf = (IRI) set.getValue("foaf");
assertTrue(foaf.stringValue().startsWith("urn:com.tinkerpop.blueprints.pgm.oupls.sail.test/"));
}
results.close();
assertEquals(4, count);
}
}
示例7: testSPARQLQueryWithDefaultInferred
import org.eclipse.rdf4j.query.BindingSet; //导入方法依赖的package包/类
@Test
public void testSPARQLQueryWithDefaultInferred()
throws Exception {
String queryString = "select ?s ?p ?o { ?s ?p ?o } limit 2 ";
TupleQuery tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, queryString);
tupleQuery.setIncludeInferred(true);
TupleQueryResult results = tupleQuery.evaluate();
Assert.assertEquals(results.getBindingNames().get(0), "s");
Assert.assertEquals(results.getBindingNames().get(1), "p");
Assert.assertEquals(results.getBindingNames().get(2), "o");
BindingSet bindingSet = results.next();
Value sV = bindingSet.getValue("s");
Value pV = bindingSet.getValue("p");
Value oV = bindingSet.getValue("o");
Assert.assertEquals("http://semanticbible.org/ns/2006/NTNames#AttaliaGeodata", sV.stringValue());
Assert.assertEquals("http://semanticbible.org/ns/2006/NTNames#altitude", pV.stringValue());
Assert.assertEquals("0", oV.stringValue());
BindingSet bindingSet1 = results.next();
Value sV1 = bindingSet1.getValue("s");
Value pV1 = bindingSet1.getValue("p");
Value oV1 = bindingSet1.getValue("o");
Assert.assertEquals("http://semanticbible.org/ns/2006/NTNames#BabylonGeodata", sV1.stringValue());
Assert.assertEquals("http://semanticbible.org/ns/2006/NTNames#altitude", pV1.stringValue());
Assert.assertEquals("0", oV1.stringValue());
results.close();
}
示例8: testSPARQLQueryWithPagination
import org.eclipse.rdf4j.query.BindingSet; //导入方法依赖的package包/类
@Test
public void testSPARQLQueryWithPagination()
throws Exception {
try{
for(int i=0; i<101; i++){
String queryString = "select ?s ?p ?o { ?s ?p ?o } limit 100 ";
MarkLogicTupleQuery tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, queryString);
TupleQueryResult results = tupleQuery.evaluate(3, 1);
Assert.assertEquals(results.getBindingNames().get(0), "s");
Assert.assertEquals(results.getBindingNames().get(1), "p");
Assert.assertEquals(results.getBindingNames().get(2), "o");
BindingSet bindingSet = results.next();
Value sV = bindingSet.getValue("s");
Value pV = bindingSet.getValue("p");
Value oV = bindingSet.getValue("o");
Assert.assertEquals("http://semanticbible.org/ns/2006/NTNames#BethanyBeyondtheJordanGeodata", sV.stringValue());
Assert.assertEquals("http://semanticbible.org/ns/2006/NTNames#altitude", pV.stringValue());
Assert.assertEquals("0", oV.stringValue());
Assert.assertFalse(results.hasNext());
results.close();
}
}
catch(Exception ex)
{
throw ex;
}
finally {
conn.close();
Thread.sleep(1000);
}
}
示例9: testSPARQLQueryWithNullRulesets
import org.eclipse.rdf4j.query.BindingSet; //导入方法依赖的package包/类
@Test
public void testSPARQLQueryWithNullRulesets()
throws Exception {
String queryString = "select ?s ?p ?o { ?s ?p ?o } limit 100 ";
MarkLogicTupleQuery tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, queryString);
tupleQuery.setRulesets(SPARQLRuleset.RDFS_FULL,null);
tupleQuery.setRulesets(null);
Assert.assertTrue(tupleQuery.getRulesets() == null);
TupleQueryResult results = tupleQuery.evaluate();
Assert.assertEquals(results.getBindingNames().get(0), "s");
Assert.assertEquals(results.getBindingNames().get(1), "p");
Assert.assertEquals(results.getBindingNames().get(2), "o");
BindingSet bindingSet = results.next();
Value sV = bindingSet.getValue("s");
Value pV = bindingSet.getValue("p");
Value oV = bindingSet.getValue("o");
Assert.assertEquals("http://semanticbible.org/ns/2006/NTNames#AttaliaGeodata", sV.stringValue());
Assert.assertEquals("http://semanticbible.org/ns/2006/NTNames#altitude", pV.stringValue());
Assert.assertEquals("0", oV.stringValue());
results.close();
}
示例10: testPrepareQuery2
import org.eclipse.rdf4j.query.BindingSet; //导入方法依赖的package包/类
@Test
public void testPrepareQuery2() throws Exception {
Reader ir = new BufferedReader(new InputStreamReader(
MarkLogicRepositoryConnectionTest.class.getResourceAsStream(TEST_DIR_PREFIX + "property-paths.ttl")));
testAdminCon.add(ir, "", RDFFormat.TURTLE, (Resource) null);
StringBuilder queryBuilder = new StringBuilder(128);
queryBuilder.append(" prefix : <http://learningsparql.com/ns/papers#> ");
queryBuilder.append(" prefix c: <http://learningsparql.com/ns/citations#>");
queryBuilder.append(" SELECT ?s");
queryBuilder.append(" WHERE { ");
queryBuilder.append(" ?s ^c:cites :paperK2 . ");
queryBuilder.append(" FILTER (?s != :paperK2)");
queryBuilder.append(" } ");
queryBuilder.append(" ORDER BY ?s ");
Query query = testAdminCon.prepareQuery(queryBuilder.toString());
query.setBinding("whatcode", vf.createLiteral("33333"));
TupleQueryResult result = null;
if (query instanceof TupleQuery) {
result = ((TupleQuery) query).evaluate();
}
try {
assertThat(result, is(notNullValue()));
while (result.hasNext()) {
BindingSet solution = result.next();
assertThat(solution.hasBinding("s"), is(equalTo(true)));
Value totalResult = solution.getValue("s");
Assert.assertEquals(vf.createIRI("http://learningsparql.com/ns/papers#paperJ"), totalResult);
}
} finally {
result.close();
}
}
示例11: getOriginalQueryString
import org.eclipse.rdf4j.query.BindingSet; //导入方法依赖的package包/类
private static String getOriginalQueryString(BindingSet b) {
if (b==null)
return null;
Value q = b.getValue(FedXSailRepositoryConnection.BINDING_ORIGINAL_QUERY);
if (q!=null)
return q.stringValue();
return null;
}
示例12: getOriginalQueryType
import org.eclipse.rdf4j.query.BindingSet; //导入方法依赖的package包/类
private static QueryType getOriginalQueryType(BindingSet b) {
if (b==null)
return null;
Value q = b.getValue(FedXSailRepositoryConnection.BINDING_ORIGINAL_QUERY_TYPE);
if (q!=null)
return QueryType.valueOf(q.stringValue());
return null;
}
示例13: toValue
import org.eclipse.rdf4j.query.BindingSet; //导入方法依赖的package包/类
protected static Value toValue(Var var, BindingSet bindings) {
if (var.hasValue())
return var.getValue();
if (bindings.hasBinding(var.getName()))
return bindings.getValue(var.getName());
return null;
}
示例14: getVarValue
import org.eclipse.rdf4j.query.BindingSet; //导入方法依赖的package包/类
/**
* Gets a value from a {@code Var} if it has a {@code Value}. If it does not then the method will attempt to get it
* from the bindings using the name of the Var
* @param var
* @param bindings
* @return the matching {@code Value} or {@code null} if var is {@code null}
*/
private static Value getVarValue(Var var, BindingSet bindings) {
if (var == null) {
return null;
} else if (var.hasValue()) {
return var.getValue();
} else {
return bindings.getValue(var.getName());
}
}
示例15: testSPARQLQuery
import org.eclipse.rdf4j.query.BindingSet; //导入方法依赖的package包/类
@Test
public void testSPARQLQuery()
throws Exception {
try {
for (int i=0; i<101;i++){
String queryString = "select * { ?s ?p ?o } limit 2 ";
TupleQuery tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, queryString);
TupleQueryResult results = tupleQuery.evaluate();
Assert.assertEquals(results.getBindingNames().get(0), "s");
Assert.assertEquals(results.getBindingNames().get(1), "p");
Assert.assertEquals(results.getBindingNames().get(2), "o");
BindingSet bindingSet = results.next();
Value sV = bindingSet.getValue("s");
Value pV = bindingSet.getValue("p");
Value oV = bindingSet.getValue("o");
Assert.assertEquals("http://semanticbible.org/ns/2006/NTNames#AttaliaGeodata", sV.stringValue());
Assert.assertEquals("http://semanticbible.org/ns/2006/NTNames#altitude", pV.stringValue());
Assert.assertEquals("0", oV.stringValue());
BindingSet bindingSet1 = results.next();
Value sV1 = bindingSet1.getValue("s");
Value pV1 = bindingSet1.getValue("p");
Value oV1 = bindingSet1.getValue("o");
Assert.assertEquals("http://semanticbible.org/ns/2006/NTNames#BabylonGeodata", sV1.stringValue());
Assert.assertEquals("http://semanticbible.org/ns/2006/NTNames#altitude", pV1.stringValue());
Assert.assertEquals("0", oV1.stringValue());
results.close();
}
}
catch(Exception ex)
{
throw ex;
}
finally {
conn.close();
Thread.sleep(1000);
}
}