org.semanticweb.owl.util
Class DefaultNamespaceManager

java.lang.Object
  extended by org.semanticweb.owl.util.DefaultNamespaceManager
All Implemented Interfaces:
NamespaceManager

public class DefaultNamespaceManager
extends java.lang.Object
implements NamespaceManager

Author: Matthew Horridge
The University Of Manchester
Information Management Group
Date: 10-Sep-2008


Constructor Summary
DefaultNamespaceManager()
          Creates a namespace manager that does not have a default namespace.
DefaultNamespaceManager(java.lang.String defaultNamespace)
          Creates a namespace manager that has the specified default namespace.
 
Method Summary
 void clear()
           
 boolean containsPrefixMapping(java.lang.String prefix)
          Determines if this manager knows about a given namespace prefix and it contains a (non-null) mapping for the prefix.
 java.lang.String getDefaultNamespace()
          Gets the default namespace.
 java.lang.String getNamespace(java.lang.String prefix)
          Gets the namespace that is bound to a particular prefix.
 java.util.Map<java.lang.String,java.lang.String> getNamespaceMap()
          Gets a map that maps prefixes to namespaces.
 java.net.URI getURI(java.lang.String curie)
          Gets the URI for a given CURI.
 void registerNamespace(java.lang.String prefix, java.lang.String namespace)
          Adds a prefix namespace mapping
 void setDefaultNamespace(java.lang.String defaultNamespace)
          Sets the default namespace.
 void unregisterNamespace(java.lang.String namespace)
          Removes a previously registerd prefix namespace mapping
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultNamespaceManager

public DefaultNamespaceManager()
Creates a namespace manager that does not have a default namespace.


DefaultNamespaceManager

public DefaultNamespaceManager(java.lang.String defaultNamespace)
Creates a namespace manager that has the specified default namespace.

Parameters:
defaultNamespace - The namespace to be used as the default namespace.
Method Detail

clear

public void clear()

setDefaultNamespace

public void setDefaultNamespace(java.lang.String defaultNamespace)
Sets the default namespace. This will also bind the empty string prefix to this namespace.

Parameters:
defaultNamespace - The namespace to be used as the default namespace. Note that the value may be null in order to clear the default namespace.

getDefaultNamespace

public java.lang.String getDefaultNamespace()
Description copied from interface: NamespaceManager
Gets the default namespace.

Specified by:
getDefaultNamespace in interface NamespaceManager
Returns:
The default namespace, or null if there is no default namespace.

containsPrefixMapping

public boolean containsPrefixMapping(java.lang.String prefix)
Description copied from interface: NamespaceManager
Determines if this manager knows about a given namespace prefix and it contains a (non-null) mapping for the prefix.

Specified by:
containsPrefixMapping in interface NamespaceManager
Parameters:
prefix - The prefix to be tested for.
Returns:
true if the manager knows about this prefix and there is a non-null mapping for this prefix.

getURI

public java.net.URI getURI(java.lang.String curie)
Description copied from interface: NamespaceManager
Gets the URI for a given CURI. The CURI must have a namespace prefix that is registered with this namespace manager, or a runtime exception will be thrown.

Specified by:
getURI in interface NamespaceManager
Parameters:
curie - The CURI
Returns:
The full URI.

getNamespaceMap

public java.util.Map<java.lang.String,java.lang.String> getNamespaceMap()
Description copied from interface: NamespaceManager
Gets a map that maps prefixes to namespaces.

Specified by:
getNamespaceMap in interface NamespaceManager
Returns:
The map of prefixes to namespaces. Note that modifying the contents of this map will not change the prefix - namespace mappings

getNamespace

public java.lang.String getNamespace(java.lang.String prefix)
Description copied from interface: NamespaceManager
Gets the namespace that is bound to a particular prefix. Note that specifying the empty string corresponds to requesting the default namespace and will return the same result as a call to the getDefaultNamespace() method.

Specified by:
getNamespace in interface NamespaceManager
Parameters:
prefix - The namespace prefix. A string that represents a namespace prefix of the namespace to be retrieved. Note that specifying the empty string is the same as asking for the default namespace (see the getDefaultNamespace() method).
Returns:
The namespace, or null if there is no namespace bound to this prefix, or the prefix doesn't exist.

registerNamespace

public void registerNamespace(java.lang.String prefix,
                              java.lang.String namespace)
Adds a prefix namespace mapping

Parameters:
prefix - The prefix (must not be null)
namespace - The namespace that the prefix points to

unregisterNamespace

public void unregisterNamespace(java.lang.String namespace)
Removes a previously registerd prefix namespace mapping

Parameters:
namespace - The namespace to be removed.