Package org.semanticweb.owlapi.util
Class DefaultPrefixManager
java.lang.Object
org.semanticweb.owlapi.util.DefaultPrefixManager
- All Implemented Interfaces:
Serializable
,PrefixManager
,IRIShortFormProvider
,ShortFormProvider
public class DefaultPrefixManager
extends Object
implements PrefixManager, ShortFormProvider, IRIShortFormProvider
- Since:
- 2.2.0
- Author:
- Matthew Horridge, The University Of Manchester, Information Management Group
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor setting the comparator to string length comparator.DefaultPrefixManager
(String defaultPrefix) DefaultPrefixManager
(PrefixManager pm, StringComparator c, String defaultPrefix) -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Clear the map.boolean
containsPrefixMapping
(String prefixName) Determines if this manager knows about a given prefix name and it contains a (non-null) mapping for the prefix.void
copyPrefixesFrom
(Map<String, String> from) Copies the prefix from another prefix manager into this one.void
Copies the prefix from another prefix manager into this one.Gets the default prefix.Gets the URI for a given prefix IRI.Gets the prefix that is bound to a particular prefix name.getPrefixIRI
(IRI iri) Gets the prefix IRI given a IRI (URI).Gets the prefix IRI given a IRI (URI).Gets a map that maps prefix names to prefixes.getShortForm
(IRI iri) getShortForm
(OWLEntity entity) Gets the short form for the specified entity.Gets the prefix names that have a mapping in this prefix manager.void
setDefaultPrefix
(String defaultPrefix) Sets the default namespace.void
Adds a prefix name to prefix mapping.void
setPrefixComparator
(StringComparator comparator) void
unregisterNamespace
(String namespace) Removes a previously registered prefix namespace mapping.Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.semanticweb.owlapi.model.PrefixManager
getPrefixNames
Methods inherited from interface org.semanticweb.owlapi.util.ShortFormProvider
dispose
-
Constructor Details
-
DefaultPrefixManager
- Parameters:
defaultPrefix
- default prefix
-
DefaultPrefixManager
public DefaultPrefixManager(@Nullable PrefixManager pm, @Nullable StringComparator c, @Nullable String defaultPrefix) - Parameters:
pm
- the prefix manager to copyc
- comparator to sort prefixesdefaultPrefix
- default prefix
-
DefaultPrefixManager
public DefaultPrefixManager()Default constructor setting the comparator to string length comparator.
-
-
Method Details
-
getPrefixComparator
- Specified by:
getPrefixComparator
in interfacePrefixManager
- Returns:
- the prefix comparator currently used by the prefix manager
-
setPrefixComparator
- Specified by:
setPrefixComparator
in interfacePrefixManager
- Parameters:
comparator
- the comparator to use
-
clear
public void clear()Description copied from interface:PrefixManager
Clear the map.- Specified by:
clear
in interfacePrefixManager
-
prefixNames
Description copied from interface:PrefixManager
Gets the prefix names that have a mapping in this prefix manager.- Specified by:
prefixNames
in interfacePrefixManager
- Returns:
- The prefix names as a set of strings.
-
getPrefixIRI
Description copied from interface:PrefixManager
Gets the prefix IRI given a IRI (URI).- Specified by:
getPrefixIRI
in interfacePrefixManager
- 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.
-
getPrefixIRIIgnoreQName
Description copied from interface:PrefixManager
Gets the prefix IRI given a IRI (URI). Does not restrict the response to be a QName- Specified by:
getPrefixIRIIgnoreQName
in interfacePrefixManager
- 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
Description copied from interface:PrefixManager
Gets the default prefix. The default prefix is denoted by the prefix name ":"- Specified by:
getDefaultPrefix
in interfacePrefixManager
- Returns:
- The default prefix, or
null
if there is no default prefix.
-
setDefaultPrefix
Description copied from interface:PrefixManager
Sets the default namespace. This will also bind the prefix name ":" to this prefix- Specified by:
setDefaultPrefix
in interfacePrefixManager
- Parameters:
defaultPrefix
- The namespace to be used as the default namespace. Note that the value may benull
in order to clear the default namespace.
-
containsPrefixMapping
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 interfacePrefixManager
- Parameters:
prefixName
- 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.
-
copyPrefixesFrom
Description copied from interface:PrefixManager
Copies the prefix from another prefix manager into this one.- Specified by:
copyPrefixesFrom
in interfacePrefixManager
- Parameters:
from
- The manager that the prefixes should be copied from
-
copyPrefixesFrom
Description copied from interface:PrefixManager
Copies the prefix from another prefix manager into this one.- Specified by:
copyPrefixesFrom
in interfacePrefixManager
- Parameters:
from
- The map containing the prefixes
-
getIRI
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 interfacePrefixManager
- Parameters:
prefixIRI
- The Prefix IRI- Returns:
- The full IRI.
-
getPrefixName2PrefixMap
Description copied from interface:PrefixManager
Gets a map that maps prefix names to prefixes.- Specified by:
getPrefixName2PrefixMap
in interfacePrefixManager
- 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
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 thegetDefaultPrefix()
method.- Specified by:
getPrefix
in interfacePrefixManager
- 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
Description copied from interface:PrefixManager
Adds a prefix name to prefix mapping.- Specified by:
setPrefix
in interfacePrefixManager
- Parameters:
inputPrefixName
- name The prefix name (must end with a colon)prefix
- The prefix.
-
unregisterNamespace
Description copied from interface:PrefixManager
Removes a previously registered prefix namespace mapping.- Specified by:
unregisterNamespace
in interfacePrefixManager
- Parameters:
namespace
- The namespace to be removed.
-
getShortForm
- Specified by:
getShortForm
in interfaceIRIShortFormProvider
- Parameters:
iri
- the IRI to shorten- Returns:
- the short form
-
getShortForm
Description copied from interface:ShortFormProvider
Gets the short form for the specified entity.- Specified by:
getShortForm
in interfaceShortFormProvider
- Parameters:
entity
- The entity.- Returns:
- A string which represents a short rendering of the specified entity. The returned value will not be null but might be an empty string.
-