public class NamedNodeMapImpl
extends java.lang.Object
implements org.w3c.dom.NamedNodeMap, java.io.Serializable
Only one Node may be stored per name; attempting to store another will replace the previous value.
NOTE: The "primary" storage key is taken from the NodeName attribute of the node. The "secondary" storage key is the namespaceURI and localName, when accessed by DOM level 2 nodes. All nodes, even DOM Level 2 nodes are stored in a single ArrayList sorted by the primary "nodename" key.
NOTE: item()'s integer index does _not_ imply that the named nodes must be stored in an array; that's only an access method. Note too that these indices are "live"; if someone changes the map's contents, the indices associated with nodes may change.
Modifier and Type | Field and Description |
---|---|
protected static short |
CHANGED |
protected short |
flags |
protected static short |
HASDEFAULTS |
protected java.util.List |
nodes
Nodes.
|
protected NodeImpl |
ownerNode |
protected static short |
READONLY |
Modifier | Constructor and Description |
---|---|
protected |
NamedNodeMapImpl(NodeImpl ownerNode)
Constructs a named node map.
|
Modifier and Type | Method and Description |
---|---|
protected int |
addItem(org.w3c.dom.Node arg) |
protected void |
cloneContent(NamedNodeMapImpl srcmap) |
protected java.util.ArrayList |
cloneMap(java.util.ArrayList list)
NON-DOM: copy content of this map into the specified ArrayList
|
NamedNodeMapImpl |
cloneMap(NodeImpl ownerNode)
Cloning a NamedNodeMap is a DEEP OPERATION; it always clones
all the nodes contained in the map.
|
protected int |
findNamePoint(java.lang.String name,
int start)
Subroutine: Locate the named item, or the point at which said item
should be added.
|
protected int |
findNamePoint(java.lang.String namespaceURI,
java.lang.String name)
This findNamePoint is for DOM Level 2 Namespaces.
|
protected java.lang.Object |
getItem(int index) |
int |
getLength()
Report how many nodes are currently stored in this NamedNodeMap.
|
org.w3c.dom.Node |
getNamedItem(java.lang.String name)
Retrieve a node by name.
|
protected int |
getNamedItemIndex(java.lang.String namespaceURI,
java.lang.String localName) |
org.w3c.dom.Node |
getNamedItemNS(java.lang.String namespaceURI,
java.lang.String localName)
Introduced in DOM Level 2.
|
org.w3c.dom.Node |
item(int index)
Retrieve an item from the map by 0-based index.
|
protected boolean |
precedes(org.w3c.dom.Node a,
org.w3c.dom.Node b) |
void |
removeAll()
NON-DOM remove all elements from this map
|
protected void |
removeItem(int index)
NON-DOM: Remove attribute at specified index
|
org.w3c.dom.Node |
removeNamedItem(java.lang.String name)
Removes a node specified by name.
|
org.w3c.dom.Node |
removeNamedItemNS(java.lang.String namespaceURI,
java.lang.String name)
Introduced in DOM Level 2.
|
org.w3c.dom.Node |
setNamedItem(org.w3c.dom.Node arg)
Adds a node using its nodeName attribute.
|
org.w3c.dom.Node |
setNamedItemNS(org.w3c.dom.Node arg)
Adds a node using its namespaceURI and localName.
|
protected void |
setOwnerDocument(CoreDocumentImpl doc)
NON-DOM
set the ownerDocument of this node, and the attributes it contains
|
protected short flags
protected static final short READONLY
protected static final short CHANGED
protected static final short HASDEFAULTS
protected java.util.List nodes
protected NodeImpl ownerNode
protected NamedNodeMapImpl(NodeImpl ownerNode)
public int getLength()
getLength
in interface org.w3c.dom.NamedNodeMap
public org.w3c.dom.Node item(int index)
item
in interface org.w3c.dom.NamedNodeMap
index
- Which item to retrieve. Note that indices are just an
enumeration of the current contents; they aren't guaranteed to be
stable, nor do they imply any promises about the order of the
NamedNodeMap's contents. In other words, DO NOT assume either that
index(i) will always refer to the same entry, or that there is any
stable ordering of entries... and be prepared for double-reporting
or skips as insertion and deletion occur.public org.w3c.dom.Node getNamedItem(java.lang.String name)
getNamedItem
in interface org.w3c.dom.NamedNodeMap
name
- Name of a node to look up.public org.w3c.dom.Node getNamedItemNS(java.lang.String namespaceURI, java.lang.String localName)
Retrieves a node specified by local name and namespace URI.
getNamedItemNS
in interface org.w3c.dom.NamedNodeMap
namespaceURI
- The namespace URI of the node to retrieve.
When it is null or an empty string, this
method behaves like getNamedItem.localName
- The local name of the node to retrieve.public org.w3c.dom.Node setNamedItem(org.w3c.dom.Node arg) throws org.w3c.dom.DOMException
setNamedItem
in interface org.w3c.dom.NamedNodeMap
arg
- A node to store in a named node map. The node will later be
accessible using the value of the namespaceURI and localName
attribute of the node. If a node with those namespace URI and
local name is already present in the map, it is replaced by the new
one.org.w3c.dom.DOMException
- The exception description.NamedNodeMap.setNamedItem(org.w3c.dom.Node)
public org.w3c.dom.Node setNamedItemNS(org.w3c.dom.Node arg) throws org.w3c.dom.DOMException
setNamedItemNS
in interface org.w3c.dom.NamedNodeMap
arg
- A node to store in a named node map. The node will later be
accessible using the value of the namespaceURI and localName
attribute of the node. If a node with those namespace URI and
local name is already present in the map, it is replaced by the new
one.org.w3c.dom.DOMException
- WRONG_DOCUMENT_ERR: Raised if arg
was created from a
different document than the one that created this map.
arg
is an
Attr
that is already an attribute of another
Element
object. The DOM user must explicitly clone
Attr
nodes to re-use them in other elements.
NamedNodeMap.setNamedItem(org.w3c.dom.Node)
public org.w3c.dom.Node removeNamedItem(java.lang.String name) throws org.w3c.dom.DOMException
org.w3c.dom.NamedNodeMap
removeNamedItem
in interface org.w3c.dom.NamedNodeMap
name
- The nodeName
of the node to remove.org.w3c.dom.DOMException
- NOT_FOUND_ERR: Raised if there is no node named name
in
this map.
public org.w3c.dom.Node removeNamedItemNS(java.lang.String namespaceURI, java.lang.String name) throws org.w3c.dom.DOMException
Removes a node specified by local name and namespace URI.
removeNamedItemNS
in interface org.w3c.dom.NamedNodeMap
namespaceURI
- The namespace URI of the node to remove.
When it is null or an empty string, this
method behaves like removeNamedItem.name
- The local name of the node to remove.NOT_FOUND_ERR:
- Raised if there is no node named
name in the map.org.w3c.dom.DOMException
- NOT_FOUND_ERR: Raised if there is no node with the specified
namespaceURI
and localName
in this map.
public NamedNodeMapImpl cloneMap(NodeImpl ownerNode)
protected void cloneContent(NamedNodeMapImpl srcmap)
protected void setOwnerDocument(CoreDocumentImpl doc)
protected int findNamePoint(java.lang.String name, int start)
name
- Name of a node to look up.protected int findNamePoint(java.lang.String namespaceURI, java.lang.String name)
protected boolean precedes(org.w3c.dom.Node a, org.w3c.dom.Node b)
protected void removeItem(int index)
protected java.lang.Object getItem(int index)
protected int addItem(org.w3c.dom.Node arg)
protected java.util.ArrayList cloneMap(java.util.ArrayList list)
list
- ArrayList to copy information into.protected int getNamedItemIndex(java.lang.String namespaceURI, java.lang.String localName)
public void removeAll()
Copyright © 1999-2022 The Apache Software Foundation. All Rights Reserved.