📄 namednodemapimpl.java
字号:
/*
Copyright (C) 2003 Together
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package org.enhydra.xml;
import java.util.Iterator;
import java.util.List;
import org.w3c.dom.Document;
import org.w3c.dom.DOMException;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
/**
*
* @version 1.0
*/
class NamedNodeMapImpl implements NamedNodeMap {
/**
* List of <code>Node</code>s.
*/
List nodes;
/**
* Constructs new <code>NamedNodeMapImpl</code> with the given list of nodes.
* @param nodes list of nodes.
*/
public NamedNodeMapImpl(List nodes) {
this.nodes = nodes;
}
/**
* Returns the count of nodes.
*
* @return the count of nodes.
*/
public int getLength() {
return nodes.size();
}
/**
* Returns the <code>Node</code> with the given name.
*
* @param name the node name.
*
* @return the <code>Node</code> with the given name.
*/
public Node getNamedItem(String name) {
Iterator iter = nodes.iterator();
while (iter.hasNext()) {
Node node = (Node)iter.next();
if (name.equals(node.getNodeName())) {
return node;
}
}
return null;
}
/**
* Returns the <code>Node</code> with the given index.
*
* @param index index of a node.
* @return the <code>Node</code> with the given index.
*/
public Node item(int index) {
Node node = (Node) nodes.get(index);
return node;
}
public Node removeNamedItem(java.lang.String name) {
throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, "This NamedNodeMap is read-only!");
}
public Node setNamedItem(Node arg) {
throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, "This NamedNodeMap is read-only!");
}
public Node getNamedItemNS(String namespaceURI, String localName) {
return getNamedItem(localName);
}
/**
* Equivalent to <code>setNamedItem(arg)</code>.
* @param arg is node
* @return node
*/
public Node setNamedItemNS(Node arg) {
return setNamedItem(arg);
}
/**
* Equivalent to <code>removeNamedItem(localName)</code>.
* @param namespaceURI is name space
* @param localName is string
* @return node
*/
public Node removeNamedItemNS(String namespaceURI, String localName) {
return removeNamedItem(localName);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -