protected int getNamedItemIndex(String namespaceURI, String localName) { return findNamePoint(namespaceURI, localName); }
/** * Retrieve a node by name. * * @param name Name of a node to look up. * @return the Node (of unspecified sub-class) stored with that name, or * null if no value has been assigned to that name. */ public Node getNamedItem(String name) { int i = findNamePoint(name,0); return (i < 0) ? null : (Node)(nodes.get(i)); } // getNamedItem(String):Node
/** * Introduced in DOM Level 2. <p> * Retrieves a node specified by local name and namespace URI. * * @param namespaceURI The namespace URI of the node to retrieve. * When it is null or an empty string, this * method behaves like getNamedItem. * @param localName The local name of the node to retrieve. * @return Node A Node (of any type) with the specified name, or null if the specified * name did not identify any node in the map. */ public Node getNamedItemNS(String namespaceURI, String localName) { int i = findNamePoint(namespaceURI, localName); return (i < 0) ? null : (Node)(nodes.get(i)); } // getNamedItemNS(String,String):Node
protected int addItem (Node arg) { int i = findNamePoint(arg.getNamespaceURI(), arg.getLocalName()); if (i >= 0) { nodes.set(i, arg); } 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.add(i, arg); } else { i = -1 - i; // Insert point (may be end of list) if (null == nodes) { nodes = new ArrayList(5); } nodes.add(i, arg); } } return i; }
int i = findNamePoint(arg.getNamespaceURI(), arg.getLocalName()); NodeImpl previous = null; if (i >= 0) { i = findNamePoint(arg.getNodeName(),0); if (i >= 0) { previous = (NodeImpl) nodes.get(i);
/***/ 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.get(i); nodes.remove(i); return n; } // removeNamedItem(String):Node
int i = findNamePoint(arg.getNodeName(),0); NodeImpl previous = null; if (i >= 0) {
/** * Introduced in DOM Level 2. <p> * Removes a node specified by local name and namespace URI. * @param namespaceURI * The namespace URI of the node to remove. * When it is null or an empty string, this * method behaves like removeNamedItem. * @param name The local name of the node to remove. * @return Node The node removed from the map if a node with such * a local name and namespace URI exists. * @throws NOT_FOUND_ERR: Raised if there is no node named * name in the map. */ public Node removeNamedItemNS(String namespaceURI, 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(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.get(i); nodes.remove(i); return n; } // removeNamedItem(String):Node