root / branches / v2_0_0_prep / extensions / extGPE-gvSIG / src / org / gvsig / fmap / dal / store / gpe / GPESetProvider.java @ 27499
History | View | Annotate | Download (4.82 KB)
1 | 27499 | jpiera | /* 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 | |||
23 | /*
|
||
24 | * AUTHORS (In addition to CIT):
|
||
25 | * 2009 {Iver T.I.} {Task}
|
||
26 | */
|
||
27 | |||
28 | package org.gvsig.fmap.dal.store.gpe; |
||
29 | |||
30 | import java.util.HashMap; |
||
31 | import java.util.Iterator; |
||
32 | |||
33 | import org.gvsig.fmap.dal.exception.DataException; |
||
34 | import org.gvsig.fmap.dal.exception.ReadRuntimeException; |
||
35 | import org.gvsig.fmap.dal.feature.Feature; |
||
36 | import org.gvsig.fmap.dal.feature.FeatureQuery; |
||
37 | import org.gvsig.fmap.dal.feature.FeatureType; |
||
38 | import org.gvsig.fmap.dal.feature.impl.DefaultFeature; |
||
39 | import org.gvsig.fmap.dal.feature.spi.FeatureData; |
||
40 | import org.gvsig.fmap.dal.feature.spi.FeatureSetProvider; |
||
41 | import org.gvsig.fmap.dal.store.gpe.handlers.FmapContentHandler; |
||
42 | import org.gvsig.gpe.GPEFactory; |
||
43 | |||
44 | /**
|
||
45 | * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
|
||
46 | */
|
||
47 | public class GPESetProvider implements FeatureSetProvider { |
||
48 | private GPEStoreProvider store;
|
||
49 | private FeatureQuery query;
|
||
50 | private FeatureType featureType;
|
||
51 | |||
52 | public GPESetProvider(GPEStoreProvider store,
|
||
53 | FeatureQuery query) { |
||
54 | this.store = store;
|
||
55 | this.query = query;
|
||
56 | } |
||
57 | |||
58 | public GPESetProvider(GPEStoreProvider store,
|
||
59 | FeatureQuery query, FeatureType featureType) { |
||
60 | this.store = store;
|
||
61 | this.query = query;
|
||
62 | this.featureType = featureType;
|
||
63 | } |
||
64 | |||
65 | /* (non-Javadoc)
|
||
66 | * @see org.gvsig.fmap.dal.feature.spi.FeatureSetProvider#canFilter()
|
||
67 | */
|
||
68 | public boolean canFilter() { |
||
69 | // TODO Auto-generated method stub
|
||
70 | return false; |
||
71 | } |
||
72 | |||
73 | /* (non-Javadoc)
|
||
74 | * @see org.gvsig.fmap.dal.feature.spi.FeatureSetProvider#canIterateFromIndex()
|
||
75 | */
|
||
76 | public boolean canIterateFromIndex() { |
||
77 | // TODO Auto-generated method stub
|
||
78 | return false; |
||
79 | } |
||
80 | |||
81 | /* (non-Javadoc)
|
||
82 | * @see org.gvsig.fmap.dal.feature.spi.FeatureSetProvider#canOrder()
|
||
83 | */
|
||
84 | public boolean canOrder() { |
||
85 | // TODO Auto-generated method stub
|
||
86 | return false; |
||
87 | } |
||
88 | |||
89 | /* (non-Javadoc)
|
||
90 | * @see org.gvsig.fmap.dal.feature.spi.FeatureSetProvider#fastIterator(long)
|
||
91 | */
|
||
92 | public Iterator fastIterator(long index) throws DataException { |
||
93 | return new GPEFastIterator(this.store, this.featureType); |
||
94 | } |
||
95 | |||
96 | /* (non-Javadoc)
|
||
97 | * @see org.gvsig.fmap.dal.feature.spi.FeatureSetProvider#fastIterator()
|
||
98 | */
|
||
99 | public Iterator fastIterator() throws DataException { |
||
100 | return fastIterator(0); |
||
101 | } |
||
102 | |||
103 | /* (non-Javadoc)
|
||
104 | * @see org.gvsig.fmap.dal.feature.spi.FeatureSetProvider#getSize()
|
||
105 | */
|
||
106 | public long getSize() throws DataException { |
||
107 | return store.getFeatureCount();
|
||
108 | } |
||
109 | |||
110 | /* (non-Javadoc)
|
||
111 | * @see org.gvsig.fmap.dal.feature.spi.FeatureSetProvider#isEmpty()
|
||
112 | */
|
||
113 | public boolean isEmpty() throws DataException { |
||
114 | // TODO Auto-generated method stub
|
||
115 | return false; |
||
116 | } |
||
117 | |||
118 | /* (non-Javadoc)
|
||
119 | * @see org.gvsig.fmap.dal.feature.spi.FeatureSetProvider#iterator()
|
||
120 | */
|
||
121 | public Iterator iterator() throws DataException { |
||
122 | return this.iterator(0); |
||
123 | } |
||
124 | |||
125 | /* (non-Javadoc)
|
||
126 | * @see org.gvsig.fmap.dal.feature.spi.FeatureSetProvider#iterator(long)
|
||
127 | */
|
||
128 | public Iterator iterator(long index) throws DataException { |
||
129 | return new GPEIterator(this.store, this.featureType); |
||
130 | } |
||
131 | |||
132 | protected class GPEIterator implements Iterator { |
||
133 | protected GPEStoreProvider store;
|
||
134 | protected FeatureType type;
|
||
135 | Iterator keys = null; |
||
136 | HashMap<String, Feature> features = null; |
||
137 | |||
138 | public GPEIterator(GPEStoreProvider store, FeatureType type) throws DataException { |
||
139 | this.store = store;
|
||
140 | this.type = type;
|
||
141 | features = ((FmapContentHandler)store.getParser().getContentHandler()) |
||
142 | .getFeatureSet(); |
||
143 | keys = features.keySet().iterator(); |
||
144 | } |
||
145 | |||
146 | /*
|
||
147 | * (non-Javadoc)
|
||
148 | * @see java.util.Iterator#hasNext()
|
||
149 | */
|
||
150 | public boolean hasNext() { |
||
151 | return keys.hasNext();
|
||
152 | } |
||
153 | |||
154 | /*
|
||
155 | * (non-Javadoc)
|
||
156 | * @see java.util.Iterator#next()
|
||
157 | */
|
||
158 | public Object next() { |
||
159 | return ((DefaultFeature)features.get(keys.next())).getData();
|
||
160 | } |
||
161 | |||
162 | /*
|
||
163 | * (non-Javadoc)
|
||
164 | * @see java.util.Iterator#remove()
|
||
165 | */
|
||
166 | public void remove() { |
||
167 | throw new UnsupportedOperationException(); |
||
168 | } |
||
169 | } |
||
170 | |||
171 | protected class GPEFastIterator extends GPEIterator { |
||
172 | |||
173 | public GPEFastIterator(GPEStoreProvider store, FeatureType type) throws DataException { |
||
174 | super(store, type);
|
||
175 | } |
||
176 | } |
||
177 | } |