All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.ontoware.rdf2go.util.transform.URISearchReplaceRule Maven / Gradle / Ivy

Go to download

RDF2go is an implementation-independent Java API with the design goals: portability (hence the name), performance and ease of implementation. This project was started at FZI Forschungszentrum Informatik Karlsruhe, Germany - www.fzi.de

The newest version!
/**
 * LICENSE INFORMATION
 *
 * Copyright 2005-2008 by FZI (http://www.fzi.de).
 * Licensed under a BSD license (http://www.opensource.org/licenses/bsd-license.php)
 *  = Max Völkel
 *  = FZI Forschungszentrum Informatik Karlsruhe, Karlsruhe, Germany
 *  = 2010
 *
 * Further project information at http://semanticweb.org/wiki/RDF2Go
 */

package org.ontoware.rdf2go.util.transform;

import java.util.Map;

import org.ontoware.rdf2go.model.Model;
import org.ontoware.rdf2go.model.node.URI;

public class URISearchReplaceRule implements TransformerRule {

	private URI search, replace;

	public URISearchReplaceRule(URI search, URI replace) {
		super();
		this.search = search;
		this.replace = replace;
	}

	@Override
    public void applyRule(Model model, Map namespaceMap) {
		searchAndReplace(model, namespaceMap, this.search, this.replace);
	}

	public static void searchAndReplace(Model model,
			Map namespaceMap, URI search, URI replace) {
		SearchRemoveAddRule.searchAndReplace(model, namespaceMap,

		search.toSPARQL() + " ?p ?o",

		search.toSPARQL() + " ?p ?o",

		replace.toSPARQL() + " ?p ?o");

		SearchRemoveAddRule.searchAndReplace(model, namespaceMap,

		"?s " + search.toSPARQL() + " ?o",

		"?s " + search.toSPARQL() + " ?o",

		"?s " + replace.toSPARQL() + " ?o");
		SearchRemoveAddRule.searchAndReplace(model, namespaceMap,

		"?s ?p " + search.toSPARQL(),

		"?s ?p " + search.toSPARQL(),

		"?s ?p " + replace.toSPARQL());
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy