1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19
20 package org.apache.axiom.c14n.omwrapper;
21
22 import org.apache.axiom.c14n.omwrapper.factory.WrapperFactory;
23 import org.apache.axiom.c14n.omwrapper.interfaces.Node;
24 import org.apache.axiom.c14n.omwrapper.interfaces.NodeList;
25
26 import java.util.List;
27
28 /**
29 * @author Saliya Ekanayake (esaliya@gmail.com)
30 */
31 public class NodeListImpl implements NodeList {
32 private WrapperFactory fac = null;
33 private List nodes = null;
34
35 public NodeListImpl(List nodes, WrapperFactory fac) {
36 this.fac = fac;
37 this.nodes = nodes;
38 }
39
40 public Node item(int index) {
41 try {
42 return fac.getNode(nodes.get(index));
43 } catch(IndexOutOfBoundsException e) {
44 return null;
45 }
46 }
47
48 public int getLength() {
49 return nodes.size();
50 }
51
52 // Object should represent an OMNode
53 protected int indexOf(Object o){
54 return nodes.indexOf(o);
55 }
56 }