1 /*
2 Copyright (C) 2003 Together
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 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.List;
23
24 import org.w3c.dom.Attr;
25 import org.w3c.dom.Document;
26 import org.w3c.dom.Node;
27 import org.w3c.dom.NodeList;
28
29
30
31 /***
32 * @author Tweety
33 *
34 * A class representing a node in a meta-data tree, which implements
35 * the <a href="../../../../api/org/w3c/dom/NodeList.html">
36 *
37 * <p> Namespaces are ignored in this implementation. The terms "tag
38 * name" and "node name" are always considered to be synonymous.
39 *
40 * @version 1.0
41 */
42 public class NodeListImpl implements NodeList {
43
44 /***
45 * List of <code>Node</code>s.
46 */
47 List nodes;
48
49
50 /***
51 * Constructs an empty <code>NodeListImpl</code>.
52 */
53 public NodeListImpl() {
54 this.nodes = new ArrayList();
55 }
56
57
58 /***
59 * Constructs <code>NodeListImpl</code> with the given list of nodes.
60 *
61 * @param nodes list of nodes.
62 */
63 public NodeListImpl(List nodes) {
64 this.nodes = nodes;
65 }
66
67
68 /***
69 * Returns the count of nodes.
70 *
71 * @return the count of nodes.
72 */
73 public int getLength() {
74 return nodes.size();
75 }
76
77
78 /***
79 * Returns the <code>Node</code> with the given index.
80 *
81 * @param index node index.
82 *
83 * @return the <code>Node</code> with the given index.
84 */
85 public Node item(int index) {
86 if (index < 0 || index > nodes.size()) {
87 return null;
88 }
89 return (Node) nodes.get(index);
90 }
91
92
93 /***
94 * Appends the given list to the end of the existing one.
95 *
96 * @param list list to add, as <code>NodeListImpl</code>.
97 *
98 * @return this as </code>NodeList</code>.
99 */
100 public NodeList append(NodeListImpl list) {
101 this.nodes.addAll(list.nodes);
102 return this;
103 }
104
105 }
This page was automatically generated by Maven