KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > commons > collections > iterators > ProxyListIterator


1 /*
2  * Copyright 1999-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 package org.apache.commons.collections.iterators;
17
18 import java.util.ListIterator JavaDoc;
19
20 /**
21  * A proxy {@link ListIterator ListIterator} which delegates its
22  * methods to a proxy instance.
23  *
24  * @deprecated Use AbstractListIteratorDecorator. Will be removed in v4.0
25  * @since Commons Collections 2.0
26  * @version $Revision: 1.9 $ $Date: 2004/02/18 00:59:50 $
27  *
28  * @author Rodney Waldhoff
29  */

30 public class ProxyListIterator implements ListIterator JavaDoc {
31
32     /** Holds value of property "iterator". */
33     private ListIterator JavaDoc iterator;
34
35     // Constructors
36
//-------------------------------------------------------------------------
37

38     /**
39      * Constructs a new <code>ProxyListIterator</code> that will not
40      * function until {@link #setListIterator(ListIterator) setListIterator}
41      * is invoked.
42      */

43     public ProxyListIterator() {
44         super();
45     }
46
47     /**
48      * Constructs a new <code>ProxyListIterator</code> that will use the
49      * given list iterator.
50      *
51      * @param iterator the list iterator to use
52      */

53     public ProxyListIterator(ListIterator JavaDoc iterator) {
54         super();
55         this.iterator = iterator;
56     }
57
58     // ListIterator interface
59
//-------------------------------------------------------------------------
60

61     /**
62      * Invokes the underlying {@link ListIterator#add(Object)} method.
63      *
64      * @throws NullPointerException if the underlying iterator is null
65      */

66     public void add(Object JavaDoc o) {
67         getListIterator().add(o);
68     }
69
70     /**
71      * Invokes the underlying {@link ListIterator#hasNext()} method.
72      *
73      * @throws NullPointerException if the underlying iterator is null
74      */

75     public boolean hasNext() {
76         return getListIterator().hasNext();
77     }
78
79     /**
80      * Invokes the underlying {@link ListIterator#hasPrevious()} method.
81      *
82      * @throws NullPointerException if the underlying iterator is null
83      */

84     public boolean hasPrevious() {
85         return getListIterator().hasPrevious();
86     }
87
88     /**
89      * Invokes the underlying {@link ListIterator#next()} method.
90      *
91      * @throws NullPointerException if the underlying iterator is null
92      */

93     public Object JavaDoc next() {
94         return getListIterator().next();
95     }
96
97     /**
98      * Invokes the underlying {@link ListIterator#nextIndex()} method.
99      *
100      * @throws NullPointerException if the underlying iterator is null
101      */

102     public int nextIndex() {
103         return getListIterator().nextIndex();
104     }
105
106     /**
107      * Invokes the underlying {@link ListIterator#previous()} method.
108      *
109      * @throws NullPointerException if the underlying iterator is null
110      */

111     public Object JavaDoc previous() {
112         return getListIterator().previous();
113     }
114
115     /**
116      * Invokes the underlying {@link ListIterator#previousIndex()} method.
117      *
118      * @throws NullPointerException if the underlying iterator is null
119      */

120     public int previousIndex() {
121         return getListIterator().previousIndex();
122     }
123
124     /**
125      * Invokes the underlying {@link ListIterator#remove()} method.
126      *
127      * @throws NullPointerException if the underlying iterator is null
128      */

129     public void remove() {
130         getListIterator().remove();
131     }
132
133     /**
134      * Invokes the underlying {@link ListIterator#set(Object)} method.
135      *
136      * @throws NullPointerException if the underlying iterator is null
137      */

138     public void set(Object JavaDoc o) {
139         getListIterator().set(o);
140     }
141
142     // Properties
143
//-------------------------------------------------------------------------
144

145     /**
146      * Getter for property iterator.
147      * @return Value of property iterator.
148      */

149     public ListIterator JavaDoc getListIterator() {
150         return iterator;
151     }
152
153     /**
154      * Setter for property iterator.
155      * @param iterator New value of property iterator.
156      */

157     public void setListIterator(ListIterator JavaDoc iterator) {
158         this.iterator = iterator;
159     }
160
161 }
162
163
Popular Tags