Package com.helger.xml.namespace
Class MapBasedNamespaceContext
java.lang.Object
com.helger.xml.namespace.AbstractNamespaceContext
com.helger.xml.namespace.MapBasedNamespaceContext
- All Implemented Interfaces:
com.helger.commons.lang.ICloneable<MapBasedNamespaceContext>,IIterableNamespaceContext,NamespaceContext
@NotThreadSafe
public class MapBasedNamespaceContext
extends AbstractNamespaceContext
implements com.helger.commons.lang.ICloneable<MapBasedNamespaceContext>
Represents a namespace context a 1:n (namespace:prefix) mapping.
- Author:
- Philip Helger
-
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.Constructor to copy from anotherIIterableNamespaceContextCopy constructor.MapBasedNamespaceContext(Map<String, String> aOther) Constructor with prefix to namespace URL map -
Method Summary
Modifier and TypeMethodDescriptionfinal MapBasedNamespaceContextaddDefaultNamespaceURI(String sNamespaceURI) Add the default namespace URL, so the mapping to the default XML namespace prefix ("").final MapBasedNamespaceContextaddMapping(String sPrefix, String sNamespaceURI) Add a new prefix to namespace mapping.final MapBasedNamespaceContextaddMappings(IIterableNamespaceContext aOther) final MapBasedNamespaceContextaddMappings(Map<String, String> aOther) clear()booleangetClone()getCustomNamespaceURI(String sPrefix) getCustomPrefix(String sNamespaceURI) getCustomPrefixes(String sNamespaceURI) intGet all contained mappings.booleaninthashCode()booleanisNamespaceURIMapped(String sNamespaceURI) booleanisPrefixMapped(String sPrefix) removeMapping(String sPrefix) final MapBasedNamespaceContextsetDefaultNamespaceURI(String sNamespaceURI) Set the default namespace URL, so the mapping to the default XML namespace prefix ("").final MapBasedNamespaceContextsetMapping(String sPrefix, String sNamespaceURI) Add a new prefix to namespace mapping.final MapBasedNamespaceContextsetMappings(IIterableNamespaceContext aOther) final MapBasedNamespaceContextsetMappings(Map<String, String> aOther) toString()Methods inherited from class com.helger.xml.namespace.AbstractNamespaceContext
getNamespaceURI, getPrefix, getPrefixes
-
Constructor Details
-
MapBasedNamespaceContext
public MapBasedNamespaceContext()Default constructor. -
MapBasedNamespaceContext
Copy constructor.- Parameters:
aOther- Object to copy from. May benull.
-
MapBasedNamespaceContext
Constructor to copy from anotherIIterableNamespaceContext- Parameters:
aOther- Object to copy the data from. May benull.
-
MapBasedNamespaceContext
Constructor with prefix to namespace URL map- Parameters:
aOther- Map with prefix to namespace URL. May benull.- Since:
- 8.5.3
-
-
Method Details
-
getDefaultNamespaceURI
- Specified by:
getDefaultNamespaceURIin classAbstractNamespaceContext
-
addMapping
@Nonnull public final MapBasedNamespaceContext addMapping(@Nonnull String sPrefix, @Nonnull String sNamespaceURI) Add a new prefix to namespace mapping. If a prefix is already present, an IllegalArgumentException is thrown.- Parameters:
sPrefix- The prefix to be used. May not benull. If it equalsXMLConstants.DEFAULT_NS_PREFIXthat the namespace is considered to be the default one.sNamespaceURI- The namespace URI to be mapped. May not benullbut maybe empty.- Returns:
- this
- Throws:
IllegalArgumentException- If another mapping for the passed prefix is already present- See Also:
-
setMapping
@Nonnull public final MapBasedNamespaceContext setMapping(@Nonnull String sPrefix, @Nonnull String sNamespaceURI) Add a new prefix to namespace mapping. If a prefix is already present it is overwritten.- Parameters:
sPrefix- The prefix to be used. May not benull. If it equalsXMLConstants.DEFAULT_NS_PREFIXthat the namespace is considered to be the default one.sNamespaceURI- The namespace URI to be mapped. May not benullbut maybe empty.- Returns:
- this
- See Also:
-
addMappings
@Nonnull public final MapBasedNamespaceContext addMappings(@Nullable IIterableNamespaceContext aOther) -
setMappings
@Nonnull public final MapBasedNamespaceContext setMappings(@Nullable IIterableNamespaceContext aOther) -
addMappings
-
setMappings
-
addDefaultNamespaceURI
@Nonnull public final MapBasedNamespaceContext addDefaultNamespaceURI(@Nonnull String sNamespaceURI) Add the default namespace URL, so the mapping to the default XML namespace prefix ("").- Parameters:
sNamespaceURI- The namespace URI to be used as the default. May not benullbut maybe empty.- Returns:
- this
-
setDefaultNamespaceURI
@Nonnull public final MapBasedNamespaceContext setDefaultNamespaceURI(@Nonnull String sNamespaceURI) Set the default namespace URL, so the mapping to the default XML namespace prefix ("").- Parameters:
sNamespaceURI- The namespace URI to be used as the default. May not benullbut maybe empty.- Returns:
- this
-
removeMapping
-
isPrefixMapped
-
isNamespaceURIMapped
-
clear
-
getCustomPrefixes
- Specified by:
getCustomPrefixesin classAbstractNamespaceContext
-
getCustomPrefix
- Specified by:
getCustomPrefixin classAbstractNamespaceContext
-
getCustomNamespaceURI
- Specified by:
getCustomNamespaceURIin classAbstractNamespaceContext
-
getPrefixToNamespaceURIMap
@Nonnull @ReturnsMutableCopy public com.helger.commons.collection.impl.ICommonsOrderedMap<String,String> getPrefixToNamespaceURIMap()Description copied from interface:IIterableNamespaceContextGet all contained mappings.- Specified by:
getPrefixToNamespaceURIMapin interfaceIIterableNamespaceContext- Returns:
- The map with all prefixes mapped to the namespace URIs.
-
hasAnyMapping
public boolean hasAnyMapping() -
getMappingCount
-
getClone
- Specified by:
getClonein interfacecom.helger.commons.lang.ICloneable<MapBasedNamespaceContext>
-
equals
-
hashCode
public int hashCode() -
toString
-