APIdia Launch Partner
Top Description Fields Constructors Methods
com.sun.org.apache.xerces.internal.dom

public Class NamedNodeMapImpl

extends Object
implements NamedNodeMap, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, org.w3c.dom.NamedNodeMap
Known Direct Subclasses
com.sun.org.apache.xerces.internal.dom.AttributeMap
Imports
java.io.IOException, .ObjectInputStream, .ObjectOutputStream, .Serializable, java.util.ArrayList, .List, .Vector, org.w3c.dom.DOMException, .NamedNodeMap, .Node

NamedNodeMaps represent collections of Nodes that can be accessed by name. Entity and Notation nodes are stored in NamedNodeMaps attached to the DocumentType. Attributes are placed in a NamedNodeMap attached to the elem they're related too. However, because attributes require more work, such as firing mutation events, they are stored in a subclass of NamedNodeMapImpl.

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 Vector 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.

Since
PR-DOM-Level-1-19980818.

Field Summary

Modifier and TypeField and Description
protected static final short
protected short
protected static final short
protected List<Node>
nodes

Nodes.

protected NodeImpl
protected static final short
pack-priv static final long
serialVersionUID

Serialization version.

Constructor Summary

AccessConstructor and Description
protected
NamedNodeMapImpl(NodeImpl ownerNode)

Constructs a named node map.

Method Summary

Modifier and TypeMethod and Description
protected int
pack-priv final boolean
pack-priv final void
changed(boolean value)

protected void
public NamedNodeMapImpl
cloneMap(NodeImpl ownerNode)

Cloning a NamedNodeMap is a DEEP OPERATION; it always clones all the nodes contained in the map.

protected List<Node>

Returns:

A copy of this node named map
cloneMap
(List<Node>
ArrayList to copy information into.
list
)

NON-DOM: copy content of this map into the specified ArrayList

protected int

Returns:

If positive or zero, the index of the found item. If negative, index of the appropriate point at which to insert the item, encoded as -1-index and hence reconvertable by subtracting it from -1. (Encoding because I don't want to recompare the strings but don't want to burn bytes on a datatype to hold a flagged value.)
findNamePoint
(String
Name of a node to look up.
name
,
int start)

Subroutine: Locate the named item, or the point at which said item should be added.

protected int
findNamePoint(String namespaceURI, String name)

This findNamePoint is for DOM Level 2 Namespaces.

protected Object
getItem(int index)

public int
getLength()

Implements org.w3c.dom.NamedNodeMap.getLength.

Report how many nodes are currently stored in this NamedNodeMap.

public Node

Returns:

the Node (of unspecified sub-class) stored with that name, or null if no value has been assigned to that name.
getNamedItem
(String
Name of a node to look up.
name
)

Implements org.w3c.dom.NamedNodeMap.getNamedItem.

Retrieve a node by name.

protected int
getNamedItemIndex(String namespaceURI, String localName)

public Node

Returns:

Node A Node (of any type) with the specified name, or null if the specified name did not identify any node in the map.
getNamedItemNS
(String
The namespace URI of the node to retrieve. When it is null or an empty string, this method behaves like getNamedItem.
namespaceURI
,
String
The local name of the node to retrieve.
localName
)

Implements org.w3c.dom.NamedNodeMap.getNamedItemNS.

Introduced in DOM Level 2.

pack-priv boolean
getReadOnly()

Internal subroutine returns this NodeNameMap's (shallow) readOnly value.

pack-priv final boolean
pack-priv final void
hasDefaults(boolean value)

pack-priv final boolean
pack-priv final void
isReadOnly(boolean value)

public Node

Returns:

the node which currenly has the specified index, or null if index is greater than or equal to getLength().
item
(int
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.
index
)

Implements org.w3c.dom.NamedNodeMap.item.

Retrieve an item from the map by 0-based index.

protected boolean
private void
public void
removeAll()

NON-DOM remove all elements from this map

protected void
removeItem(int index)

NON-DOM: Remove attribute at specified index

public Node
removeNamedItem(String name)

Implements org.w3c.dom.NamedNodeMap.removeNamedItem.

Removes a node specified by name.

public Node

Returns:

Node The node removed from the map if a node with such a local name and namespace URI exists.
removeNamedItemNS
(String
The namespace URI of the node to remove. When it is null or an empty string, this method behaves like removeNamedItem.
namespaceURI
,
String
The local name of the node to remove.
name
)

Implements org.w3c.dom.NamedNodeMap.removeNamedItemNS.

Introduced in DOM Level 2.

public Node

Returns:

If the new Node replaces an existing node the replaced Node is returned, otherwise null is returned.
setNamedItem
(Node
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.
arg
)

Implements org.w3c.dom.NamedNodeMap.setNamedItem.

Adds a node using its nodeName attribute.

public Node

Returns:

If the new Node replaces an existing node the replaced Node is returned, otherwise null is returned.
setNamedItemNS
(Node
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.
arg
)

Implements org.w3c.dom.NamedNodeMap.setNamedItemNS.

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

pack-priv void
setReadOnly(boolean
boolean true to make read-only, false to permit editing.
readOnly
,
boolean
boolean true to pass this request along to the contained nodes, false to only toggle the NamedNodeMap itself. I expect that the shallow version of this operation will never be used, but I want to design it in now, while I'm thinking about it.
deep
)

Internal subroutine to allow read-only Nodes to make their contained NamedNodeMaps readonly too.

private void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

CHANGEDback to summary
protected static final short CHANGED
flagsback to summary
protected short flags
HASDEFAULTSback to summary
protected static final short HASDEFAULTS
nodesback to summary
protected List<Node> nodes

Nodes.

Annotations
@SuppressWarnings:serial
ownerNodeback to summary
protected NodeImpl ownerNode
READONLYback to summary
protected static final short READONLY
serialVersionUIDback to summary
pack-priv static final long serialVersionUID

Serialization version.

Constructor Detail

NamedNodeMapImplback to summary
protected NamedNodeMapImpl(NodeImpl ownerNode)

Constructs a named node map.

Method Detail

addItemback to summary
protected int addItem(Node arg)
changedback to summary
pack-priv final boolean changed()
changedback to summary
pack-priv final void changed(boolean value)
cloneContentback to summary
protected void cloneContent(NamedNodeMapImpl srcmap)
cloneMapback to summary
public NamedNodeMapImpl cloneMap(NodeImpl ownerNode)

Cloning a NamedNodeMap is a DEEP OPERATION; it always clones all the nodes contained in the map.

cloneMapback to summary
protected List<Node> cloneMap(List<Node> list)

NON-DOM: copy content of this map into the specified ArrayList

Parameters
list:List<Node>

ArrayList to copy information into.

Returns:List<Node>

A copy of this node named map

findNamePointback to summary
protected int findNamePoint(String name, int start)

Subroutine: Locate the named item, or the point at which said item should be added.

Parameters
name:String

Name of a node to look up.

Returns:int

If positive or zero, the index of the found item. If negative, index of the appropriate point at which to insert the item, encoded as -1-index and hence reconvertable by subtracting it from -1. (Encoding because I don't want to recompare the strings but don't want to burn bytes on a datatype to hold a flagged value.)

findNamePointback to summary
protected int findNamePoint(String namespaceURI, String name)

This findNamePoint is for DOM Level 2 Namespaces.

getItemback to summary
protected Object getItem(int index)
getLengthback to summary
public int getLength()

Implements org.w3c.dom.NamedNodeMap.getLength.

Report how many nodes are currently stored in this NamedNodeMap.

Caveat

This is a count rather than an index, so the highest-numbered node at any time can be accessed via item(getLength()-1).

getNamedItemback to summary
public Node getNamedItem(String name)

Implements org.w3c.dom.NamedNodeMap.getNamedItem.

Retrieve a node by name.

Parameters
name:String

Name of a node to look up.

Returns:Node

the Node (of unspecified sub-class) stored with that name, or null if no value has been assigned to that name.

getNamedItemIndexback to summary
protected int getNamedItemIndex(String namespaceURI, String localName)
getNamedItemNSback to summary
public Node getNamedItemNS(String namespaceURI, String localName)

Implements org.w3c.dom.NamedNodeMap.getNamedItemNS.

Introduced in DOM Level 2.

Retrieves a node specified by local name and namespace URI.

Parameters
namespaceURI:String

The namespace URI of the node to retrieve. When it is null or an empty string, this method behaves like getNamedItem.

localName:String

The local name of the node to retrieve.

Returns:Node

Node A Node (of any type) with the specified name, or null if the specified name did not identify any node in the map.

getReadOnlyback to summary
pack-priv boolean getReadOnly()

Internal subroutine returns this NodeNameMap's (shallow) readOnly value.

hasDefaultsback to summary
pack-priv final boolean hasDefaults()
hasDefaultsback to summary
pack-priv final void hasDefaults(boolean value)
isReadOnlyback to summary
pack-priv final boolean isReadOnly()
isReadOnlyback to summary
pack-priv final void isReadOnly(boolean value)
itemback to summary
public Node item(int index)

Implements org.w3c.dom.NamedNodeMap.item.

Retrieve an item from the map by 0-based index.

Parameters
index:int

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.

Returns:Node

the node which currenly has the specified index, or null if index is greater than or equal to getLength().

precedesback to summary
protected boolean precedes(Node a, Node b)
readObjectback to summary
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException
removeAllback to summary
public void removeAll()

NON-DOM remove all elements from this map

removeItemback to summary
protected void removeItem(int index)

NON-DOM: Remove attribute at specified index

removeNamedItemback to summary
public Node removeNamedItem(String name) throws DOMException

Implements org.w3c.dom.NamedNodeMap.removeNamedItem.

Doc from org.w3c.dom.NamedNodeMap.removeNamedItem.

Removes a node specified by name. When this map contains the attributes attached to an element, if the removed attribute is known to have a default value, an attribute immediately appears containing the default value as well as the corresponding namespace URI, local name, and prefix when applicable.

Exceptions
DOMException:
NOT_FOUND_ERR: Raised if there is no node named name in this map.
NO_MODIFICATION_ALLOWED_ERR: Raised if this map is readonly.
removeNamedItemNSback to summary
public Node removeNamedItemNS(String namespaceURI, String name) throws DOMException

Implements org.w3c.dom.NamedNodeMap.removeNamedItemNS.

Introduced in DOM Level 2.

Removes a node specified by local name and namespace URI.

Parameters
namespaceURI:String

The namespace URI of the node to remove. When it is null or an empty string, this method behaves like removeNamedItem.

name:String

The local name of the node to remove.

Returns:Node

Node The node removed from the map if a node with such a local name and namespace URI exists.

Exceptions
DOMException:

Doc from org.w3c.dom.NamedNodeMap.removeNamedItemNS.

NOT_FOUND_ERR: Raised if there is no node with the specified namespaceURI and localName in this map.
NO_MODIFICATION_ALLOWED_ERR: Raised if this map is readonly.
NOT_SUPPORTED_ERR: May be raised if the implementation does not support the feature "XML" and the language exposed through the Document does not support XML Namespaces (such as [HTML 4.01]).

NOT_FOUND_ERR:
Raised if there is no node named name in the map.
setNamedItemback to summary
public Node setNamedItem(Node arg) throws DOMException

Implements org.w3c.dom.NamedNodeMap.setNamedItem.

Adds a node using its nodeName attribute. As the nodeName attribute is used to derive the name which the node must be stored under, multiple nodes of certain types (those that have a "special" string value) cannot be stored as the names would clash. This is seen as preferable to allowing nodes to be aliased.

Parameters
arg:Node

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.

Returns:Node

If the new Node replaces an existing node the replaced Node is returned, otherwise null is returned.

Exceptions
DOMException:
The exception description.
See Also
org.w3c.dom.NamedNodeMap#setNamedItem
setNamedItemNSback to summary
public Node setNamedItemNS(Node arg) throws DOMException

Implements org.w3c.dom.NamedNodeMap.setNamedItemNS.

Adds a node using its namespaceURI and localName.

Parameters
arg:Node

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.

Returns:Node

If the new Node replaces an existing node the replaced Node is returned, otherwise null is returned.

Exceptions
DOMException:

Doc from org.w3c.dom.NamedNodeMap.setNamedItemNS.

WRONG_DOCUMENT_ERR: Raised if arg was created from a different document than the one that created this map.
NO_MODIFICATION_ALLOWED_ERR: Raised if this map is readonly.
INUSE_ATTRIBUTE_ERR: Raised if 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.
HIERARCHY_REQUEST_ERR: Raised if an attempt is made to add a node doesn't belong in this NamedNodeMap. Examples would include trying to insert something other than an Attr node into an Element's map of attributes, or a non-Entity node into the DocumentType's map of Entities.
NOT_SUPPORTED_ERR: May be raised if the implementation does not support the feature "XML" and the language exposed through the Document does not support XML Namespaces (such as [HTML 4.01]).

See Also
org.w3c.dom.NamedNodeMap#setNamedItem
setOwnerDocumentback to summary
protected void setOwnerDocument(CoreDocumentImpl doc)

NON-DOM set the ownerDocument of this node, and the attributes it contains

setReadOnlyback to summary
pack-priv void setReadOnly(boolean readOnly, boolean deep)

Internal subroutine to allow read-only Nodes to make their contained NamedNodeMaps readonly too. I expect that in fact the shallow version of this operation will never be

Parameters
readOnly:boolean

boolean true to make read-only, false to permit editing.

deep:boolean

boolean true to pass this request along to the contained nodes, false to only toggle the NamedNodeMap itself. I expect that the shallow version of this operation will never be used, but I want to design it in now, while I'm thinking about it.

writeObjectback to summary
private void writeObject(ObjectOutputStream out) throws IOException