KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > axis > message > NodeListImpl


1 /*
2  * Copyright 2001-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.jboss.axis.message;
18
19 import org.w3c.dom.Node JavaDoc;
20 import org.w3c.dom.NodeList JavaDoc;
21
22 import java.util.ArrayList JavaDoc;
23 import java.util.List JavaDoc;
24
25 /**
26  * A simple implementation for Nodelist Support in AXIS
27  *
28  * @author Heejune Ahn (cityboy@tmax.co.kr)
29  */

30 class NodeListImpl implements NodeList JavaDoc
31 {
32
33    private List JavaDoc mNodes = new ArrayList JavaDoc();
34
35    /**
36     * Constructor and Setter is intensionally made package access only.
37     */

38    NodeListImpl()
39    {
40    }
41
42    NodeListImpl(List JavaDoc nodes)
43    {
44       mNodes = new ArrayList JavaDoc(nodes);
45    }
46
47    void addNode(org.w3c.dom.Node JavaDoc node)
48    {
49       mNodes.add(node);
50    }
51
52    void addNodeList(org.w3c.dom.NodeList JavaDoc nodes)
53    {
54       for (int i = 0; i < nodes.getLength(); i++)
55       {
56          mNodes.add(nodes.item(i));
57       }
58    }
59
60    /**
61     * Interface Implemented
62     *
63     * @param index
64     * @return
65     */

66    public Node JavaDoc item(int index)
67    {
68       if (mNodes != null && mNodes.size() > index)
69       {
70          return (Node JavaDoc)mNodes.get(index);
71       }
72       else
73       {
74          return null;
75       }
76    }
77
78    public int getLength()
79    {
80       return mNodes.size();
81    }
82
83 }
Popular Tags