1
/* Copyright 2002-2004 Elliotte Rusty Harold
3
This library is free software; you can redistribute it and/or modify
4
it under the terms of version 2.1 of the GNU Lesser General Public
5
License as published by the Free Software Foundation.
7
This library is distributed in the hope that it will be useful,
8
but WITHOUT ANY WARRANTY; without even the implied warranty of
9
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
GNU Lesser General Public License for more details.
12
You should have received a copy of the GNU Lesser General Public
13
License along with this library; if not, write to the
14
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
15
Boston, MA 02111-1307 USA
17
You can contact Elliotte Rusty Harold by sending e-mail to
18
elharo@metalab.unc.edu. Please include the word "XOM" in the
19
subject line. The XOM home page is located at http://www.xom.nu/
24
import java.util.ArrayList;
25
import java.util.List;
30
* A read-only list of elements for traversal purposes.
31
* Changes to the document from which this list was generated
32
* are not reflected in this list. Changes to the individual
33
* <code>Element</code> objects in the list are reflected.
36
* @author Elliotte Rusty Harold
41
public final class Elements {
44
private List elements = new ArrayList(1);
46
// non-public constructor to prevent instantiation
51
* Returns the number of elements in the list.
52
* This is guaranteed non-negative.
55
* @return the number of elements in the list
58
return elements.size();
63
* Returns the index<sup>th</sup> element in the list.
64
* The first element has index 0. The last element
65
* has index <code>size()-1</code>.
68
* @param index the element to return
70
* @return the element at the specified position
72
* @throws IndexOutOfBoundsException if index is negative
73
* or greater than or equal to the size of the list
75
public Element get(int index) {
76
return (Element) elements.get(index);
80
// Add the specified Element object to the list
81
void add(Element element) {
82
elements.add(element);
b'\\ No newline at end of file'