01: /*
02: * @(#)HashMapNode.java 1.36 02/03/21
03: *
04: * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
05: * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
06: */
07: package org.enhydra.xml;
08:
09: import java.util.ArrayList;
10: import java.util.HashMap;
11:
12: import org.w3c.dom.Node;
13:
14: /**
15: * @author Tweety
16: *
17: * A class representing a node in a meta-data tree, which implements
18: * the <a href="../../../../api/org/w3c/dom/NamedNodeMap.html">
19: *
20: * @version 1.0
21: */
22: class HashMapNamedNodeMap extends NamedNodeMapImpl {
23:
24: /**
25: * HashMap of <code>Node</code> items.
26: */
27: HashMap hNodes;
28:
29: /**
30: * Constructs a <code>HashMapNamedNodeMap</code> from the given <code>HashMap</code>.
31: *
32: * @param nodes, as a <code>HashMap</code>.
33: */
34: public HashMapNamedNodeMap(HashMap nodes) {
35: super (new ArrayList(nodes.values()));
36: this .hNodes = nodes;
37: }
38:
39: /**
40: * Returns the items count.
41: *
42: * @return items count.
43: */
44: public int getLength() {
45: return hNodes.size();
46: }
47:
48: /**
49: * Returns the <code>Node</code> item with the given name.
50: *
51: * @param name <code>Node</code> name.
52: *
53: * @return <code>Node</code> item with the given name.
54: */
55: public Node getNamedItem(String name) {
56: return (Node) hNodes.get(name);
57: }
58:
59: }
|