Statistics
| Revision:

gvsig-raster / org.gvsig.raster.wms / trunk / org.gvsig.raster.wms / org.gvsig.raster.wms.app.wmsclient / src / main / java / org / gvsig / raster / wms / app / wmsclient / layer / DynObjectIteratorWMSInfo.java @ 2484

History | View | Annotate | Download (2.79 KB)

1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22
package org.gvsig.raster.wms.app.wmsclient.layer;
23

    
24
import java.util.ArrayList;
25

    
26
import org.gvsig.fmap.dal.feature.Feature;
27
import org.gvsig.tools.dispose.DisposableIterator;
28
import org.gvsig.tools.dynobject.DynObject;
29
import org.gvsig.tools.dynobject.DynObjectSet;
30

    
31
/**
32
 * {@link DynObject} implementation to facade a iterator of a WMTSInfo
33
 * and allow to be used as a {@link DynObjectSet} iterator.
34
 * 
35
 * @author Nacho Brodin (nachobrodin@gmail.com)
36
 * @version $Id$
37
 * 
38
 */
39
public class DynObjectIteratorWMSInfo implements DisposableIterator {
40

    
41
    private ArrayList<Object> infoList = new ArrayList<Object>();
42
    private int               index    = -1;
43

    
44
    /**
45
     * Creates a new DynObjects iterator facade over a feature iterator.
46
     * Each WMTSInfo will be returned through a new or reused
47
     * {@link DynObjectWMTSInfo} which allows the {@link Feature} to be
48
     * used like a DynObject.
49
     * 
50
     * @param featureIterator
51
     *            to facade
52
     * @param featureFacade
53
     *            if not null this object will be reused as the facade for the
54
     *            Feature objects of the feature iterator
55
     */
56
    public DynObjectIteratorWMSInfo(Object info) {
57
        this.infoList.add(info);
58
        index = 0;
59
    }
60
    
61
    public void addObject(Object info) {
62
            this.infoList.add(info);
63
            if(index == -1)
64
                    index = 0;
65
    }
66

    
67
    public synchronized void dispose() {
68
            this.infoList.clear();
69
            index = -1;
70
    }
71

    
72
    public synchronized boolean hasNext() {
73
        return (infoList.size() == 0 || index >= infoList.size()) ? false : true;
74
    }
75

    
76
    public synchronized Object next() {
77
        Object o = infoList.get(index);
78
        index ++;
79
        return o;
80
    }
81

    
82
    public synchronized void remove() {
83
            if(index < infoList.size() && index >= 0) {
84
                    index --;
85
                    infoList.remove(index);
86
            }
87
    }
88
    
89
    public long getSize() {
90
        return infoList.size();
91
    }
92
}