Statistics
| Revision:

root / branches / v2_0_0_prep / extensions / extGPE-gvSIG / src / org / gvsig / fmap / dal / store / gpe / GPESetProvider.java @ 34134

History | View | Annotate | Download (3.99 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

    
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.feature.FeatureQuery;
35
import org.gvsig.fmap.dal.feature.FeatureType;
36
import org.gvsig.fmap.dal.feature.spi.AbstractFeatureProviderIterator;
37
import org.gvsig.fmap.dal.feature.spi.AbstractFeatureSetProvider;
38
import org.gvsig.tools.exception.BaseException;
39

    
40
/**
41
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
42
 */
43
public class GPESetProvider extends AbstractFeatureSetProvider {
44

    
45
        public GPESetProvider(GPEStoreProvider store,
46
                        FeatureQuery query) {
47
                super(store, query, null);
48
        }
49

    
50
        public GPESetProvider(GPEStoreProvider store,
51
                        FeatureQuery query, FeatureType featureType) {
52
                super(store, query, featureType);
53
        }
54

    
55
        /* (non-Javadoc)
56
         * @see org.gvsig.fmap.dal.feature.spi.FeatureSetProvider#canFilter()
57
         */
58
        public boolean canFilter() {
59
                // TODO Auto-generated method stub
60
                return false;
61
        }
62

    
63
        /* (non-Javadoc)
64
         * @see org.gvsig.fmap.dal.feature.spi.FeatureSetProvider#canIterateFromIndex()
65
         */
66
        public boolean canIterateFromIndex() {
67
                // TODO Auto-generated method stub
68
                return false;
69
        }
70

    
71
        /* (non-Javadoc)
72
         * @see org.gvsig.fmap.dal.feature.spi.FeatureSetProvider#canOrder()
73
         */
74
        public boolean canOrder() {
75
                // TODO Auto-generated method stub
76
                return false;
77
        }
78

    
79
        /* (non-Javadoc)
80
         * @see org.gvsig.fmap.dal.feature.spi.FeatureSetProvider#getSize()
81
         */
82
        public long getSize() throws DataException {
83
                return getStore().getFeatureCount();
84
        }
85

    
86
        /* (non-Javadoc)
87
         * @see org.gvsig.fmap.dal.feature.spi.FeatureSetProvider#isEmpty()
88
         */
89
        public boolean isEmpty() throws DataException {
90
                // TODO Auto-generated method stub
91
                return false;
92
        }
93

    
94
        protected AbstractFeatureProviderIterator createFastIterator(long index)
95
                        throws DataException {
96
                return new GPEFastIterator((GPEStoreProvider) getStore(),
97
                                getFeatureType());
98
        }
99

    
100
        protected AbstractFeatureProviderIterator createIterator(long index)
101
                        throws DataException {
102
                return new GPEIterator((GPEStoreProvider) getStore(), getFeatureType());
103
        }
104

    
105
        protected class GPEIterator extends AbstractFeatureProviderIterator {
106
                protected FeatureType type;
107
                Iterator keys = null;
108
                HashMap features = null;
109

    
110
                public GPEIterator(GPEStoreProvider store, FeatureType type)
111
                                throws DataException {
112
                        super(store);
113
                        this.type = type;
114
                        features = store.getContentHandler().getFeatureSet();
115
                        keys = features.keySet().iterator();
116
                }
117

    
118
                protected boolean internalHasNext() {
119
                        return keys.hasNext();
120
                }
121

    
122
                protected Object internalNext() {
123
                        return features.get(keys.next());
124
                }
125

    
126
                /*
127
                 * (non-Javadoc)
128
                 * @see java.util.Iterator#remove()
129
                 */
130
                public void remove() {
131
                        throw new UnsupportedOperationException();
132
                }
133

    
134
                protected void doDispose() throws BaseException {
135
                        
136
                }
137
        }
138
        
139
        protected class GPEFastIterator extends GPEIterator {
140

    
141
                public GPEFastIterator(GPEStoreProvider store, FeatureType type) throws DataException {
142
                        super(store, type);
143
                }
144
        }
145

    
146
        protected void doDispose() throws BaseException {
147
                // Nothing to do
148
        }
149
}
150