Debian Codegraph @

net/sf/saxon/dom/DOMNodeList.java

raw symbols SCIP
1 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2 // Copyright (c) 2018 Saxonica Limited.
3 // This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
4 // If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 // This Source Code Form is "Incompatible With Secondary Licenses", as defined by the Mozilla Public License, v. 2.0.
6 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
7
8 package net.sf.saxon.dom;
9
10 import org.w3c.dom.Node;
11
12 import java.util.List;
13
14 /**
15 * This class wraps a list of nodes as a DOM NodeList
16 */
17
18 public final class DOMNodeList implements org.w3c.dom.NodeList {
19 private List<Node> sequence;
20
21 /**
22 * Construct an node list that wraps a supplied list of DOM Nodes.
23 *
24 * @param extent the list of nodes to be wrapped
25 */
26
27 public DOMNodeList(List<Node> extent) {
28 sequence = extent;
29 }
30
31 /**
32 * return the number of nodes in the list (DOM method)
33 */
34
35 public int getLength() {
36 return sequence.size();
37 }
38
39 /**
40 * Return the n'th item in the list (DOM method)
41 *
42 * @throws java.lang.ClassCastException if the item is not a DOM Node
43 */
44
45 /*@Nullable*/
46 public Node item(int index) {
47 if (index < 0 || index >= sequence.size()) {
48 return null;
49 } else {
50 return sequence.get(index);
51 }
52 }
53
54 }
55