org.jboss.resteasy.plugins.providers.jaxb.XmlNamespacePrefixMapper Maven / Gradle / Ivy
package org.jboss.resteasy.plugins.providers.jaxb;
import com.sun.xml.bind.marshaller.NamespacePrefixMapper;
import javax.xml.bind.annotation.XmlNs;
import java.util.HashMap;
import java.util.Map;
/**
* A XmlNamespecePrefixMapper.
*
* @author Ryan J. McDonough
* @version $Revision:$
*/
public class XmlNamespacePrefixMapper extends NamespacePrefixMapper
{
private final Map namespaceMap = new HashMap();
/**
* Create a new XmlNamespecePrefixMapper.
*
* @param namespeces
*/
public XmlNamespacePrefixMapper(final XmlNs... namespaces)
{
for (XmlNs namespace : namespaces)
{
namespaceMap.put(namespace.namespaceURI(), namespace.prefix());
}
}
/**
*
*/
@Override
public String getPreferredPrefix(String namespaceUri, String suggestion, boolean requirePrefix)
{
String prefix = namespaceMap.get(namespaceUri);
if (prefix != null)
{
return prefix;
}
return suggestion;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy