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,INamespaceContext,Serializable,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
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description MapBasedNamespaceContext()Default constructor.MapBasedNamespaceContext(IIterableNamespaceContext aOther)Constructor to copy from anotherIIterableNamespaceContextMapBasedNamespaceContext(MapBasedNamespaceContext aOther)Copy constructor.MapBasedNamespaceContext(Map<String,String> aOther)Constructor with prefix to namespace URL map
-
Method Summary
-
Methods inherited from class com.helger.xml.namespace.AbstractNamespaceContext
getNamespaceURI, getPrefix, getPrefixes
-
-
-
-
Constructor Detail
-
MapBasedNamespaceContext
public MapBasedNamespaceContext()
Default constructor.
-
MapBasedNamespaceContext
public MapBasedNamespaceContext(@Nullable MapBasedNamespaceContext aOther)
Copy constructor.- Parameters:
aOther- Object to copy from. May benull.
-
MapBasedNamespaceContext
public MapBasedNamespaceContext(@Nullable IIterableNamespaceContext aOther)
Constructor to copy from anotherIIterableNamespaceContext- Parameters:
aOther- Object to copy the data from. May benull.
-
-
Method Detail
-
getDefaultNamespaceURI
@Nullable public String 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(String, String)
-
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:
addMapping(String, String)
-
addMappings
@Nonnull public final MapBasedNamespaceContext addMappings(@Nullable IIterableNamespaceContext aOther)
-
setMappings
@Nonnull public final MapBasedNamespaceContext setMappings(@Nullable IIterableNamespaceContext aOther)
-
addMappings
@Nonnull public final MapBasedNamespaceContext addMappings(@Nullable Map<String,String> aOther)
-
setMappings
@Nonnull public final MapBasedNamespaceContext setMappings(@Nullable Map<String,String> aOther)
-
addDefaultNamespaceURI
@Nonnull public final MapBasedNamespaceContext addDefaultNamespaceURI(@Nonnull String sNamespaceURI)
Add the default namespace URL- 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- Parameters:
sNamespaceURI- The namespace URI to be used as the default. May not benullbut maybe empty.- Returns:
- this
-
removeMapping
@Nonnull public com.helger.commons.state.EChange removeMapping(@Nullable String sPrefix)
-
clear
@Nonnull public com.helger.commons.state.EChange clear()
-
getCustomPrefixes
@Nullable public Iterator<String> getCustomPrefixes(@Nonnull String sNamespaceURI)
- Specified by:
getCustomPrefixesin classAbstractNamespaceContext
-
getCustomPrefix
@Nullable public String getCustomPrefix(@Nonnull String sNamespaceURI)
- Specified by:
getCustomPrefixin classAbstractNamespaceContext
-
getCustomNamespaceURI
@Nullable public String getCustomNamespaceURI(@Nonnull String sPrefix)
- 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
@Nonnegative public int getMappingCount()
-
getClone
@Nonnull @ReturnsMutableCopy public MapBasedNamespaceContext getClone()
- Specified by:
getClonein interfacecom.helger.commons.lang.ICloneable<MapBasedNamespaceContext>
-
-