KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > xml > HashMapNamedNodeMap


1 /*
2  * @(#)HashMapNode.java 1.36 02/03/21
3  *
4  * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7 package org.enhydra.xml;
8
9 import java.util.ArrayList JavaDoc;
10 import java.util.HashMap JavaDoc;
11
12 import org.w3c.dom.Node JavaDoc;
13
14
15
16 /**
17  * @author Tweety
18  *
19  * A class representing a node in a meta-data tree, which implements
20  * the <a HREF="../../../../api/org/w3c/dom/NamedNodeMap.html">
21  *
22  * @version 1.0
23  */

24 class HashMapNamedNodeMap extends NamedNodeMapImpl {
25
26     
27     /**
28      * HashMap of <code>Node</code> items.
29      */

30     HashMap JavaDoc hNodes;
31
32
33     /**
34      * Constructs a <code>HashMapNamedNodeMap</code> from the given <code>HashMap</code>.
35      *
36      * @param nodes, as a <code>HashMap</code>.
37      */

38     public HashMapNamedNodeMap(HashMap JavaDoc nodes) {
39         super(new ArrayList JavaDoc(nodes.values()));
40         this.hNodes = nodes;
41     }
42
43
44     /**
45      * Returns the items count.
46      *
47      * @return items count.
48      */

49     public int getLength() {
50         return hNodes.size();
51     }
52
53     
54     /**
55      * Returns the <code>Node</code> item with the given name.
56      *
57      * @param name <code>Node</code> name.
58      *
59      * @return <code>Node</code> item with the given name.
60      */

61     public Node JavaDoc getNamedItem(String JavaDoc name) {
62         return (Node JavaDoc) hNodes.get(name);
63     }
64     
65 }
66
Popular Tags