org.topbraid.spin.system
Class SPINModuleRegistry

java.lang.Object
  extended by org.topbraid.spin.system.SPINModuleRegistry

public class SPINModuleRegistry
extends java.lang.Object

A singleton that keeps track of all registered SPIN functions and templates. For example, in TopBraid this is populated by walking all .spin. files in the Eclipse workspace. Other implementations may need to register their modules "manually".

Author:
Holger Knublauch

Constructor Summary
SPINModuleRegistry()
           
 
Method Summary
static SPINModuleRegistry get()
          Gets the singleton instance of this class.
 Function getFunction(java.lang.String uri, Model model)
          Gets a registered Function with a given URI.
 Template getTemplate(java.lang.String uri, Model model)
          Gets a Template with a given URI in its defining Model.
 java.util.Collection<Template> getTemplates()
          Gets a Collection of all registered Templates.
 void init()
          Initializes this registry with all system functions and templates from the SPL namespace.
 void register(Function function, boolean addARQFunction)
          Registers a Function with its URI to this registry.
 void register(Template template)
          Registers a Template with its URI.
 void registerAll(Model model)
          Registers all functions and templates from a given Model.
protected  void registerARQFunction(Function function)
          If the provided Function has an executable body (spin:body), then register an ARQ function for it with the current FunctionRegistry.
protected  void registerARQPFunction(Function function)
          If the provided Function has an executable body (spin:body), then register an ARQ function for it with the current FunctionRegistry.
 void registerFunctions(Model model)
          Registers all functions defined in a given Model.
 void registerTemplates(Model model)
          Registers all templates defined in a given Model.
static void set(SPINModuleRegistry value)
          Sets the SPINModuleRegistry to another value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SPINModuleRegistry

public SPINModuleRegistry()
Method Detail

get

public static SPINModuleRegistry get()
Gets the singleton instance of this class.

Returns:
the singleton

set

public static void set(SPINModuleRegistry value)
Sets the SPINModuleRegistry to another value.

Parameters:
value - the new value (not null)

getFunction

public Function getFunction(java.lang.String uri,
                            Model model)
Gets a registered Function with a given URI.

Parameters:
uri - the URI of the Function to get
model - an (optional) Model that should also be used to look up locally defined functions (currently not used)
Returns:
the Function or null if none was found

getTemplate

public Template getTemplate(java.lang.String uri,
                            Model model)
Gets a Template with a given URI in its defining Model.

Parameters:
uri - the URI of the Template to look up
model - an (optional) Model that should also be used for look up
Returns:
a Template or null

getTemplates

public java.util.Collection<Template> getTemplates()
Gets a Collection of all registered Templates.

Returns:
the Templates

init

public void init()
Initializes this registry with all system functions and templates from the SPL namespace.


register

public void register(Function function,
                     boolean addARQFunction)
Registers a Function with its URI to this registry. As an optional side effect, if the provided function has a spin:body, this method can also register an ARQ FunctionFactory at the current Jena FunctionRegistry, using registerARQFunction(). Note that the Model attached to the function should be an OntModel that also imports the system namespaces spin.owl and sp.owl - otherwise the system may not be able to transform the SPIN RDF into the correct SPARQL string.

Parameters:
function - the Function (must be a URI resource)
addARQFunction - true to also add an entry to the ARQ function registry

register

public void register(Template template)
Registers a Template with its URI. Note that the Model attached to the template should be an OntModel that also imports the system namespaces spin.owl and sp.owl - otherwise the system may not be able to transform the SPIN RDF into the correct SPARQL string.

Parameters:
template - the Template (must be a URI resource)

registerAll

public void registerAll(Model model)
Registers all functions and templates from a given Model. Note that the Model should contain the triples from the system namespaces spin.owl and sp.owl - otherwise the system may not be able to transform the SPIN RDF into the correct SPARQL string. In a typical use case, the Model would be an OntModel that also imports the SPIN system namespaces.

Parameters:
model - the Model to iterate over

registerARQFunction

protected void registerARQFunction(Function function)
If the provided Function has an executable body (spin:body), then register an ARQ function for it with the current FunctionRegistry.

Parameters:
function - the function to register

registerARQPFunction

protected void registerARQPFunction(Function function)
If the provided Function has an executable body (spin:body), then register an ARQ function for it with the current FunctionRegistry.

Parameters:
function - the function to register

registerFunctions

public void registerFunctions(Model model)
Registers all functions defined in a given Model. This basically iterates over all instances of spin:Function and calls register(function) for each of them.

Parameters:
model - the Model to add the functions of

registerTemplates

public void registerTemplates(Model model)
Registers all templates defined in a given Model. This basically iterates over all instances of spin:Template and calls register(template) for each of them.

Parameters:
model - the Model to add the templates of