01: /*
02:
03: Licensed to the Apache Software Foundation (ASF) under one or more
04: contributor license agreements. See the NOTICE file distributed with
05: this work for additional information regarding copyright ownership.
06: The ASF licenses this file to You under the Apache License, Version 2.0
07: (the "License"); you may not use this file except in compliance with
08: the License. You may obtain a copy of the License at
09:
10: http://www.apache.org/licenses/LICENSE-2.0
11:
12: Unless required by applicable law or agreed to in writing, software
13: distributed under the License is distributed on an "AS IS" BASIS,
14: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15: See the License for the specific language governing permissions and
16: limitations under the License.
17:
18: */
19:
20: package org.apache.batik.dom.util;
21:
22: import java.util.List;
23:
24: import org.w3c.dom.NodeList;
25: import org.w3c.dom.Node;
26:
27: /**
28: * A simple class that implements the DOM NodeList interface by
29: * wrapping an Java List instace.
30: *
31: * @author <a href="mailto:deweese@apache.org">deweese</a>
32: * @version $Id: ListNodeList.java 478249 2006-11-22 17:29:37Z dvholten $
33: */
34: public class ListNodeList implements NodeList {
35: protected List list;
36:
37: public ListNodeList(List list) {
38: this .list = list;
39: }
40:
41: /**
42: * <b>DOM</b>: Implements {@link NodeList#item(int)}.
43: */
44: public Node item(int index) {
45: if ((index < 0) || (index > list.size()))
46: return null;
47: return (Node) list.get(index);
48: }
49:
50: /**
51: * <b>DOM</b>: Implements {@link NodeList#getLength()}.
52: */
53: public int getLength() {
54: return list.size();
55: }
56: }
|