01: /*
02: * The contents of this file are subject to the terms
03: * of the Common Development and Distribution License
04: * (the License). You may not use this file except in
05: * compliance with the License.
06: *
07: * You can obtain a copy of the license at
08: * https://glassfish.dev.java.net/public/CDDLv1.0.html.
09: * See the License for the specific language governing
10: * permissions and limitations under the License.
11: *
12: * When distributing Covered Code, include this CDDL
13: * Header Notice in each file and include the License file
14: * at https://glassfish.dev.java.net/public/CDDLv1.0.html.
15: * If applicable, add the following below the CDDL Header,
16: * with the fields enclosed by brackets [] replaced by
17: * you own identifying information:
18: * "Portions Copyrighted [year] [name of copyright owner]"
19: *
20: * Copyright 2006 Sun Microsystems Inc. All Rights Reserved
21: */
22:
23: /*
24: * NodeListImpl.java
25: *
26: * Created on March 31, 2006, 8:08 PM
27: *
28: * To change this template, choose Tools | Template Manager
29: * and open the template in the editor.
30: */
31:
32: package com.sun.xml.wss.util;
33:
34: import org.w3c.dom.Node;
35: import java.util.List;
36: import java.util.ArrayList;
37: import org.w3c.dom.NodeList;
38:
39: /**
40: *
41: * @author ashutosh.shahi@sun.com
42: */
43: public class NodeListImpl implements NodeList {
44:
45: private List<Node> nodes;
46:
47: /**
48: * Creates a new instance of NodeListImpl
49: */
50: public NodeListImpl() {
51: nodes = new ArrayList<Node>();
52: }
53:
54: /**
55: * get the size of the nodeList
56: */
57: public int getLength() {
58: return nodes.size();
59: }
60:
61: /**
62: * get the ith item from NodeList
63: */
64: public Node item(int i) {
65: return nodes.get(i);
66: }
67:
68: /**
69: * add node to the end of NodeList
70: */
71: public void add(Node node) {
72: nodes.add(node);
73: }
74:
75: public void merge(NodeList nodeList) {
76: for (int i = 0; i < nodeList.getLength(); i++) {
77: nodes.add(nodeList.item(i));
78: }
79: }
80:
81: }
|