org.mule.module.xml.stax.MapNamespaceContext Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mule-module-xml Show documentation
Show all versions of mule-module-xml Show documentation
Functionality for working with XML
/*
* Copyright (c) MuleSoft, Inc. All rights reserved. http://www.mulesoft.com
* The software in this package is published under the terms of the CPAL v1.0
* license, a copy of which has been included with this distribution in the
* LICENSE.txt file.
*/
package org.mule.module.xml.stax;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import javax.xml.namespace.NamespaceContext;
public final class MapNamespaceContext implements NamespaceContext
{
private Map namespaces = new HashMap();
public MapNamespaceContext()
{
super();
}
public MapNamespaceContext(final Map ns)
{
this();
this.namespaces = ns;
}
public void addNamespace(final String prefix, final String namespaceURI)
{
this.namespaces.put(prefix, namespaceURI);
}
public void addNamespaces(final Map ns)
{
this.namespaces.putAll(ns);
}
@Override
public String getNamespaceURI(String prefix)
{
return namespaces.get(prefix);
}
@Override
public String getPrefix(String namespaceURI)
{
for (Map.Entry entry : namespaces.entrySet())
{
if (entry.getValue().equals(namespaceURI))
{
return entry.getKey();
}
}
return null;
}
@Override
public Iterator getPrefixes(String namespaceURI)
{
return null;
}
public Map getUsedNamespaces()
{
return namespaces;
}
}