public class NamespaceContextImpl
extends java.lang.Object
implements javax.xml.namespace.NamespaceContext
NamespaceContext.| Modifier and Type | Field and Description |
|---|---|
private java.lang.String |
cachedPrefix |
private java.lang.String |
cachedURI |
private java.util.List |
prefixList |
| Constructor and Description |
|---|
NamespaceContextImpl() |
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
checkContext(int i)
This method is used to restore the namespace state
after an element is created.
|
void |
endPrefixMapping(java.lang.String pPrefix)
Removes the declaration of the prefix, which has been defined
last.
|
java.lang.String |
getAttributePrefix(java.lang.String pURI)
Returns a non-empty prefix currently mapped to the given
URL or null, if there is no such mapping.
|
int |
getContext()
Returns the current number of assigned prefixes.
|
java.lang.String |
getNamespaceURI(java.lang.String pPrefix)
Given a prefix, returns the URI to which the prefix is
currently mapped or null, if there is no such mapping.
|
java.lang.String |
getPrefix(java.lang.String pURI)
Returns a prefix currently mapped to the given URI or
null, if there is no such mapping.
|
java.util.List |
getPrefixes()
Returns a list of all prefixes, which are currently declared,
in the order of declaration.
|
java.util.Iterator |
getPrefixes(java.lang.String pURI)
Returns a collection to all prefixes bound to the given
namespace URI.
|
boolean |
isPrefixDeclared(java.lang.String pPrefix)
Returns whether a given prefix is currently declared.
|
void |
reset()
Resets the NamespaceSupport's state.
|
void |
startPrefixMapping(java.lang.String pPrefix,
java.lang.String pURI)
Declares a new prefix.
|
private java.util.List prefixList
private java.lang.String cachedPrefix
private java.lang.String cachedURI
public void reset()
public void startPrefixMapping(java.lang.String pPrefix,
java.lang.String pURI)
org.xml.sax.ContextHandler#startPrefixMapping(java.lang.String, java.lang.String).java.lang.IllegalArgumentException - Prefix or URI are null.public void endPrefixMapping(java.lang.String pPrefix)
org.xml.sax.ContextHandler#endPrefixMapping(java.lang.String).java.lang.IllegalArgumentException - The prefix is null.java.lang.IllegalStateException - The prefix is not the prefix, which
has been defined last. In other words, the calls to
startPrefixMapping(String, String), and
endPrefixMapping(String) aren't in LIFO order.public java.lang.String getNamespaceURI(java.lang.String pPrefix)
Note: This methods behaviour is precisely
defined by NamespaceContext.getNamespaceURI(java.lang.String).
getNamespaceURI in interface javax.xml.namespace.NamespaceContextpPrefix - The prefix in questionpublic java.lang.String getPrefix(java.lang.String pURI)
getAttributePrefix(String).
Note: This methods behaviour is precisely
defined by NamespaceContext.getPrefix(java.lang.String).getPrefix in interface javax.xml.namespace.NamespaceContextpURI - The namespace URI in questionjava.lang.IllegalArgumentException - The namespace URI is null.public java.lang.String getAttributePrefix(java.lang.String pURI)
getPrefix(String).pURI - Thhe namespace URI in questionjava.lang.IllegalArgumentException - The namespace URI is null.public java.util.Iterator getPrefixes(java.lang.String pURI)
NamespaceContext.getPrefixes(java.lang.String).getPrefixes in interface javax.xml.namespace.NamespaceContextpURI - The namespace prefix in questionpublic boolean isPrefixDeclared(java.lang.String pPrefix)
public int getContext()
ContentHandler.startElement(String, String, String, org.xml.sax.Attributes).
The return value is used as a saveable state. After
invoking
ContentHandler.endElement(String, String, String),
the state is restored by calling checkContext(int).public java.lang.String checkContext(int i)
getContext().
NamespaceSupport nss;
ContentHandler h;
int context = nss.getContext();
h.startElement("foo", "bar", "f:bar", new AttributesImpl());
...
h.endElement("foo", "bar", "f:bar");
for (;;) {
String prefix = nss.checkContext(context);
if (prefix == null) {
break;
}
h.endPrefixMapping(prefix);
}
public java.util.List getPrefixes()