svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.fmap.dal / org.gvsig.fmap.dal.impl / src / main / java / org / gvsig / fmap / dal / feature / impl / featureset / DynObjectIteratorFeatureIteratorFacade.java @ 40435
History | View | Annotate | Download (3.2 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.fmap.dal.feature.impl.featureset; |
23 |
|
24 |
import org.gvsig.fmap.dal.feature.Feature; |
25 |
import org.gvsig.fmap.dal.feature.FeatureSet; |
26 |
import org.gvsig.tools.dispose.DisposableIterator; |
27 |
import org.gvsig.tools.dynobject.DynObject; |
28 |
import org.gvsig.tools.dynobject.DynObjectSet; |
29 |
|
30 |
/**
|
31 |
* {@link DynObject} implementation to facade a iterator of a {@link FeatureSet}
|
32 |
* and allow to be used as a {@link DynObjectSet} iterator.
|
33 |
*
|
34 |
* @author gvSIG Team
|
35 |
* @version $Id$
|
36 |
*
|
37 |
*/
|
38 |
public class DynObjectIteratorFeatureIteratorFacade implements |
39 |
DisposableIterator { |
40 |
|
41 |
private final DisposableIterator featureIterator; |
42 |
private DynObjectFeatureFacade featureFacade;
|
43 |
|
44 |
/**
|
45 |
* Creates a new DynObjects iterator facade over a feature iterator.
|
46 |
* Each {@link Feature} will be returned through a new or reused
|
47 |
* {@link DynObjectFeatureFacade} 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 DynObjectIteratorFeatureIteratorFacade(
|
57 |
DisposableIterator featureIterator, DynObjectFeatureFacade featureFacade) { |
58 |
this.featureIterator = featureIterator;
|
59 |
this.featureFacade = featureFacade;
|
60 |
} |
61 |
|
62 |
/**
|
63 |
* Creates a new DynObjects iterator facade over a feature iterator.
|
64 |
* Each {@link Feature} will be returned through a new
|
65 |
* {@link DynObjectFeatureFacade} which allows the {@link Feature} to be
|
66 |
* used like a DynObject.
|
67 |
*
|
68 |
* @param featureIterator
|
69 |
* to facade
|
70 |
*/
|
71 |
public DynObjectIteratorFeatureIteratorFacade(
|
72 |
DisposableIterator featureIterator) { |
73 |
this.featureIterator = featureIterator;
|
74 |
} |
75 |
|
76 |
public void dispose() { |
77 |
featureIterator.dispose(); |
78 |
} |
79 |
|
80 |
public boolean hasNext() { |
81 |
return featureIterator.hasNext();
|
82 |
} |
83 |
|
84 |
public Object next() { |
85 |
Feature feature = (Feature) featureIterator.next(); |
86 |
if (featureFacade == null) { |
87 |
featureFacade = new DynObjectFeatureFacade();
|
88 |
} |
89 |
featureFacade.setFeatureCopy(feature); |
90 |
return featureFacade;
|
91 |
} |
92 |
|
93 |
public void remove() { |
94 |
featureIterator.remove(); |
95 |
} |
96 |
|
97 |
} |