本文整理汇总了Java中org.eclipse.rdf4j.query.Binding类的典型用法代码示例。如果您正苦于以下问题:Java Binding类的具体用法?Java Binding怎么用?Java Binding使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Binding类属于org.eclipse.rdf4j.query包,在下文中一共展示了Binding类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: serialize
import org.eclipse.rdf4j.query.Binding; //导入依赖的package包/类
@Override
public void serialize(@NonNull TupleQueryResult tupleQueryResult,
@NonNull JsonGenerator jsonGenerator, SerializerProvider serializerProvider)
throws IOException {
writeStart(jsonGenerator);
while (tupleQueryResult.hasNext()) {
writeStartItem(jsonGenerator);
BindingSet bindingSet = tupleQueryResult.next();
for (Binding binding : bindingSet) {
jsonGenerator.writeObjectField(binding.getName(), serializeValue(binding.getValue()));
}
writeEndItem(jsonGenerator);
}
writeEnd(jsonGenerator);
}
示例2: select
import org.eclipse.rdf4j.query.Binding; //导入依赖的package包/类
@Override
public CloseableIteration<BindingSet, QueryEvaluationException> select(Service service, Set<String> projectionVars, BindingSet bindings, String baseUri) throws QueryEvaluationException {
RepositoryConnection conn = endpoint.getConn();
try {
TupleQuery query = conn.prepareTupleQuery(QueryLanguage.SPARQL, service.getSelectQueryString(projectionVars), baseUri);
Iterator<Binding> bIter = bindings.iterator();
while (bIter.hasNext()) {
Binding b = bIter.next();
if (service.getServiceVars().contains(b.getName()))
query.setBinding(b.getName(), b.getValue());
}
TupleQueryResult qRes = query.evaluate();
return new InsertBindingsIteration(qRes, bindings);
} catch(Throwable e) {
throw new QueryEvaluationException(e);
} finally {
conn.close();
}
}
示例3: ask
import org.eclipse.rdf4j.query.Binding; //导入依赖的package包/类
@Override
public boolean ask(Service service, BindingSet bindings, String baseUri) throws QueryEvaluationException {
RepositoryConnection conn = endpoint.getConn();
try {
BooleanQuery query = conn.prepareBooleanQuery(QueryLanguage.SPARQL, service.getAskQueryString(), baseUri);
Iterator<Binding> bIter = bindings.iterator();
while (bIter.hasNext()) {
Binding b = bIter.next();
if (service.getServiceVars().contains(b.getName()))
query.setBinding(b.getName(), b.getValue());
}
return query.evaluate();
} catch(Throwable e) {
throw new QueryEvaluationException(e);
} finally {
conn.close();
}
}
示例4: removeStatement
import org.eclipse.rdf4j.query.Binding; //导入依赖的package包/类
@Override
public void removeStatement(UpdateContext op, Resource subj, IRI pred, Value obj, Resource... contexts) throws SailException {
BindingSet bs;
Binding b;
Value v;
long timestamp = (op != null && (bs = op.getBindingSet()) != null && (b = bs.getBinding(TIMESTAMP_CALLBACK_BINDING_NAME)) != null) ? ((Literal) b.getValue()).longValue() : System.currentTimeMillis();
try {
for (Resource ctx : normalizeContexts(contexts)) {
for (KeyValue kv : HalyardTableUtils.toKeyValues(subj, pred, obj, ctx, true, timestamp)) { //calculate the kv's corresponding to the quad (or triple)
delete(kv);
}
}
} catch (IOException e) {
throw new SailException(e);
}
}
示例5: evaluate
import org.eclipse.rdf4j.query.Binding; //导入依赖的package包/类
@Override
public CloseableIteration<? extends BindingSet, QueryEvaluationException> evaluate(TupleExpr tupleExpr, Dataset dataset, BindingSet bindings, boolean includeInferred) throws SailException {
Binding b = bindings.getBinding(TIMESTAMP_CALLBACK_BINDING_NAME);
final TimestampCallbackBinding timestampBinding = (b instanceof TimestampCallbackBinding) ? (TimestampCallbackBinding) b : null;
CloseableIteration<? extends BindingSet, QueryEvaluationException> iter = super.evaluate(tupleExpr, dataset, bindings, includeInferred);
//push back the actual timestamp binding to the callback binding if requested
if (timestampBinding != null) {
iter = new FilterIteration<BindingSet, QueryEvaluationException>(iter) {
@Override
protected boolean accept(BindingSet bindings) throws QueryEvaluationException {
Binding b = bindings.getBinding(TIMESTAMP_BINDING_NAME);
//push back actual time if the timestamp binding is not provided
timestampBinding.v = b == null ? SimpleValueFactory.getInstance().createLiteral(System.currentTimeMillis()) : b.getValue();
return true;
}
};
}
return iter;
}
示例6: configureBindingSetWithValue
import org.eclipse.rdf4j.query.Binding; //导入依赖的package包/类
void configureBindingSetWithValue(BindingSet bindingSet, String value) {
Iterator<Binding> iterator = mock(Iterator.class);
when(bindingSet.iterator()).thenReturn(iterator);
ValueFactory factory = SimpleValueFactory.getInstance();
Binding binding = mock(Binding.class);
when(iterator.hasNext()).thenReturn(true, false);
when(iterator.next()).thenReturn(binding);
when(binding.getName()).thenReturn("beer");
when(binding.getValue()).thenReturn(factory.createLiteral(value));
}
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:12,代码来源:SparqlResultsTupleEntityWriterTestBase.java
示例7: getSPARQLBindings
import org.eclipse.rdf4j.query.Binding; //导入依赖的package包/类
/**
* Converts RDF4J BindingSet to java client api SPARQLBindings
*
* @param bindings
* @return
*/
protected SPARQLBindings getSPARQLBindings(SPARQLQueryBindingSet bindings) {
SPARQLBindings sps = new SPARQLBindingsImpl();
for (Binding binding : bindings) {
sps.bind(binding.getName(), binding.getValue().stringValue());
}
return sps;
}
示例8: evaluateProjectionWithBindings
import org.eclipse.rdf4j.query.Binding; //导入依赖的package包/类
/**
* Evaluate a projection containing additional values, e.g. set from a filter expression
*
* @return
* @throws QueryEvaluationException
*/
public CloseableIteration<BindingSet, QueryEvaluationException> evaluateProjectionWithBindings(ProjectionWithBindings projection, BindingSet bindings) throws QueryEvaluationException {
QueryBindingSet actualBindings = new QueryBindingSet(bindings);
for (Binding b : projection.getAdditionalBindings())
actualBindings.addBinding(b);
return evaluate((Projection)projection, actualBindings);
}
示例9: convert
import org.eclipse.rdf4j.query.Binding; //导入依赖的package包/类
@Override
protected BindingSet convert(BindingSet bIn) {
int bIndex = -1;
Iterator<Binding> bIter = bIn.iterator();
while (bIter.hasNext()) {
Binding b = bIter.next();
String name = b.getName();
bIndex = Integer.parseInt(name.substring(name.lastIndexOf("_")+1));
}
return bindings.get(bIndex);
}
示例10: convert
import org.eclipse.rdf4j.query.Binding; //导入依赖的package包/类
@Override
protected BindingSet convert(BindingSet bIn) throws QueryEvaluationException {
QueryBindingSet res = new QueryBindingSet();
int bIndex = Integer.parseInt(bIn.getBinding(INDEX_BINDING_NAME).getValue().stringValue());
Iterator<Binding> bIter = bIn.iterator();
while (bIter.hasNext()) {
Binding b = bIter.next();
if (b.getName().equals(INDEX_BINDING_NAME))
continue;
res.addBinding(b);
}
for (Binding bs : bindings.get(bIndex))
res.setBinding(bs);
return res;
}
示例11: convert
import org.eclipse.rdf4j.query.Binding; //导入依赖的package包/类
@Override
protected BindingSet convert(BindingSet bIn) {
QueryBindingSet res = new QueryBindingSet();
int bIndex = -1;
Iterator<Binding> bIter = bIn.iterator();
while (bIter.hasNext()) {
Binding b = bIter.next();
String name = b.getName();
bIndex = Integer.parseInt(name.substring(name.lastIndexOf("_")+1));
res.addBinding(name.substring(0, name.lastIndexOf("_")), b.getValue());
}
res.addAll( bindings.get(bIndex));
return res;
}
示例12: calcKey
import org.eclipse.rdf4j.query.Binding; //导入依赖的package包/类
private BindingSet calcKey(BindingSet bindings, Set<String> commonVars) {
QueryBindingSet q = new QueryBindingSet();
for (String varName : commonVars) {
Binding b = bindings.getBinding(varName);
if (b != null) {
q.addBinding(b);
}
}
return q;
}
示例13: addStatement
import org.eclipse.rdf4j.query.Binding; //导入依赖的package包/类
@Override
public void addStatement(UpdateContext op, Resource subj, IRI pred, Value obj, Resource... contexts) throws SailException {
BindingSet bs;
Binding b;
Value v;
long timestamp = (op != null && (bs = op.getBindingSet()) != null && (b = bs.getBinding(TIMESTAMP_CALLBACK_BINDING_NAME)) != null) ? ((Literal) b.getValue()).longValue() : System.currentTimeMillis();
for (Resource ctx : normalizeContexts(contexts)) {
addStatementInternal(subj, pred, obj, ctx, timestamp);
}
}
示例14: project
import org.eclipse.rdf4j.query.Binding; //导入依赖的package包/类
/**
* Project a binding set to a potentially smaller binding set that
* contain only the variable bindings that are in vars set.
* @param bindings
* @param vars
* @return
*/
@Override
public BindingSet project(Collection<String> vars, BindingSet bindings) {
QueryBindingSet q = new QueryBindingSet();
for (String varName : vars) {
Binding b = bindings.getBinding(varName);
if (b != null) {
q.addBinding(b);
}
}
return q;
}
示例15: hasBNode
import org.eclipse.rdf4j.query.Binding; //导入依赖的package包/类
public static boolean hasBNode(BindingSet bindings) {
for (Binding b : bindings) {
if (b.getValue() instanceof BNode) {
return true;
}
}
return false;
}