org.apache.ws.jaxme.util
public class NamespaceSupport extends Object implements NamespaceContext
Similar to org.xml.sax.NamespaceSupport, but for marshalling and not for parsing XML.
Version: $Id: NamespaceSupport.java 232067 2005-03-10 10:14:08Z jochen $
Constructor Summary | |
---|---|
NamespaceSupport() Creates a new instance of NamespaceSupport. |
Method Summary | |
---|---|
String | checkContext(int i) This method is used to restore the namespace state
after an element is created. |
void | declarePrefix(String pPrefix, String pURI) Declares a new prefix. |
String | getAttributePrefix(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.
|
String | getNamespaceURI(String pPrefix) Given a prefix, returns the URI to which the prefix is currently mapped or null, if there is no such mapping. Note: This methods behaviour is precisely defined by {@link NamespaceContext#getNamespaceURI(java.lang.String)}. |
String | getPrefix(String pURI) Returns a prefix currently mapped to the given URI or null, if there is no such mapping. |
Iterator | getPrefixes(String pURI) Returns a collection to all prefixes bound to the given namespace URI. |
boolean | isPrefixDeclared(String pPrefix) Returns whether a given prefix is currently declared. |
void | reset() Resets the NamespaceSupport's state for reuse. |
void | undeclarePrefix(String pPrefix) Removes a prefix declaration. |
Creates a new instance of NamespaceSupport.
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); }
Declares a new prefix.
Returns a non-empty prefix currently mapped to the given URL or null, if there is no such mapping. This method may be used to find a possible prefix for an attributes namespace URI. For elements you should use {@link #getPrefix(String)}.
Parameters: pURI Thhe namespace URI in question
Throws: IllegalArgumentException The namespace URI is null.
Given a prefix, returns the URI to which the prefix is currently mapped or null, if there is no such mapping.
Note: This methods behaviour is precisely defined by {@link NamespaceContext#getNamespaceURI(java.lang.String)}.
Parameters: pPrefix The prefix in question
Returns a prefix currently mapped to the given URI or null, if there is no such mapping. This method may be used to find a possible prefix for an elements namespace URI. For attributes you should use {@link #getAttributePrefix(String)}.
Note: This methods behaviour is precisely defined by {@link NamespaceContext#getPrefix(java.lang.String)}.
Parameters: pURI The namespace URI in question
Throws: IllegalArgumentException The namespace URI is null.
Returns a collection to all prefixes bound to the given namespace URI.
Note: This methods behaviour is precisely defined by {@link NamespaceContext#getPrefixes(java.lang.String)}.
Parameters: pURI The namespace prefix in question
Returns whether a given prefix is currently declared.
Resets the NamespaceSupport's state for reuse.
Removes a prefix declaration. Assumes that the prefix is the current prefix. If not, throws a IllegalStateException.