public final class NamespaceManager extends Object
NamespaceManager manages namespace URIs and their prefixes. It allows for NamespaceManagers only),
A NamespaceManager may have a parent NamespaceManager to which retrieval requests
are delegated if it has no own registries or if it has no result to the request. A NamespaceManager
without a parent is called a root namespace manager.
Note: Instances of this class are intentionally not thread-safe.
| Modifier and Type | Method and Description |
|---|---|
static NamespaceManager |
create()
Creates a new
NamespaceManager. |
NamespaceManager |
createCopy()
Creates a copy of this
NamespaceManager. |
String |
createPrefix(String uri,
boolean defaultAllowed)
Creates a new prefix for the given URI.
|
static NamespaceManager |
createWithParent(NamespaceManager parent)
Creates a new
NamespaceManager with the given NamespaceManager as its parent. |
NamespaceManager |
getParent()
Returns the parent namespace manager of this namespace manager - if exists.
|
String |
getPrefix(String uri,
boolean defaultAllowed)
Returns the prefix which is registered for the given namespace uri.
|
String |
getUri(String prefix)
Returns the namespace uri the given prefix is registered for.
|
void |
registerPreferredPrefix(String prefix,
String uri)
Registers the given prefix to be the preferred one for the given URI.
|
void |
registerPrefix(String prefix,
String uri)
Registers the given prefix for the given namespace uri.
|
public static NamespaceManager create()
NamespaceManager.NamespaceManagerpublic static NamespaceManager createWithParent(NamespaceManager parent)
NamespaceManager with the given NamespaceManager as its parent.parent - the parent of this namespace manager.NamespaceManagerpublic NamespaceManager createCopy()
NamespaceManager. The copy has its own registries but has the same
(identical) parent as the this NamespaceManager.NamespaceManagerpublic NamespaceManager getParent()
public void registerPreferredPrefix(String prefix, String uri)
createPrefix(java.lang.String, boolean)) for that URI the given preferred one is used and not an automatically created
one.prefix - the preferred prefixuri - the URIpublic void registerPrefix(String prefix, String uri)
During serialization a registered prefix is interpretated is being known at the current point in the xml document.
Note: Normally it is registerPreferredPrefix(java.lang.String, java.lang.String) what you want to call.
prefix - the prefixuri - the uriNullPointerException - if one of the arguments is nullNamespaceRegistrationException - if public String getPrefix(String uri, boolean defaultAllowed)
If the parent namespace manager returns a prefix which is known for this namespace manager (the prefix is overwritten), then null is returned.
uri - the namespace uridefaultAllowed - true, if the prefix may be the default one.public String createPrefix(String uri, boolean defaultAllowed)
uri - the uri to get a prefix for (not null)defaultAllowed - true, if the prefix may be the default one.public String getUri(String prefix)
prefix - the prefixCopyright © 2014. All rights reserved.