public final class XmlNamespaceDictionary
Beta
Thread-safe XML namespace dictionary that provides a one-to-one map of namespace alias to URI.
Implementation is thread-safe. For maximum efficiency, applications should use a single globally-shared instance of the XML namespace dictionary.
A namespace alias is uniquely mapped to a single namespace URI, and a namespace URI is uniquely mapped to a single namespace alias. In other words, it is not possible to have duplicates.
Sample usage:
static final XmlNamespaceDictionary DICTIONARY = new XmlNamespaceDictionary()
.set("", "http://www.w3.org/2005/Atom")
.set("activity", "http://activitystrea.ms/spec/1.0/")
.set("georss", "http://www.georss.org/georss")
.set("media", "http://search.yahoo.com/mrss/")
.set("thr", "http://purl.org/syndication/thread/1.0");
Constructors
XmlNamespaceDictionary()
public XmlNamespaceDictionary()
Methods
getAliasForUri(String uri)
public synchronized String getAliasForUri(String uri)
Returns the namespace alias (or ""
for the default namespace) for the given namespace
URI.
Name | Description |
uri | String namespace URI |
Type | Description |
String |
getAliasToUriMap()
public synchronized Map<String,String> getAliasToUriMap()
Returns an unmodified set of map entries for the map from namespace alias (or ""
for
the default namespace) to namespace URI.
Type | Description |
Map<String,String> |
getUriForAlias(String alias)
public synchronized String getUriForAlias(String alias)
Returns the namespace URI for the given namespace alias (or ""
for the default
namespace).
Name | Description |
alias | String namespace alias (or |
Type | Description |
String |
getUriToAliasMap()
public synchronized Map<String,String> getUriToAliasMap()
Returns an unmodified set of map entries for the map from namespace URI to namespace alias (or
""
for the default namespace).
Type | Description |
Map<String,String> |
serialize(XmlSerializer serializer, String elementName, Object element)
public void serialize(XmlSerializer serializer, String elementName, Object element)
Shows a debug string representation of an element data object of key/value pairs.
Name | Description |
serializer | org.xmlpull.v1.XmlSerializer |
elementName | String XML element local name prefixed by its namespace alias |
element | Object element data object (GenericXml, Map, or any object with public fields) |
Type | Description |
IOException | I/O exception |
serialize(XmlSerializer serializer, String elementNamespaceUri, String elementLocalName, Object element)
public void serialize(XmlSerializer serializer, String elementNamespaceUri, String elementLocalName, Object element)
Shows a debug string representation of an element data object of key/value pairs.
Name | Description |
serializer | org.xmlpull.v1.XmlSerializer |
elementNamespaceUri | String XML namespace URI or |
elementLocalName | String XML local name |
element | Object element data object (GenericXml, Map, or any object with public fields) |
Type | Description |
IOException | I/O exception |
set(String alias, String uri)
public synchronized XmlNamespaceDictionary set(String alias, String uri)
Adds a namespace of the given alias and URI.
If the uri is null
, the namespace alias will be removed. Similarly, if the alias is
null
, the namespace URI will be removed. Otherwise, if the alias is already mapped to a
different URI, it will be remapped to the new URI. Similarly, if a URI is already mapped to a
different alias, it will be remapped to the new alias.
Name | Description |
alias | String alias or |
uri | String namespace URI or |
Type | Description |
XmlNamespaceDictionary | this namespace dictionary |
toStringOf(String elementName, Object element)
public String toStringOf(String elementName, Object element)
Shows a debug string representation of an element data object of key/value pairs.
Name | Description |
elementName | String optional XML element local name prefixed by its namespace alias -- for
example |
element | Object element data object (GenericXml, Map, or any object with public fields) |
Type | Description |
String |