Package org.aksw.qa.commons.sparql
Class SPARQLPrefixResolver
java.lang.Object
org.aksw.qa.commons.sparql.SPARQLPrefixResolver
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static classConsists of two, a local and a global request mapping. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static PropertiesRefers to resource "prefixes.properties".private static org.apache.jena.shared.PrefixMappingThis mapping will be used to refer to, if the local mapping (e.g.PREFIX declarations in the query itself) cannot resolve a prefix.private static org.slf4j.Logger -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringaddMissingPrefixes(String sparqlQuery)Adds the declaration of a prefix, if its used in the sparql query, but not declared.static org.apache.jena.shared.PrefixMappingIf you want to add/remove a prefix, this is your best bet.
-
Field Details
-
LOGGER
private static org.slf4j.Logger LOGGER -
globalPrefixes
Refers to resource "prefixes.properties". Left had side is a prefix, right hand side is a corresponding URI.Prefixes will be loaded during loading of enclosing class, via static constructor.
-
globalPrefixMapping
private static org.apache.jena.shared.PrefixMapping globalPrefixMappingThis mapping will be used to refer to, if the local mapping (e.g.PREFIX declarations in the query itself) cannot resolve a prefix. Will be initialized with all prefixes inglobalPrefixes
-
-
Constructor Details
-
SPARQLPrefixResolver
public SPARQLPrefixResolver()
-
-
Method Details
-
getGlobalPrefixMapping
public static org.apache.jena.shared.PrefixMapping getGlobalPrefixMapping()If you want to add/remove a prefix, this is your best bet.- Returns:
- The global prefix mapping, possibly containing all from resource "prefixes.properties"
-
addMissingPrefixes
Adds the declaration of a prefix, if its used in the sparql query, but not declared. As global prefix sourceglobalPrefixMappingis used, which is initialized with data from resource "prefixes.properties"In query defined prefixes override.
If uris are given in the query body which can be represented with a prefix, the uris are replaced with a prefix and a prefix declaration will be added. E.g. "http://www.w3.org/1999/02/22-rdf-syntax-ns#type" is present, it will be replaced with "rdf:type", and prefix declaration for "rdf" will be added.
This will not remove unused prefix declarations.
if you wonder why keyword "a" is replaced, this is correct behavior. This is, because mapping for rdf: is set in a PrefixMap(its default in global).
- Parameters:
sparqlQuery- a sparql query- Returns:
- the same sparql query, but with missing PREFIX declarations added.
-