Subversion Repository Public Repository

litesoft

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
package org.litesoft.core.util;

import org.litesoft.core.util.*;

import java.util.*;

// Copyright Status:
//
// All Software available from LiteSoft.org (including this file) is
// hereby released into the public domain.
//
// It is free!  As in, you may use it freely in both commercial and
// non-commercial applications, bundle it with your software
// distribution, include it on a CD-ROM, list the source code in a book,
// mirror the documentation at your own web site, or use it in any other
// way you see fit.
//
// NO Warranty!
//
// All software is provided "as is".
//
// There is ABSOLUTELY NO WARRANTY OF ANY KIND: not for the design, fitness
// (for a particular purpose), level of errors (or lack thereof), or
// applicability of this software.  The entire risk as to the quality
// and performance of this software is with you.  Should this software
// prove defective, you assume the cost of all necessary servicing, repair
// or correction.
//
// In no event unless required by applicable law or agreed to in writing
// will any party who created or may modify and/or redistribute this
// software, be liable to you for damages, including any general,
// special, incidental or consequential damages arising out of the use or
// inability to use this software (including but not limited to loss of
// data or data being rendered inaccurate or losses sustained by you or
// third parties or a failure of this software to operate with any
// other programs), even if such holder or other party has been advised
// of the possibility of such damages.
//
// NOTE: Should you discover a bug, have a recogmendation for a change, wish
// to submit modifications, or wish to add new classes/functionality,
// please email them to:
//
//        changes@litesoft.org
//

/**
 * This class's purpose is to be extended by any concrete Iterator that is
 * wrapping/decorating another Iterator.<p>
 *
 * @author George Smith
 * @version 1.0 7/28/01
 */

public abstract class AbstractWrappingIterator<T> extends AbstractReadOnlyIterator<T>
{
    /**
     * Construct an Iterator wrapping Iterator.<p>
     *
     * @param pIterator Iterator to be <i>wrapped</i> (!null).<p>
     *
     * @see <a href="http://java.sun.com/j2se/1.3/docs/api/java/lang/Util/Iterator.html">java.util.Iterator</a>
     */
    protected AbstractWrappingIterator( Iterator<T> pIterator )
            throws NullPointerException
    {
        if ( (zIterator = pIterator) == null )
        {
            throw new NullPointerException( "Iterator was null" );
        }
    }

    /**
     * Reference to the <i>wrapped</i> Iterator.
     */
    protected Iterator<T> zIterator;

    /**
     * This hasNext() simply forwards the request to the <i>wrapped</i> Iterator.<p>
     *
     * @see <a href="http://java.sun.com/j2se/1.3/docs/api/java/lang/Util/Iterator.html#hasNext()">java.util.Iterator#hasNext()</a>
     */
    public boolean hasNext()
    {
        return zIterator.hasNext();
    }

    /**
     * This next() simply forwards the request to the <i>wrapped</i> Iterator.<p>
     *
     * @see <a href="http://java.sun.com/j2se/1.3/docs/api/java/lang/Util/Iterator.html#next()">java.util.Iterator#next()</a>
     */
    public T next()
    {
        return zIterator.next();
    }

    @Override
    public void dispose()
    {
        if ( zIterator instanceof Disposable )
        {
            ((Disposable)zIterator).dispose();
        }
        super.dispose();
    }
}

Commits for litesoft/trunk/Java/core/Anywhere/src/org/litesoft/core/util/AbstractWrappingIterator.java

Diff revisions: vs.
Revision Author Commited Message
2 GeorgeS picture GeorgeS Sun 07 Feb, 2010 12:50:58 +0000