本文整理汇总了Java中org.apache.jena.sparql.util.Context类的典型用法代码示例。如果您正苦于以下问题:Java Context类的具体用法?Java Context怎么用?Java Context使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Context类属于org.apache.jena.sparql.util包,在下文中一共展示了Context类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: exec
import org.apache.jena.sparql.util.Context; //导入依赖的package包/类
public NodeValue exec(NodeValue prefix, Context context) {
if (prefix == null) {
return null;
}
if (!prefix.isString()) {
throw new ExprEvalException(NAME + ": not a string: " + prefix);
}
PrefixMapping prefixes = context.get(PREFIX_MAPPING);
if (prefixes == null) {
throw new ExprEvalException(NAME + ": no prefix mapping registered");
}
String iri = prefixes.getNsPrefixURI(prefix.asString());
if (iri == null) {
throw new ExprEvalException(NAME + ": prefix not defined: " + prefix);
}
return NodeValue.makeString(iri);
}
示例2: addValueNodes
import org.apache.jena.sparql.util.Context; //导入依赖的package包/类
public static void addValueNodes(RDFNode focusNode, Path path, Collection<RDFNode> results) {
Set<Node> seen = new HashSet<>();
Iterator<Node> it = PathEval.eval(focusNode.getModel().getGraph(), focusNode.asNode(), path, Context.emptyContext);
while(it.hasNext()) {
Node node = it.next();
if(!seen.contains(node)) {
seen.add(node);
results.add(focusNode.getModel().asRDFNode(node));
}
}
}
示例3: create
import org.apache.jena.sparql.util.Context; //导入依赖的package包/类
@Override
public UpdateEngine create(DatasetGraph datasetGraph, Binding inputBinding,
Context context) {
MarkLogicUpdateEngine engine = new MarkLogicUpdateEngine(
datasetGraph, inputBinding, context);
return engine;
}
示例4: MarkLogicUpdateEngineWorker
import org.apache.jena.sparql.util.Context; //导入依赖的package包/类
public MarkLogicUpdateEngineWorker(DatasetGraph graphStore,
Binding inputBinding, Context context) {
if (!(graphStore instanceof MarkLogicDatasetGraph)) {
throw new MarkLogicJenaException(
"UpdateVisitor created with incorrect GraphStore implementation");
} else {
this.markLogicDatasetGraph = (MarkLogicDatasetGraph) graphStore;
this.initial = inputBinding;
this.client = markLogicDatasetGraph.getDatabaseClient();
}
}
示例5: MarkLogicQueryEngine
import org.apache.jena.sparql.util.Context; //导入依赖的package包/类
/**
* Constructor.
* @param query A Jena Query. This engine does not use all parts of the Query hierarchy.
* @param datasetGraph The MarkLogic instance viewed through Jena. Must be a MarkLogicDatasetGraph.
* @param initial Bindings for the query.
* @param context
*/
private MarkLogicQueryEngine(Query query, DatasetGraph datasetGraph,
Binding initial, Context context) {
super(query, datasetGraph, initial, context);
bgp = new BasicPattern();
bgp.add(new Triple(
Var.alloc("s"),
Var.alloc("p"),
Var.alloc("o")));
template = new Template(bgp);
this.markLogicDatasetGraph = (MarkLogicDatasetGraph) datasetGraph;
this.initial = initial;
}
示例6: createEntity
import org.apache.jena.sparql.util.Context; //导入依赖的package包/类
@Test
public void createEntity() throws Exception {
Individual ent = provModel.createEntity(URI
.create("http://example.com/fred#test"));
provModel.createEntity(URI.create("http://example.com/test"));
OntModel model = provModel.model;
model.write(System.out, "TURTLE", "http://example.com/fred");
model.write(System.out, "RDF/XML", "http://example.com/fred");
WriterGraphRIOT writer = RDFDataMgr.createGraphWriter(RDFFormat.TURTLE_BLOCKS);
writer.write(System.out, model.getBaseModel().getGraph(), RiotLib.prefixMap(model.getGraph()), "http://example.com/fred", new Context());
}
示例7: LinkedDataFragmentEngine
import org.apache.jena.sparql.util.Context; //导入依赖的package包/类
public LinkedDataFragmentEngine(Query query, DatasetGraph dataset, Binding input, Context context)
{
super(query, dataset, input, context) ;
this.ldfQuery = query;
this.ldfDataset = dataset;
this.ldfBinding = input;
this.ldfContext = context;
}
示例8: write
import org.apache.jena.sparql.util.Context; //导入依赖的package包/类
@Override
public void write(Writer out, Graph graph, PrefixMap prefixMap, String baseURI, Context context)
{
// Writers are discouraged : just hope the charset is UTF-8.
IndentedWriter x = RiotLib.create(out) ;
SSE.write(x, graph) ;
}
示例9: eval
import org.apache.jena.sparql.util.Context; //导入依赖的package包/类
@Override
public QueryIterator eval(Op op, DatasetGraph dsg, Binding initial, Context context)
{
// Extension point: access possible to all the parameters for execution.
// Be careful to deal with initial bindings.
Transform transform = new MyTransform() ;
op = Transformer.transform(transform, op) ;
return super.eval(op, dsg, initial, context) ;
}
示例10: create
import org.apache.jena.sparql.util.Context; //导入依赖的package包/类
@Override
public Plan create(Query query, DatasetGraph dataset, Binding initial, Context context)
{
// Create a query engine instance.
MyQueryEngine engine = new MyQueryEngine(query, dataset, initial, context) ;
return engine.getPlan() ;
}
示例11: exec
import org.apache.jena.sparql.util.Context; //导入依赖的package包/类
public NodeValue exec(NodeValue name, Context context) {
if (name == null) return null;
if (!name.isString()) throw new ExprEvalException("Not a string: " + name);
PrefixMapping prefixes = context.get(ExpandPrefixFunction.PREFIX_MAPPING);
if (prefixes == null) throw new ExprEvalException("No prefix mapping registered");
String pname = name.asString();
int idx = pname.indexOf(':');
if (idx == -1) throw new ExprEvalException("Not a prefixed name: " + name);
String prefix = pname.substring(0, idx);
String iri = prefixes.getNsPrefixURI(prefix);
if (iri == null) throw new ExprEvalException("Prefix not defined: " + prefix);
return NodeValue.makeNode(NodeFactory.createURI(iri + pname.substring(idx + 1)));
}
示例12: open
import org.apache.jena.sparql.util.Context; //导入依赖的package包/类
@Override
public Object open(Assembler a, Resource root, Mode mode) {
// delta:changes.
if ( ! exactlyOneProperty(root, pDeltaChanges) )
throw new AssemblerException(root, "No destination for changes given") ;
String destURL = getAsStringValue(root, pDeltaChanges);
// Future - multiple outputs.
List<String> xs = Arrays.asList(destURL);
// delta:zone.
if ( ! exactlyOneProperty(root, pDeltaZone) )
throw new AssemblerException(root, "No location for state manangement (zone)") ;
String zoneLocation = getAsStringValue(root, pDeltaZone);
// Name of the patch log.
// delta:patchlog
if ( ! exactlyOneProperty(root, pDeltaPatchLog) )
throw new AssemblerException(root, "No patch log name") ;
String dsName = getAsStringValue(root, pDeltaPatchLog);
// delta:storage
if ( ! exactlyOneProperty(root, pDeltaChanges) )
throw new AssemblerException(root, "No location for state manangement (zone)") ;
String storageTypeStr = getAsStringValue(root, pDeltaStorage);
LocalStorageType storage = LocalStorageType.fromString(storageTypeStr);
if ( storage == null )
throw new AssemblerException(root, "Unrecognized storage type '"+storageTypeStr+"'");
// Build the RDFChanges: URLs to send each patch log entry.
RDFChanges streamChanges = null ;
for ( String dest : xs ) {
FmtLog.info(log, "Destination: '%s'", dest) ;
RDFChanges sc = DeltaLib.destination(dest);
streamChanges = RDFChangesN.multi(streamChanges, sc) ;
}
// Link to log server.
DeltaLink deltaLink = DeltaLinkHTTP.connect(destURL);
// Touch server
Id clientId = Id.create();
deltaLink.register(clientId);
// Create.connect the local copy.
Zone zone = Zone.connect(zoneLocation);
// Local client.
DeltaClient deltaClient = DeltaClient.create(zone, deltaLink);
Id dsRef = setup(deltaClient, dsName, "delta:"+dsName, storage);
DeltaConnection deltaConnection = deltaClient.get(dsRef);
DatasetGraph dsg = deltaConnection.getDatasetGraph();
// This DatasetGraph syncs on transaction so it happens, and assumes, a transaction for any Fuseki operation.
// And someday tap into services to add a "sync before operation" step.
// Poll for changes as well.
// if ( root.hasProperty(pPollForChanges) ) {
// if ( ! exactlyOneProperty(root, pPollForChanges) )
// throw new AssemblerException(root, "Multiple places to poll for chnages") ;
// String source = getStringValue(root, pPollForChanges) ;
// forkUpdateFetcher(source, dsgSub) ;
// }
// Put state into dsg Context "for the record".
Context cxt = dsg.getContext();
cxt.set(symDeltaClient, deltaClient);
cxt.set(symDeltaConnection, deltaConnection);
cxt.set(symDeltaZone, zone);
return DatasetFactory.wrap(dsg);
}
示例13: get
import org.apache.jena.sparql.util.Context; //导入依赖的package包/类
public static IteratorFunctionRegistry get(Context context)
{
if ( context == null )
return null ;
return (IteratorFunctionRegistry) context.get(SPARQLGenerateConstants.registryIterators) ;
}
示例14: set
import org.apache.jena.sparql.util.Context; //导入依赖的package包/类
public static void set(Context context, IteratorFunctionRegistry reg)
{
context.set(SPARQLGenerateConstants.registryIterators, reg) ;
}
示例15: getContext
import org.apache.jena.sparql.util.Context; //导入依赖的package包/类
@Override
public Context getContext() {
return delegate.getContext();
}