01: package org.ontoware.rdf2go.util.transform;
02:
03: import java.util.Map;
04:
05: import org.ontoware.rdf2go.model.Model;
06: import org.ontoware.rdf2go.model.node.URI;
07:
08: public class URISearchReplaceRule implements TransformerRule {
09:
10: private URI search, replace;
11:
12: public URISearchReplaceRule(URI search, URI replace) {
13: super ();
14: this .search = search;
15: this .replace = replace;
16: }
17:
18: public void applyRule(Model model, Map<String, URI> namespaceMap) {
19: searchAndReplace(model, namespaceMap, search, replace);
20: }
21:
22: public static void searchAndReplace(Model model,
23: Map<String, URI> namespaceMap, URI search, URI replace) {
24: SearchRemoveAddRule.searchAndReplace(model, namespaceMap,
25:
26: search.toSPARQL() + " ?p ?o",
27:
28: search.toSPARQL() + " ?p ?o",
29:
30: replace.toSPARQL() + " ?p ?o");
31:
32: SearchRemoveAddRule.searchAndReplace(model, namespaceMap,
33:
34: "?s " + search.toSPARQL() + " ?o",
35:
36: "?s " + search.toSPARQL() + " ?o",
37:
38: "?s " + replace.toSPARQL() + " ?o");
39: SearchRemoveAddRule.searchAndReplace(model, namespaceMap,
40:
41: "?s ?p " + search.toSPARQL(),
42:
43: "?s ?p " + search.toSPARQL(),
44:
45: "?s ?p " + replace.toSPARQL());
46: }
47:
48: }
|