KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > batik > dom > util > ListNodeList


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

18
19 package org.apache.batik.dom.util;
20
21 import java.util.List JavaDoc;
22
23 import org.w3c.dom.NodeList JavaDoc;
24 import org.w3c.dom.Node JavaDoc;
25
26 /**
27  * A simple class that implements the DOM NodeList interface by
28  * wrapping an Java List instace.
29  *
30  * @author <a HREF="mailto:deweese@apache.org">deweese</a>
31  * @version $Id: ListNodeList.java,v 1.2 2005/03/27 08:58:32 cam Exp $
32  */

33 public class ListNodeList implements NodeList JavaDoc {
34     protected List JavaDoc list;
35
36     public ListNodeList(List JavaDoc list) {
37         this.list = list;
38     }
39
40     /**
41      * <b>DOM</b>: Implements {@link NodeList#item(int)}.
42      */

43     public Node JavaDoc item(int index) {
44         if ((index < 0) || (index > list.size()))
45             return null;
46         return (Node JavaDoc)list.get(index);
47     }
48
49     /**
50      * <b>DOM</b>: Implements {@link NodeList#getLength()}.
51      */

52     public int getLength() {
53         return list.size();
54     }
55 };
56
Popular Tags