org.semanticweb.owlapi.util
Class DefaultPrefixManager

java.lang.Object
  extended by org.semanticweb.owlapi.util.DefaultPrefixManager
All Implemented Interfaces:
PrefixManager, IRIShortFormProvider, ShortFormProvider

public class DefaultPrefixManager
extends java.lang.Object
implements PrefixManager, ShortFormProvider, IRIShortFormProvider

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


Constructor Summary
DefaultPrefixManager()
          Creates a namespace manager that does not have a default namespace.
DefaultPrefixManager(PrefixManager pm)
           
DefaultPrefixManager(java.lang.String defaultPrefix)
          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 prefix name and it contains a (non-null) mapping for the prefix.
 void dispose()
          Disposes of the short form proivider.
 java.lang.String getDefaultPrefix()
          Gets the default prefix.
 IRI getIRI(java.lang.String curie)
          Gets the URI for a given prefix IRI.
 java.lang.String getPrefix(java.lang.String prefixName)
          Gets the prefix that is bound to a particular prefix name.
 java.lang.String getPrefixIRI(IRI iri)
          Gets the prefix IRI given a IRI (URI).
 java.util.Map<java.lang.String,java.lang.String> getPrefixName2PrefixMap()
          Gets a map that maps prefix names to prefixes.
 java.util.Set<java.lang.String> getPrefixNames()
          Gets the prefix names that have a mapping in this prefix manager
 java.lang.String getShortForm(IRI iri)
           
 java.lang.String getShortForm(OWLEntity entity)
          Gets the short form for the specified entity.
 void setDefaultPrefix(java.lang.String defaultPrefix)
          Sets the default namespace.
 void setPrefix(java.lang.String prefixName, java.lang.String prefix)
          Adds a prefix name to prefix mapping
 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

DefaultPrefixManager

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


DefaultPrefixManager

public DefaultPrefixManager(PrefixManager pm)

DefaultPrefixManager

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

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

clear

public void clear()

getPrefixNames

public java.util.Set<java.lang.String> getPrefixNames()
Gets the prefix names that have a mapping in this prefix manager

Specified by:
getPrefixNames in interface PrefixManager
Returns:
The prefix names as a set of strings.

setDefaultPrefix

public void setDefaultPrefix(java.lang.String defaultPrefix)
Sets the default namespace. This will also bind the prefix name ":" to this prefix

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

getPrefixIRI

public java.lang.String getPrefixIRI(IRI iri)
Description copied from interface: PrefixManager
Gets the prefix IRI given a IRI (URI).

Specified by:
getPrefixIRI in interface PrefixManager
Parameters:
iri - The IRI whose prefix it to be retrieved
Returns:
The prefix IRI for this IRI, or null if a prefix IRI cannot be generated.

getDefaultPrefix

public java.lang.String getDefaultPrefix()
Description copied from interface: PrefixManager
Gets the default prefix. The default prefix is denoted by the prefix name ":"

Specified by:
getDefaultPrefix in interface PrefixManager
Returns:
The default prefix, or null if there is no default prefix.

containsPrefixMapping

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

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

getIRI

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

Specified by:
getIRI in interface PrefixManager
Parameters:
curie - The Prefix IRI
Returns:
The full IRI.

getPrefixName2PrefixMap

public java.util.Map<java.lang.String,java.lang.String> getPrefixName2PrefixMap()
Description copied from interface: PrefixManager
Gets a map that maps prefix names to prefixes.

Specified by:
getPrefixName2PrefixMap in interface PrefixManager
Returns:
The map of prefix names to prefixes. Note that modifying the contents of this map will not change the prefix name - prefix mappings

getPrefix

public java.lang.String getPrefix(java.lang.String prefixName)
Description copied from interface: PrefixManager
Gets the prefix that is bound to a particular prefix name. Note that specifying ":" corresponds to requesting the default prefix and will return the same result as a call to the getDefaultPrefix() method.

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

setPrefix

public void setPrefix(java.lang.String prefixName,
                      java.lang.String prefix)
Adds a prefix name to prefix mapping

Parameters:
prefixName - name The prefix name (must not be null)
prefix - The prefix
Throws:
java.lang.NullPointerException - if the prefix name or prefix is null.
java.lang.IllegalArgumentException - if the prefix name does not end with a colon.

unregisterNamespace

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

Parameters:
namespace - The namespace to be removed.

getShortForm

public java.lang.String getShortForm(IRI iri)
Specified by:
getShortForm in interface IRIShortFormProvider

getShortForm

public java.lang.String getShortForm(OWLEntity entity)
Description copied from interface: ShortFormProvider
Gets the short form for the specified entity.

Specified by:
getShortForm in interface ShortFormProvider
Parameters:
entity - The entity.
Returns:
A string which represents a short rendering of the speicified entity.

dispose

public void dispose()
Description copied from interface: ShortFormProvider
Disposes of the short form proivider. This frees any resources and clears any caches.

Specified by:
dispose in interface ShortFormProvider