org.inria.ns.reflex.xml.dom
Class MapOfNamedNode

java.lang.Object
  extended by org.inria.ns.reflex.xml.dom.MapOfNamedNode
All Implemented Interfaces:
Map

public class MapOfNamedNode
extends Object
implements Map

A named node map.

Just for adding a map view of the underlying map.

Author:
Philippe Poulard
See Also:
AttributesMap, NamedNodeMap, Element, DocumentType

Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Constructor Summary
MapOfNamedNode(Element element)
          Create a new map of attributes.
MapOfNamedNode(NamedNodeMap namedNodeMap, Node owner)
          Create a new map of named nodes.
 
Method Summary
 void clear()
          Remove all the nodes of this map.
 boolean containsKey(Object key)
          Indicates whether this map contains the given key or not.
 boolean containsValue(Object value)
          Lookup for a value.
 Set entrySet()
          Return the set of attributes contained in this map.
 Object get(Object name)
          Return the value of the node that has the name given.
 int getLength()
          Return the number of nodes in this map.
 Node getNamedItem(String name)
          Get the node that has the name given.
 Node getNamedItemNS(String namespaceURI, String localName)
          Get the node that has the name given.
 boolean isEmpty()
          Indicates whether this map is empty or not.
 Node item(int index)
          Get the node at the index specified.
 Set keySet()
          Return the set of node names contained in this map.
 Object put(Object name, Object value)
          Put a node in this map.
 void putAll(Map nodes)
          Put all nodes of the given map in this map.
 Object remove(Object name)
          Remove the node that has the name given.
 Node removeNamedItem(String name)
          Remove a node.
 Node removeNamedItemNS(String namespaceURI, String localName)
          Remove a node.
 void removeNode(Node node)
          Remove a node.
 Node setNamedItem(Node arg)
          Add a node in this map.
 Node setNamedItemNS(Node arg)
          Add a node in this map.
 int size()
          Return the number of nodes contained in this map.
 Collection values()
          Return the set of attribute values contained in this map.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Constructor Detail

MapOfNamedNode

public MapOfNamedNode(Element element)
Create a new map of attributes.

Parameters:
element - The attributes of the element to copy in this map.

MapOfNamedNode

public MapOfNamedNode(NamedNodeMap namedNodeMap,
                      Node owner)
Create a new map of named nodes.

Parameters:
namedNodeMap - The nodes that are in this map.
owner - The node that own the map. Either an element, a doctype, or a DOMFragment.
See Also:
Element, DocumentType
Method Detail

size

public int size()
Return the number of nodes contained in this map.

Specified by:
size in interface Map
Returns:
The number of nodes contained in this map.
See Also:
NamedNodeMap.getLength()

isEmpty

public boolean isEmpty()
Indicates whether this map is empty or not.

Specified by:
isEmpty in interface Map
Returns:
true if there is no attribute in this map, false otherwise.

containsKey

public boolean containsKey(Object key)
Indicates whether this map contains the given key or not.

Specified by:
containsKey in interface Map
Parameters:
key - The key to look for.
Returns:
true if the key is in this map, false otherwise.
See Also:
get(Object)

containsValue

public boolean containsValue(Object value)
Lookup for a value.

Specified by:
containsValue in interface Map
Parameters:
value - The value to look for, which can be converted to a String if necessary.
Returns:
true if the value is in this map, false otherwise.

get

public Object get(Object name)
Return the value of the node that has the name given.

Specified by:
get in interface Map
Parameters:
name - The name of the node to look for. Can be a String or a QName.
Returns:
The string value of the node, or null.
See Also:
QName

put

public Object put(Object name,
                  Object value)
Put a node in this map.

Specified by:
put in interface Map
Parameters:
name - The name of the node. Can be a String or a QName.
value - The value of the node, which can be converted to a String if necessary.
Returns:
The old String value of the node, or null.
See Also:
QName

remove

public Object remove(Object name)
Remove the node that has the name given.

Specified by:
remove in interface Map
Parameters:
name - The name of the node to remove. Can be a String or a QName.
Returns:
The old String value of the node, or null.
See Also:
QName

putAll

public void putAll(Map nodes)
Put all nodes of the given map in this map.

Specified by:
putAll in interface Map
Parameters:
nodes - The nodes to put in this map.
See Also:
put(Object, Object)

keySet

public Set keySet()
Return the set of node names contained in this map.

Specified by:
keySet in interface Map
Parameters:
A - set of QName.
See Also:
QName

values

public Collection values()
Return the set of attribute values contained in this map.

Specified by:
values in interface Map
Parameters:
A - collection of String.

removeNode

public void removeNode(Node node)
Remove a node.

Parameters:
node - The node to remove from this map.

entrySet

public Set entrySet()
Return the set of attributes contained in this map.

Specified by:
entrySet in interface Map
Parameters:
A - set of Map.Entry which key is a QName and value is a String.
See Also:
QName, Map

clear

public void clear()
Remove all the nodes of this map.

Specified by:
clear in interface Map
See Also:
Map.clear()

getNamedItem

public Node getNamedItem(String name)
Get the node that has the name given.

Parameters:
name - The name of the node.
Returns:
The node of the map that has the name given, or null.
See Also:
NamedNodeMap.getNamedItem(java.lang.String)

setNamedItem

public Node setNamedItem(Node arg)
                  throws DOMException
Add a node in this map.

Parameters:
arg - The node to add.
Returns:
The old node, or null.
Throws:
DOMException
See Also:
NamedNodeMap.setNamedItem(org.w3c.dom.Node)

removeNamedItem

public Node removeNamedItem(String name)
                     throws DOMException
Remove a node.

Parameters:
name - The name of the node to remove.
Returns:
The old node, or null.
Throws:
DOMException
See Also:
NamedNodeMap.removeNamedItem(java.lang.String)

item

public Node item(int index)
Get the node at the index specified.

Parameters:
index - The index.
Returns:
The node at the index specified.
See Also:
NamedNodeMap.item(int)

getLength

public int getLength()
Return the number of nodes in this map.

Returns:
The number of nodes in this map.
See Also:
NamedNodeMap.getLength()

getNamedItemNS

public Node getNamedItemNS(String namespaceURI,
                           String localName)
Get the node that has the name given.

Parameters:
namespaceURI - The namespace URI of the node.
localName - The local name of the node.
See Also:
NamedNodeMap.getNamedItemNS(java.lang.String, java.lang.String)

setNamedItemNS

public Node setNamedItemNS(Node arg)
                    throws DOMException
Add a node in this map.

Parameters:
arg - The node to add.
Returns:
The old node, or null.
Throws:
DOMException
See Also:
NamedNodeMap.setNamedItemNS(org.w3c.dom.Node)

removeNamedItemNS

public Node removeNamedItemNS(String namespaceURI,
                              String localName)
                       throws DOMException
Remove a node.

Parameters:
namespaceURI - The namespace URI of the node to remove.
localName - The local name of the node to remove.
Returns:
The old node, or null.
Throws:
DOMException
See Also:
NamedNodeMap.removeNamedItemNS(java.lang.String, java.lang.String)