001 /*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements. See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License. You may obtain a copy of the License at
008 *
009 * http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017 package org.apache.commons.collections.iterators;
018
019 import java.util.ListIterator;
020
021 /**
022 * A proxy {@link ListIterator ListIterator} which delegates its
023 * methods to a proxy instance.
024 *
025 * @deprecated Use AbstractListIteratorDecorator. Will be removed in v4.0
026 * @since Commons Collections 2.0
027 * @version $Revision: 646777 $ $Date: 2008-04-10 13:33:15 +0100 (Thu, 10 Apr 2008) $
028 *
029 * @author Rodney Waldhoff
030 */
031 public class ProxyListIterator implements ListIterator {
032
033 /** Holds value of property "iterator". */
034 private ListIterator iterator;
035
036 // Constructors
037 //-------------------------------------------------------------------------
038
039 /**
040 * Constructs a new <code>ProxyListIterator</code> that will not
041 * function until {@link #setListIterator(ListIterator) setListIterator}
042 * is invoked.
043 */
044 public ProxyListIterator() {
045 super();
046 }
047
048 /**
049 * Constructs a new <code>ProxyListIterator</code> that will use the
050 * given list iterator.
051 *
052 * @param iterator the list iterator to use
053 */
054 public ProxyListIterator(ListIterator iterator) {
055 super();
056 this.iterator = iterator;
057 }
058
059 // ListIterator interface
060 //-------------------------------------------------------------------------
061
062 /**
063 * Invokes the underlying {@link ListIterator#add(Object)} method.
064 *
065 * @throws NullPointerException if the underlying iterator is null
066 */
067 public void add(Object o) {
068 getListIterator().add(o);
069 }
070
071 /**
072 * Invokes the underlying {@link ListIterator#hasNext()} method.
073 *
074 * @throws NullPointerException if the underlying iterator is null
075 */
076 public boolean hasNext() {
077 return getListIterator().hasNext();
078 }
079
080 /**
081 * Invokes the underlying {@link ListIterator#hasPrevious()} method.
082 *
083 * @throws NullPointerException if the underlying iterator is null
084 */
085 public boolean hasPrevious() {
086 return getListIterator().hasPrevious();
087 }
088
089 /**
090 * Invokes the underlying {@link ListIterator#next()} method.
091 *
092 * @throws NullPointerException if the underlying iterator is null
093 */
094 public Object next() {
095 return getListIterator().next();
096 }
097
098 /**
099 * Invokes the underlying {@link ListIterator#nextIndex()} method.
100 *
101 * @throws NullPointerException if the underlying iterator is null
102 */
103 public int nextIndex() {
104 return getListIterator().nextIndex();
105 }
106
107 /**
108 * Invokes the underlying {@link ListIterator#previous()} method.
109 *
110 * @throws NullPointerException if the underlying iterator is null
111 */
112 public Object previous() {
113 return getListIterator().previous();
114 }
115
116 /**
117 * Invokes the underlying {@link ListIterator#previousIndex()} method.
118 *
119 * @throws NullPointerException if the underlying iterator is null
120 */
121 public int previousIndex() {
122 return getListIterator().previousIndex();
123 }
124
125 /**
126 * Invokes the underlying {@link ListIterator#remove()} method.
127 *
128 * @throws NullPointerException if the underlying iterator is null
129 */
130 public void remove() {
131 getListIterator().remove();
132 }
133
134 /**
135 * Invokes the underlying {@link ListIterator#set(Object)} method.
136 *
137 * @throws NullPointerException if the underlying iterator is null
138 */
139 public void set(Object o) {
140 getListIterator().set(o);
141 }
142
143 // Properties
144 //-------------------------------------------------------------------------
145
146 /**
147 * Getter for property iterator.
148 * @return Value of property iterator.
149 */
150 public ListIterator getListIterator() {
151 return iterator;
152 }
153
154 /**
155 * Setter for property iterator.
156 * @param iterator New value of property iterator.
157 */
158 public void setListIterator(ListIterator iterator) {
159 this.iterator = iterator;
160 }
161
162 }
163