Methods Summary |
---|
protected int | addItem(org.w3c.dom.Node arg)
int i = findNamePoint(arg.getNamespaceURI(), arg.getLocalName());
if (i >= 0) {
nodes.setElementAt(arg,i);
}
else {
// If we can't find by namespaceURI, localName, then we find by
// nodeName so we know where to insert.
i = findNamePoint(arg.getNodeName(),0);
if (i >= 0) {
nodes.insertElementAt(arg,i);
}
else {
i = -1 - i; // Insert point (may be end of list)
if (null == nodes) {
nodes = new Vector(5, 10);
}
nodes.insertElementAt(arg, i);
}
}
return i;
|
final boolean | changed()
return (flags & CHANGED) != 0;
|
final void | changed(boolean value)
flags = (short) (value ? flags | CHANGED : flags & ~CHANGED);
|
protected void | cloneContent(org.apache.xerces.dom.NamedNodeMapImpl srcmap)
Vector srcnodes = srcmap.nodes;
if (srcnodes != null) {
int size = srcnodes.size();
if (size != 0) {
if (nodes == null) {
nodes = new Vector(size);
}
nodes.setSize(size);
for (int i = 0; i < size; ++i) {
NodeImpl n = (NodeImpl) srcmap.nodes.elementAt(i);
NodeImpl clone = (NodeImpl) n.cloneNode(true);
clone.isSpecified(n.isSpecified());
nodes.setElementAt(clone, i);
}
}
}
|
protected java.util.Vector | cloneMap(java.util.Vector list)NON-DOM: copy content of this map into the specified vector
if (list == null) {
list = new Vector(5, 10);
}
list.setSize(0);
if (nodes != null) {
for (int i=0; i<nodes.size(); i++) {
list.insertElementAt(nodes.elementAt(i), i);
}
}
return list;
|
public org.apache.xerces.dom.NamedNodeMapImpl | cloneMap(NodeImpl ownerNode)Cloning a NamedNodeMap is a DEEP OPERATION; it always clones
all the nodes contained in the map.
NamedNodeMapImpl newmap = new NamedNodeMapImpl(ownerNode);
newmap.cloneContent(this);
return newmap;
|
protected int | findNamePoint(java.lang.String name, int start)Subroutine: Locate the named item, or the point at which said item
should be added.
// Binary search
int i = 0;
if (nodes != null) {
int first = start;
int last = nodes.size() - 1;
while (first <= last) {
i = (first + last) / 2;
int test = name.compareTo(((Node)(nodes.elementAt(i))).getNodeName());
if (test == 0) {
return i; // Name found
}
else if (test < 0) {
last = i - 1;
}
else {
first = i + 1;
}
}
if (first > i) {
i = first;
}
}
return -1 - i; // not-found has to be encoded.
|
protected int | findNamePoint(java.lang.String namespaceURI, java.lang.String name)This findNamePoint is for DOM Level 2 Namespaces.
if (nodes == null) return -1;
if (name == null) return -1;
// This is a linear search through the same nodes Vector.
// The Vector is sorted on the DOM Level 1 nodename.
// The DOM Level 2 NS keys are namespaceURI and Localname,
// so we must linear search thru it.
// In addition, to get this to work with nodes without any namespace
// (namespaceURI and localNames are both null) we then use the nodeName
// as a seconday key.
for (int i = 0; i < nodes.size(); i++) {
NodeImpl a = (NodeImpl)nodes.elementAt(i);
String aNamespaceURI = a.getNamespaceURI();
String aLocalName = a.getLocalName();
if (namespaceURI == null) {
if (aNamespaceURI == null
&&
(name.equals(aLocalName)
||
(aLocalName == null && name.equals(a.getNodeName()))))
return i;
} else {
if (namespaceURI.equals(aNamespaceURI)
&&
name.equals(aLocalName))
return i;
}
}
return -1;
|
protected java.lang.Object | getItem(int index)
if (nodes !=null) {
return nodes.elementAt(index);
}
return null;
|
public int | 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).
return (nodes != null) ? nodes.size() : 0;
|
public org.w3c.dom.Node | getNamedItem(java.lang.String name)Retrieve a node by name.
int i = findNamePoint(name,0);
return (i < 0) ? null : (Node)(nodes.elementAt(i));
|
protected int | getNamedItemIndex(java.lang.String namespaceURI, java.lang.String localName)
return findNamePoint(namespaceURI, localName);
|
public org.w3c.dom.Node | getNamedItemNS(java.lang.String namespaceURI, java.lang.String localName)Introduced in DOM Level 2.
Retrieves a node specified by local name and namespace URI.
int i = findNamePoint(namespaceURI, localName);
return (i < 0) ? null : (Node)(nodes.elementAt(i));
|
boolean | getReadOnly()Internal subroutine returns this NodeNameMap's (shallow) readOnly value.
return isReadOnly();
|
final boolean | hasDefaults()
return (flags & HASDEFAULTS) != 0;
|
final void | hasDefaults(boolean value)
flags = (short) (value ? flags | HASDEFAULTS : flags & ~HASDEFAULTS);
|
final boolean | isReadOnly()
return (flags & READONLY) != 0;
|
final void | isReadOnly(boolean value)
flags = (short) (value ? flags | READONLY : flags & ~READONLY);
|
public org.w3c.dom.Node | item(int index)Retrieve an item from the map by 0-based index.
return (nodes != null && index < nodes.size()) ?
(Node)(nodes.elementAt(index)) : null;
|
protected boolean | precedes(org.w3c.dom.Node a, org.w3c.dom.Node b)
if (nodes != null) {
for (int i = 0; i < nodes.size(); i++) {
Node n = (Node)nodes.elementAt(i);
if (n==a) return true;
if (n==b) return false;
}
}
return false;
|
public void | removeAll()NON-DOM remove all elements from this map
if (nodes != null) {
nodes.removeAllElements();
}
|
protected void | removeItem(int index)NON-DOM: Remove attribute at specified index
if (nodes != null && index < nodes.size()){
nodes.removeElementAt(index);
}
|
public org.w3c.dom.Node | removeNamedItemNS(java.lang.String namespaceURI, java.lang.String name)/
public Node removeNamedItem(String name)
throws DOMException {
if (isReadOnly()) {
String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NO_MODIFICATION_ALLOWED_ERR", null);
throw
new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR,
msg);
}
int i = findNamePoint(name,0);
if (i < 0) {
String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NOT_FOUND_ERR", null);
throw new DOMException(DOMException.NOT_FOUND_ERR, msg);
}
NodeImpl n = (NodeImpl)nodes.elementAt(i);
nodes.removeElementAt(i);
return n;
} // removeNamedItem(String):Node
/**
Introduced in DOM Level 2.
Removes a node specified by local name and namespace URI.
if (isReadOnly()) {
String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NO_MODIFICATION_ALLOWED_ERR", null);
throw
new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR,
msg);
}
int i = findNamePoint(namespaceURI, name);
if (i < 0) {
String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NOT_FOUND_ERR", null);
throw new DOMException(DOMException.NOT_FOUND_ERR, msg);
}
NodeImpl n = (NodeImpl)nodes.elementAt(i);
nodes.removeElementAt(i);
return n;
|
public org.w3c.dom.Node | setNamedItem(org.w3c.dom.Node arg)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.
CoreDocumentImpl ownerDocument = ownerNode.ownerDocument();
if (ownerDocument.errorChecking) {
if (isReadOnly()) {
String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NO_MODIFICATION_ALLOWED_ERR", null);
throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, msg);
}
if (arg.getOwnerDocument() != ownerDocument) {
String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "WRONG_DOCUMENT_ERR", null);
throw new DOMException(DOMException.WRONG_DOCUMENT_ERR, msg);
}
}
int i = findNamePoint(arg.getNodeName(),0);
NodeImpl previous = null;
if (i >= 0) {
previous = (NodeImpl) nodes.elementAt(i);
nodes.setElementAt(arg,i);
} else {
i = -1 - i; // Insert point (may be end of list)
if (null == nodes) {
nodes = new Vector(5, 10);
}
nodes.insertElementAt(arg, i);
}
return previous;
|
public org.w3c.dom.Node | setNamedItemNS(org.w3c.dom.Node arg)Adds a node using its namespaceURI and localName.
CoreDocumentImpl ownerDocument = ownerNode.ownerDocument();
if (ownerDocument.errorChecking) {
if (isReadOnly()) {
String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NO_MODIFICATION_ALLOWED_ERR", null);
throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, msg);
}
if(arg.getOwnerDocument() != ownerDocument) {
String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "WRONG_DOCUMENT_ERR", null);
throw new DOMException(DOMException.WRONG_DOCUMENT_ERR, msg);
}
}
int i = findNamePoint(arg.getNamespaceURI(), arg.getLocalName());
NodeImpl previous = null;
if (i >= 0) {
previous = (NodeImpl) nodes.elementAt(i);
nodes.setElementAt(arg,i);
} else {
// If we can't find by namespaceURI, localName, then we find by
// nodeName so we know where to insert.
i = findNamePoint(arg.getNodeName(),0);
if (i >= 0) {
previous = (NodeImpl) nodes.elementAt(i);
nodes.insertElementAt(arg,i);
} else {
i = -1 - i; // Insert point (may be end of list)
if (null == nodes) {
nodes = new Vector(5, 10);
}
nodes.insertElementAt(arg, i);
}
}
return previous;
|
protected void | setOwnerDocument(CoreDocumentImpl doc)NON-DOM
set the ownerDocument of this node, and the attributes it contains
if (nodes != null) {
for (int i = 0; i < nodes.size(); i++) {
((NodeImpl)item(i)).setOwnerDocument(doc);
}
}
|
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
isReadOnly(readOnly);
if (deep && nodes != null) {
for (int i = nodes.size() - 1; i >= 0; i--) {
((NodeImpl) nodes.elementAt(i)).setReadOnly(readOnly,deep);
}
}
|