KickJava   Java API By Example, From Geeks To Geeks.

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


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.Iterator JavaDoc;
19
20 /**
21  * A Proxy {@link Iterator Iterator} which delegates its methods to a proxy instance.
22  *
23  * @deprecated Use AbstractIteratorDecorator. Will be removed in v4.0
24  * @since Commons Collections 1.0
25  * @version $Revision: 1.10 $ $Date: 2004/02/18 00:59:50 $
26  *
27  * @author James Strachan
28  */

29 public class ProxyIterator implements Iterator JavaDoc {
30     
31     /** Holds value of property iterator. */
32     private Iterator JavaDoc iterator;
33     
34     // Constructors
35
//-------------------------------------------------------------------------
36

37     /**
38      * Constructs a new <code>ProxyIterator</code> that will not function
39      * until {@link #setIterator(Iterator)} is called.
40      */

41     public ProxyIterator() {
42         super();
43     }
44     
45     /**
46      * Constructs a new <code>ProxyIterator</code> that will use the
47      * given iterator.
48      *
49      * @param iterator the underlying iterator
50      */

51     public ProxyIterator(Iterator JavaDoc iterator) {
52         super();
53         this.iterator = iterator;
54     }
55
56     // Iterator interface
57
//-------------------------------------------------------------------------
58

59     /**
60      * Returns true if the underlying iterator has more elements.
61      *
62      * @return true if the underlying iterator has more elements
63      */

64     public boolean hasNext() {
65         return getIterator().hasNext();
66     }
67
68     /**
69      * Returns the next element from the underlying iterator.
70      *
71      * @return the next element from the underlying iterator
72      * @throws java.util.NoSuchElementException if the underlying iterator
73      * raises it because it has no more elements
74      */

75     public Object JavaDoc next() {
76         return getIterator().next();
77     }
78
79     /**
80      * Removes the last returned element from the collection that spawned
81      * the underlying iterator.
82      */

83     public void remove() {
84         getIterator().remove();
85     }
86
87     // Properties
88
//-------------------------------------------------------------------------
89
/** Getter for property iterator.
90      * @return Value of property iterator.
91      */

92     public Iterator JavaDoc getIterator() {
93         return iterator;
94     }
95     /** Setter for property iterator.
96      * @param iterator New value of property iterator.
97      */

98     public void setIterator(Iterator JavaDoc iterator) {
99         this.iterator = iterator;
100     }
101 }
102
Popular Tags