|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sf.jsefa.xml.namespace.NamespaceManager
public final class NamespaceManager
A NamespaceManager
manages namespace URIs and their prefixes. It allows for
1. the registration of preferred prefixes for URIs (for root NamespaceManager
s only),
2. the registration of prefixes for URIs which are interpreted during serialization as being known at the
current point in document,
3. the retrieval of a prefix to a given URI
4. the retrieval of the URI to a given prefix
5. the creation of a new prefix for a new URI
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.
Method Summary | |
---|---|
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static NamespaceManager create()
NamespaceManager
.
NamespaceManager
public static NamespaceManager createWithParent(NamespaceManager parent)
NamespaceManager
with the given NamespaceManager
as its parent.
parent
- the parent of this namespace manager.
NamespaceManager
public NamespaceManager createCopy()
NamespaceManager
. The copy has its own registries but has the same
(identical) parent as the this NamespaceManager
.
NamespaceManager
public 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 uri
NullPointerException
- if one of the arguments is null
NamespaceRegistrationException
- 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 prefix
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |