org.semanticweb.kaon2.api
Class DefaultOntologyResolver

java.lang.Object
  extended by org.semanticweb.kaon2.api.DefaultOntologyResolver
All Implemented Interfaces:
OntologyResolver

public class DefaultOntologyResolver
extends java.lang.Object
implements OntologyResolver

This is the default resolver that maintains a list of associations for ontology URIs. There is one global instance of this class, but clients can create their own private instances as well.


Field Summary
protected  java.util.Map<java.lang.String,java.lang.String> m_physicalURIs
          The map of associations of ontology to physical URIs.
static DefaultOntologyResolver s_defaultResolver
          The glocal instance of this class that is the default resolver.
 
Constructor Summary
DefaultOntologyResolver()
           
 
Method Summary
 java.lang.String getReplacement(java.lang.String ontologyURI)
          Returns the physical URI for given ontology URI.
 void loadFromProperties(java.io.File file)
          Loads specified properties from the file and adds all (key,value) pairs as replacements.
 void loadFromProperties(java.io.InputStream inputStream)
          Loads properties from the stream and adds all (key,value) pairs as replacements.
 void loadFromProperties(java.net.URL url)
          Loads specified properties from the URL and adds all (key,value) pairs as replacements.
 java.util.Iterator<java.lang.String> registeredOntologyURIs()
          Returns the iterator over all ontology URIs.
 java.lang.String registerOntology(java.lang.String physicalURI)
          Registers the ontology with a given physical URI.
 java.lang.String registerOntology(java.lang.String physicalURI, java.net.Proxy proxy)
          Registers the ontology with a given physical URI.
 void registerReplacement(java.lang.String ontologyURI, java.lang.String physicalURI)
          Registers a physical URI for the ontology URI.
 java.lang.String resolveOntologyAccess(java.lang.String ontologyURI, java.util.Map<java.lang.String,java.lang.Object> parameters, java.util.Map<java.lang.String,java.lang.Object> templateParameters)
          Called to resolve ontology parameters.
 void unregisterReplacement(java.lang.String ontologyURI)
          Removes a possible physical URI for given otnology URI.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

s_defaultResolver

public static final DefaultOntologyResolver s_defaultResolver
The glocal instance of this class that is the default resolver.


m_physicalURIs

protected final java.util.Map<java.lang.String,java.lang.String> m_physicalURIs
The map of associations of ontology to physical URIs.

Constructor Detail

DefaultOntologyResolver

public DefaultOntologyResolver()
Method Detail

resolveOntologyAccess

public java.lang.String resolveOntologyAccess(java.lang.String ontologyURI,
                                              java.util.Map<java.lang.String,java.lang.Object> parameters,
                                              java.util.Map<java.lang.String,java.lang.Object> templateParameters)
Description copied from interface: OntologyResolver
Called to resolve ontology parameters. The resolver can locate the physical URI for the ontology URI. Furthermore, it can adjust the * parameters that will be used to open the ontology.

Specified by:
resolveOntologyAccess in interface OntologyResolver
Parameters:
ontologyURI - the ontology URI
parameters - the parameters that will be used to access the ontology
templateParameters - the template parameters (e.g. of a parent ontology)
Returns:
the physical URI to access the ontology

getReplacement

public java.lang.String getReplacement(java.lang.String ontologyURI)
Returns the physical URI for given ontology URI.

Parameters:
ontologyURI - the ontology URI
Returns:
the physical URI (or null if no URI has been registered)

registerReplacement

public void registerReplacement(java.lang.String ontologyURI,
                                java.lang.String physicalURI)
Registers a physical URI for the ontology URI.

Parameters:
ontologyURI - the ontology URI
physicalURI - the physical URI

registerOntology

public java.lang.String registerOntology(java.lang.String physicalURI)
                                  throws KAON2Exception
Registers the ontology with a given physical URI.

Parameters:
physicalURI - the physical URI of the ontology
Returns:
the ontology URI
Throws:
KAON2Exception - thrown if there is an error

registerOntology

public java.lang.String registerOntology(java.lang.String physicalURI,
                                         java.net.Proxy proxy)
                                  throws KAON2Exception
Registers the ontology with a given physical URI.

Parameters:
physicalURI - the physical URI of the ontology
proxy - the proxy
Returns:
the ontology URI
Throws:
KAON2Exception - thrown if there is an error

unregisterReplacement

public void unregisterReplacement(java.lang.String ontologyURI)
Removes a possible physical URI for given otnology URI.

Parameters:
ontologyURI - the ontology URI for which registration is removed

registeredOntologyURIs

public java.util.Iterator<java.lang.String> registeredOntologyURIs()
Returns the iterator over all ontology URIs.

Returns:
the iterator over all registered URIs.

loadFromProperties

public void loadFromProperties(java.io.InputStream inputStream)
                        throws java.io.IOException
Loads properties from the stream and adds all (key,value) pairs as replacements. The stream can be in XML or in the textual format. WARNING: The caller is responsible for closing the stream.

Parameters:
inputStream - the stream containing the information
Throws:
java.io.IOException - thrown if there is an error

loadFromProperties

public void loadFromProperties(java.net.URL url)
                        throws java.io.IOException
Loads specified properties from the URL and adds all (key,value) pairs as replacements. The URL can be in XML or in the textual format.

Parameters:
url - the URL of the properties file
Throws:
java.io.IOException - thrown if there is an error

loadFromProperties

public void loadFromProperties(java.io.File file)
                        throws java.io.IOException
Loads specified properties from the file and adds all (key,value) pairs as replacements. The file can be in XML or in the textual format.

Parameters:
file - the properties file
Throws:
java.io.IOException - thrown if there is an error