01: /*
02: Copyright (C) 2003 Together
03:
04: This library is free software; you can redistribute it and/or
05: modify it under the terms of the GNU Lesser General Public
06: License as published by the Free Software Foundation; either
07: version 2.1 of the License, or (at your option) any later version.
08:
09: This library is distributed in the hope that it will be useful,
10: but WITHOUT ANY WARRANTY; without even the implied warranty of
11: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12: Lesser General Public License for more details.
13:
14: You should have received a copy of the GNU Lesser General Public
15: License along with this library; if not, write to the Free Software
16: Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17: */
18:
19: package org.enhydra.xml;
20:
21: import java.util.ArrayList;
22: import java.util.HashMap;
23:
24: import org.w3c.dom.DOMException;
25: import org.w3c.dom.NamedNodeMap;
26: import org.w3c.dom.Node;
27:
28: /**
29: * @author Tweety
30: *
31: * A class representing a node in a meta-data tree, which implements
32: * the <a href="../../../../api/org/w3c/dom/NamedNodeMap.html">
33: *
34: * @version 1.0
35: */
36: class HashMapNamedNodeMap extends NamedNodeMapImpl {
37:
38: /**
39: * HashMap of <code>Node</code> items.
40: */
41: HashMap hNodes;
42:
43: /**
44: * Constructs a <code>HashMapNamedNodeMap</code> from the given <code>HashMap</code>.
45: *
46: * @param nodes , as a <code>HashMap</code>.
47: */
48: public HashMapNamedNodeMap(HashMap nodes) {
49: super (new ArrayList(nodes.values()));
50: this .hNodes = nodes;
51: }
52:
53: /**
54: * Returns the items count.
55: *
56: * @return items count.
57: */
58: public int getLength() {
59: return hNodes.size();
60: }
61:
62: /**
63: * Returns the <code>Node</code> item with the given name.
64: *
65: * @param name <code>Node</code> name.
66: *
67: * @return <code>Node</code> item with the given name.
68: */
69: public Node getNamedItem(String name) {
70: return (Node) hNodes.get(name);
71: }
72:
73: }
|