org.simpleframework.xml.stream
Interface NamespaceMap

All Superinterfaces:
java.lang.Iterable<java.lang.String>

public interface NamespaceMap
extends java.lang.Iterable<java.lang.String>

The NamespaceMap object is used store the namespaces for an element. Each namespace added to this map can be added with a prefix. A prefix is added only if the associated reference has not been added to a parent element. If a parent element has the associated reference, then the parents prefix is the one that will be returned when requested from this map.

Author:
Niall Gallagher

Method Summary
 java.lang.String get(java.lang.String reference)
          This acquires the prefix for the specified namespace reference.
 java.lang.String getPrefix()
          This is the prefix that is associated with the source element.
 java.util.Iterator<java.lang.String> iterator()
          This returns an iterator for the namespace of all the nodes in this NamespaceMap.
 java.lang.String put(java.lang.String reference)
          This is used to add the namespace reference to the namespace map.
 java.lang.String put(java.lang.String reference, java.lang.String prefix)
          This is used to add the namespace reference to the namespace map.
 java.lang.String remove(java.lang.String reference)
          This is used to remove the prefix that is matched to the given reference.
 

Method Detail

getPrefix

java.lang.String getPrefix()
This is the prefix that is associated with the source element. If the source element does not contain a namespace reference then this will return its parents namespace. This ensures that if a namespace has been declared its child elements will inherit its prefix.

Returns:
this returns the prefix that is currently in scope

get

java.lang.String get(java.lang.String reference)
This acquires the prefix for the specified namespace reference. If the namespace reference has been set on this node with a given prefix then that prefix is returned, however if it has not been set this will search the parent elements to find the prefix that is in scope for the specified reference.

Parameters:
reference - the reference to find a matching prefix for
Returns:
this will return the prefix that is is scope

remove

java.lang.String remove(java.lang.String reference)
This is used to remove the prefix that is matched to the given reference. If no prefix is matched to the reference then this will silently return. This will only remove mappings from the current map, and will ignore the parent nodes.

Parameters:
reference - this is the reference that is to be removed
Returns:
this returns the prefix that was matched to this

iterator

java.util.Iterator<java.lang.String> iterator()
This returns an iterator for the namespace of all the nodes in this NamespaceMap. This allows the namespaces to be iterated within a for each loop in order to extract the prefix values associated with the map.

Specified by:
iterator in interface java.lang.Iterable<java.lang.String>
Returns:
this returns the namespaces contained in this map

put

java.lang.String put(java.lang.String reference)
This is used to add the namespace reference to the namespace map. If the namespace has been added to a parent node then this will not add the reference. The prefix added to the map will be the default namespace, which is an empty prefix.

Parameters:
reference - this is the reference to be added
Returns:
this returns the prefix that has been replaced

put

java.lang.String put(java.lang.String reference,
                     java.lang.String prefix)
This is used to add the namespace reference to the namespace map. If the namespace has been added to a parent node then this will not add the reference.

Parameters:
reference - this is the reference to be added
prefix - this is the prefix to be added to the reference
Returns:
this returns the prefix that has been replaced