本文整理汇总了Java中org.apache.jena.sparql.core.Substitute类的典型用法代码示例。如果您正苦于以下问题:Java Substitute类的具体用法?Java Substitute怎么用?Java Substitute使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Substitute类属于org.apache.jena.sparql.core包,在下文中一共展示了Substitute类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: exec
import org.apache.jena.sparql.core.Substitute; //导入依赖的package包/类
@Override
public QueryIterator exec(Binding binding, PropFuncArg argSubject,
Node predicate, PropFuncArg argObject, ExecutionContext execCxt) {
argSubject = Substitute.substitute(argSubject, binding);
argObject = Substitute.substitute(argObject, binding);
if(!argObject.getArg().isVariable()) {
throw new ExprEvalException("Right hand side of tosh:targetContains must be a variable");
}
Node targetNode = argSubject.getArgList().get(0);
Node shapesGraphNode = argSubject.getArgList().get(1);
Model currentModel = ModelFactory.createModelForGraph(execCxt.getActiveGraph());
Dataset dataset = new DatasetWithDifferentDefaultModel(currentModel, DatasetImpl.wrap(execCxt.getDataset()));
Model model = dataset.getNamedModel(shapesGraphNode.getURI());
Resource target = (Resource) model.asRDFNode(targetNode);
Set<Node> focusNodes = new HashSet<Node>();
SHACLUtil.addNodesInTarget(target, dataset, focusNodes);
return new QueryIterExtendByVar(binding, (Var) argObject.getArg(), focusNodes.iterator(), execCxt);
}
示例2: reorder
import org.apache.jena.sparql.core.Substitute; //导入依赖的package包/类
private static BasicPattern reorder(BasicPattern pattern, QueryIterPeek peek, ReorderTransformation transform)
{
if ( transform != null )
{
// This works by getting one result from the peek iterator,
// and creating the more gounded BGP. The tranform is used to
// determine the best order and the transformation is returned. This
// transform is applied to the unsubstituted pattern (which will be
// substituted as part of evaluation.
if ( ! peek.hasNext() )
throw new ARQInternalErrorException("Peek iterator is already empty") ;
BasicPattern pattern2 = Substitute.substitute(pattern, peek.peek() ) ;
// Calculate the reordering based on the substituted pattern.
ReorderProc proc = transform.reorderIndexes(pattern2) ;
// Then reorder original patten
pattern = proc.reorder(pattern) ;
}
return pattern ;
}
示例3: eval1
import org.apache.jena.sparql.core.Substitute; //导入依赖的package包/类
/** One round of rule evaluation */
private static void eval1(Graph source, StreamTriple out, Rule rule) {
BasicPattern pattern = BasicPattern.wrap(rule.getBody()) ;
ExecutionContext execContext = new ExecutionContext(ARQ.getContext(), source, null, null) ;
// Create a chain of triple iterators.
QueryIterator iter = match(source, pattern) ;
iter.forEachRemaining(b->{
Triple t = Substitute.substitute(rule.getHead(), b) ;
if ( t.isConcrete() && ! source.contains(t) )
out.triple(t);
}) ;
}
示例4: exec
import org.apache.jena.sparql.core.Substitute; //导入依赖的package包/类
@Override
public QueryIterator exec(Binding binding, PropFuncArg argSubject,
Node predicate, PropFuncArg argObject, ExecutionContext execCxt) {
argSubject = Substitute.substitute(argSubject, binding);
argObject = Substitute.substitute(argObject, binding);
if(!argObject.getArg().isVariable()) {
throw new ExprEvalException("Right hand side of tosh:exprEval must be a variable");
}
Node exprNode = argSubject.getArgList().get(0);
Node focusNode = argSubject.getArgList().get(1);
Model model = ModelFactory.createModelForGraph(execCxt.getActiveGraph());
Dataset dataset = ARQFactory.get().getDataset(model);
URI shapesGraphURI = URI.create("urn:x-topbraid:dummyShapesGraph");
dataset.addNamedModel(shapesGraphURI.toString(), model);
ShapesGraph[] shapesGraph = new ShapesGraph[1];
NodeExpression n = NodeExpressionFactory.get().create(model.asRDFNode(exprNode));
List<RDFNode> results = n.eval(model.asRDFNode(focusNode), new NodeExpressionContext() {
@Override
public URI getShapesGraphURI() {
return shapesGraphURI;
}
@Override
public ShapesGraph getShapesGraph() {
if(shapesGraph[0] == null) {
shapesGraph[0] = new ShapesGraph(model);
}
return shapesGraph[0];
}
@Override
public Dataset getDataset() {
return dataset;
}
});
List<Node> nodes = new LinkedList<>();
for(RDFNode rdfNode : results) {
nodes.add(rdfNode.asNode());
}
return new QueryIterExtendByVar(binding, (Var) argObject.getArg(), nodes.iterator(), execCxt);
}