001: /*
002: * Copyright 1999-2004 The Apache Software Foundation
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016: package org.apache.commons.collections.iterators;
017:
018: import java.util.ListIterator;
019:
020: /**
021: * A proxy {@link ListIterator ListIterator} which delegates its
022: * methods to a proxy instance.
023: *
024: * @deprecated Use AbstractListIteratorDecorator. Will be removed in v4.0
025: * @since Commons Collections 2.0
026: * @version $Revision: 155406 $ $Date: 2005-02-26 12:55:26 +0000 (Sat, 26 Feb 2005) $
027: *
028: * @author Rodney Waldhoff
029: */
030: public class ProxyListIterator implements ListIterator {
031:
032: /** Holds value of property "iterator". */
033: private ListIterator iterator;
034:
035: // Constructors
036: //-------------------------------------------------------------------------
037:
038: /**
039: * Constructs a new <code>ProxyListIterator</code> that will not
040: * function until {@link #setListIterator(ListIterator) setListIterator}
041: * is invoked.
042: */
043: public ProxyListIterator() {
044: super ();
045: }
046:
047: /**
048: * Constructs a new <code>ProxyListIterator</code> that will use the
049: * given list iterator.
050: *
051: * @param iterator the list iterator to use
052: */
053: public ProxyListIterator(ListIterator iterator) {
054: super ();
055: this .iterator = iterator;
056: }
057:
058: // ListIterator interface
059: //-------------------------------------------------------------------------
060:
061: /**
062: * Invokes the underlying {@link ListIterator#add(Object)} method.
063: *
064: * @throws NullPointerException if the underlying iterator is null
065: */
066: public void add(Object o) {
067: getListIterator().add(o);
068: }
069:
070: /**
071: * Invokes the underlying {@link ListIterator#hasNext()} method.
072: *
073: * @throws NullPointerException if the underlying iterator is null
074: */
075: public boolean hasNext() {
076: return getListIterator().hasNext();
077: }
078:
079: /**
080: * Invokes the underlying {@link ListIterator#hasPrevious()} method.
081: *
082: * @throws NullPointerException if the underlying iterator is null
083: */
084: public boolean hasPrevious() {
085: return getListIterator().hasPrevious();
086: }
087:
088: /**
089: * Invokes the underlying {@link ListIterator#next()} method.
090: *
091: * @throws NullPointerException if the underlying iterator is null
092: */
093: public Object next() {
094: return getListIterator().next();
095: }
096:
097: /**
098: * Invokes the underlying {@link ListIterator#nextIndex()} method.
099: *
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 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 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 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 iterator) {
158: this.iterator = iterator;
159: }
160:
161: }
|