# Class XmlNamespaceDictionary (2.1.0)

<button class="button button-with-icon cloud-select-dropdown__button " aria-haspopup="true">Version latest</button>

- [2.1.0 (latest)](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.xml.XmlNamespaceDictionary)
- [2.0.3](https://docs.cloud.google.com/java/docs/reference/google-http-client/2.0.3/com.google.api.client.xml.XmlNamespaceDictionary)
- [1.47.1](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.47.1/com.google.api.client.xml.XmlNamespaceDictionary)
- [1.46.3](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.46.3/com.google.api.client.xml.XmlNamespaceDictionary)
- [1.45.3](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.45.3/com.google.api.client.xml.XmlNamespaceDictionary)
- [1.44.2](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.44.2/com.google.api.client.xml.XmlNamespaceDictionary)
- [1.43.2](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.43.2/com.google.api.client.xml.XmlNamespaceDictionary)
- [1.42.3](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.42.3/com.google.api.client.xml.XmlNamespaceDictionary)
- [1.41.8](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.41.8/com.google.api.client.xml.XmlNamespaceDictionary)

    public final class XmlNamespaceDictionary

[Beta](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.util.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");
     
## Inheritance

[Object](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html) \> XmlNamespaceDictionary

## Inherited Members

[Object.clone()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#clone--) [Object.equals(Object)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#equals-java.lang.Object-) [Object.finalize()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#finalize--) [Object.getClass()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#getClass--) [Object.hashCode()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#hashCode--) [Object.notify()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notify--) [Object.notifyAll()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notifyAll--) [Object.toString()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#toString--) [Object.wait()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait--) [Object.wait(long)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-) [Object.wait(long,int)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-int-)

## 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.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `uri` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` namespace URI |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |   |

### 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.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/util/Map.html<https://docs.oracle.com/javase/8/docs/api/java/lang/String.html,https://docs.oracle.com/javase/8/docs/api/java/lang/String.html>` |   |

### getUriForAlias(String alias)

    public synchronized String getUriForAlias(String alias)

Returns the namespace URI for the given namespace alias (or `""` for the default
namespace).

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `alias` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` namespace alias (or `""` for the default namespace) |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |   |

### 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).

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/util/Map.html<https://docs.oracle.com/javase/8/docs/api/java/lang/String.html,https://docs.oracle.com/javase/8/docs/api/java/lang/String.html>` |   |

### 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.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `serializer` | `org.xmlpull.v1.XmlSerializer` |
| `elementName` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` XML element local name prefixed by its namespace alias |
| `element` | `https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html` element data object ([GenericXml](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.xml.GenericXml), [Map](https://docs.oracle.com/javase/8/docs/api/java/util/Map.html), or any object with public fields) |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/io/IOException.html` | 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.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `serializer` | `org.xmlpull.v1.XmlSerializer` |
| `elementNamespaceUri` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` XML namespace URI or `null` for no namespace |
| `elementLocalName` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` XML local name |
| `element` | `https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html` element data object ([GenericXml](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.xml.GenericXml), [Map](https://docs.oracle.com/javase/8/docs/api/java/util/Map.html), or any object with public fields) |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/io/IOException.html` | 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.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `alias` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` alias or `null` to remove the namespace URI |
| `uri` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` namespace URI or `null` to remove the namespace alias |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.xml.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.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `elementName` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` optional XML element local name prefixed by its namespace alias -- for example `"atom:entry"` -- or `null` to make up something |
| `element` | `https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html` element data object ([GenericXml](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.xml.GenericXml), [Map](https://docs.oracle.com/javase/8/docs/api/java/util/Map.html), or any object with public fields) |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |   |