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 / dynobjectutils / DynObjectIteratorFeatureIteratorFacade.java @ 46078
History | View | Annotate | Download (3.26 KB)
1 | 40559 | jjdelcerro | /**
|
---|---|---|---|
2 | * gvSIG. Desktop Geographic Information System.
|
||
3 | 40435 | jjdelcerro | *
|
4 | 40559 | jjdelcerro | * Copyright (C) 2007-2013 gvSIG Association.
|
5 | 40435 | jjdelcerro | *
|
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 | 40559 | jjdelcerro | * as published by the Free Software Foundation; either version 3
|
9 | 40435 | jjdelcerro | * 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 | 40559 | jjdelcerro | * For any additional information, do not hesitate to contact us
|
22 | * at info AT gvsig.com, or visit our website www.gvsig.com.
|
||
23 | 40435 | jjdelcerro | */
|
24 | 42775 | jjdelcerro | package org.gvsig.fmap.dal.feature.impl.dynobjectutils; |
25 | 40435 | jjdelcerro | |
26 | import org.gvsig.fmap.dal.feature.Feature; |
||
27 | import org.gvsig.fmap.dal.feature.FeatureSet; |
||
28 | import org.gvsig.tools.dispose.DisposableIterator; |
||
29 | import org.gvsig.tools.dynobject.DynObject; |
||
30 | import org.gvsig.tools.dynobject.DynObjectSet; |
||
31 | |||
32 | /**
|
||
33 | * {@link DynObject} implementation to facade a iterator of a {@link FeatureSet}
|
||
34 | * and allow to be used as a {@link DynObjectSet} iterator.
|
||
35 | *
|
||
36 | * @author gvSIG Team
|
||
37 | * @version $Id$
|
||
38 | *
|
||
39 | */
|
||
40 | public class DynObjectIteratorFeatureIteratorFacade implements |
||
41 | DisposableIterator { |
||
42 | |||
43 | private final DisposableIterator featureIterator; |
||
44 | private DynObjectFeatureFacade featureFacade;
|
||
45 | |||
46 | /**
|
||
47 | * Creates a new DynObjects iterator facade over a feature iterator.
|
||
48 | * Each {@link Feature} will be returned through a new or reused
|
||
49 | * {@link DynObjectFeatureFacade} which allows the {@link Feature} to be
|
||
50 | * used like a DynObject.
|
||
51 | *
|
||
52 | * @param featureIterator
|
||
53 | * to facade
|
||
54 | * @param featureFacade
|
||
55 | * if not null this object will be reused as the facade for the
|
||
56 | * Feature objects of the feature iterator
|
||
57 | */
|
||
58 | public DynObjectIteratorFeatureIteratorFacade(
|
||
59 | DisposableIterator featureIterator, DynObjectFeatureFacade featureFacade) { |
||
60 | this.featureIterator = featureIterator;
|
||
61 | this.featureFacade = featureFacade;
|
||
62 | } |
||
63 | |||
64 | /**
|
||
65 | * Creates a new DynObjects iterator facade over a feature iterator.
|
||
66 | * Each {@link Feature} will be returned through a new
|
||
67 | * {@link DynObjectFeatureFacade} which allows the {@link Feature} to be
|
||
68 | * used like a DynObject.
|
||
69 | *
|
||
70 | * @param featureIterator
|
||
71 | * to facade
|
||
72 | */
|
||
73 | public DynObjectIteratorFeatureIteratorFacade(
|
||
74 | DisposableIterator featureIterator) { |
||
75 | this.featureIterator = featureIterator;
|
||
76 | } |
||
77 | |||
78 | public void dispose() { |
||
79 | featureIterator.dispose(); |
||
80 | } |
||
81 | |||
82 | public boolean hasNext() { |
||
83 | return featureIterator.hasNext();
|
||
84 | } |
||
85 | |||
86 | public Object next() { |
||
87 | Feature feature = (Feature) featureIterator.next(); |
||
88 | if (featureFacade == null) { |
||
89 | featureFacade = new DynObjectFeatureFacade();
|
||
90 | } |
||
91 | 42775 | jjdelcerro | featureFacade.setFeature(feature.getCopy()); |
92 | 40435 | jjdelcerro | return featureFacade;
|
93 | } |
||
94 | |||
95 | public void remove() { |
||
96 | featureIterator.remove(); |
||
97 | } |
||
98 | |||
99 | } |