public synchronized XmlNamespaceDictionary set(String alias, String uri) {
    String previousUri = null;
    String previousAlias = null;
    if (uri == null) {
      if (alias != null) {
        previousUri = namespaceAliasToUriMap.remove(alias);
      }
    } else if (alias == null) {
      previousAlias = namespaceUriToAliasMap.remove(uri);
    } else {
      previousUri =
          namespaceAliasToUriMap.put(
              Preconditions.checkNotNull(alias), Preconditions.checkNotNull(uri));
      if (!uri.equals(previousUri)) {
        previousAlias = namespaceUriToAliasMap.put(uri, alias);
      } else {
        previousUri = null;
      }
    }
    if (previousUri != null) {
      namespaceUriToAliasMap.remove(previousUri);
    }
    if (previousAlias != null) {
      namespaceAliasToUriMap.remove(previousAlias);
    }
    return this;
  }
public synchronized XmlNamespaceDictionary set ( String alias , String uri ) { String previousUri = null ; String previousAlias = null ; if ( uri == null ) { if ( alias != null ) { previousUri = namespaceAliasToUriMap . remove ( alias ) ; } } else if ( alias == null ) { previousAlias = namespaceUriToAliasMap . remove ( uri ) ; } else { previousUri = namespaceAliasToUriMap . put ( Preconditions . checkNotNull ( alias ) , Preconditions . checkNotNull ( uri ) ) ; if ( ! uri . equals ( previousUri ) ) { previousAlias = namespaceUriToAliasMap . put ( uri , alias ) ; } else { previousUri = null ; } } if ( previousUri != null ) { namespaceUriToAliasMap . remove ( previousUri ) ; } if ( previousAlias != null ) { namespaceAliasToUriMap . remove ( previousAlias ) ; } return this ; }
Adds a namespace of the given alias and URI.

<p>If the uri is {@code null}, the namespace alias will be removed. Similarly, if the alias is
{@code 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.

@param alias alias or {@code null} to remove the namespace URI
@param uri namespace URI or {@code null} to remove the namespace alias
@return this namespace dictionary
@since 1.3