Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.fmap.dal / org.gvsig.fmap.dal.api / src / main / java / org / gvsig / fmap / dal / DataStore.java @ 44259

History | View | Annotate | Download (10.8 KB)

1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
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 3
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
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.fmap.dal;
25

    
26
import java.util.Collection;
27
import java.util.Iterator;
28
import java.util.List;
29

    
30
import org.gvsig.fmap.dal.exception.DataException;
31
import org.gvsig.fmap.dal.exception.ValidateDataParametersException;
32
import org.gvsig.metadata.Metadata;
33
import org.gvsig.timesupport.Interval;
34
import org.gvsig.timesupport.Time;
35
import org.gvsig.tools.dispose.Disposable;
36
import org.gvsig.tools.dynobject.DynObject;
37
import org.gvsig.tools.dynobject.DynObject_v2;
38
import org.gvsig.tools.exception.BaseException;
39
import org.gvsig.tools.observer.ComplexWeakReferencingObservable;
40
import org.gvsig.tools.observer.Observer;
41
import org.gvsig.tools.persistence.Persistent;
42
import org.gvsig.tools.service.spi.Services;
43
import org.gvsig.tools.util.UnmodifiableBasicList;
44
import org.gvsig.tools.util.UnmodifiableBasicMap;
45
import org.gvsig.tools.visitor.Visitable;
46
import org.gvsig.tools.visitor.Visitor;
47

    
48
/**
49
 * <p>
50
 * This is the basic interface for all data stores. Depending on the context, it
51
 * can represent a geographic layer, an alphanumeric database table or any data
52
 * file. DataStore offers generic services like:
53
 * <ul>
54
 * <li>Open and close data stores</li>
55
 * <li>Access to data sets, with the possibility of loading data in background.</li>
56
 * <li>Use of selection and locks, as well as data sets</li>
57
 * <li>Editing</li>
58
 * <li>Register event observers through the Observable interface</li>
59
 * <li>Access to embedded data stores (like GML)</li>
60
 * <li>Information about the Spatial Reference Systems used by the data store</li>
61
 * </ul>
62
 * </p>
63
 * <br>
64
 *
65
 */
66
public interface DataStore extends ComplexWeakReferencingObservable,
67
                Persistent, Metadata, Disposable, Visitable, DataFactoryUnit, Services, DynObject_v2 {
68

    
69
        public static final String METADATA_DEFINITION_NAME = "DataProvider";
70

    
71
        public static final String FEATURE_METADATA_DEFINITION_NAME = "FeatureProvider";
72

    
73
        public static final String SPATIAL_METADATA_DEFINITION_NAME = "SpatialProvider";
74

    
75
        /**
76
         * Metadata property name for the provider name provided by the data provider.
77
         *
78
         * This metadata is provided by all data providers.
79
         */
80
        public static final String METADATA_PROVIDER = "ProviderName";
81

    
82
        /**
83
         * Metadata property name for Container name provided by the data provider.
84
         * By explample, in a dbf file, this is the name of dbf.
85
         *
86
         * This metadata is provided by all data providers.
87
         */
88
        public static final String METADATA_CONTAINERNAME = "ContainerName";
89

    
90
        /**
91
         * Metadata property name for the feature type provided by the data provider.
92
         *
93
         * This metadata is provided by all tabular data providers.
94
         */
95
        public static final String METADATA_FEATURETYPE = "FeatureType";
96

    
97
        /**
98
         * Metadata property name for CRS provided by the data provider.
99
         *
100
         * This metadata is only provided by data provider with spatial
101
         * information.
102
         */
103
        public static final String METADATA_CRS = "CRS";
104

    
105
        /**
106
         * Metadata property name for Envelope provided by the data provider
107
         *
108
         * This metadata is only provided by data provider with spatial
109
         * information.
110
         */
111
        public static final String METADATA_ENVELOPE = "Envelope";
112

    
113
        /**
114
         * Returns the name associated to the store.
115
         * This name is provided for informational purposes only.
116
         * Explamples:
117
         *
118
         * In a dbf the filename without the path
119
         *
120
         * In a DDBB table the name of the table
121
         *
122
         * In a WFS layer the name of the layer.
123
         *
124
         * @return String containing this store's name.
125
         */
126
        public String getName();
127

    
128
        /**
129
         * Returns a more descriptive name for the store that getName.
130
         * This name is provided for informational purposes only.
131
         * Explamples:
132
         *
133
         * In a file based store may return the full name of the filename, path and filename.
134
         *
135
         * In a data base based store may return "server:dbname:tablename"
136
         *
137
         * In a WFS layer based store may return "server:layername"
138
         *
139
         * @return String Containing the full name of the store
140
         */
141
        public String getFullName();
142

    
143
        /**
144
         * Return the of parameters of this store
145
         *
146
         * @return parameters of this store
147
         */
148
        public DataStoreParameters getParameters();
149

    
150
        /**
151
         * Return the provider name that use this store.
152
         *
153
         * @return provider name of this store
154
         */
155
        public String getProviderName();
156

    
157
        /**
158
         * Refreshes this store state.
159
         *
160
         * @throws DataException
161
         */
162
        public void refresh() throws DataException;
163

    
164
        /**
165
         * Returns all available data.
166
         *
167
         * @return a set of data
168
         * @throws DataException
169
         *             if there is any error while loading the data
170
         */
171
        DataSet getDataSet() throws DataException;
172

    
173
        /**
174
         * Returns a subset of data taking into account the properties and
175
         * restrictions of the DataQuery.
176
         *
177
         * @param dataQuery
178
         *            defines the properties of the requested data
179
         * @return a set of data
180
         * @throws DataException
181
         *             if there is any error while loading the data
182
         */
183
        DataSet getDataSet(DataQuery dataQuery) throws DataException;
184

    
185
    /**
186
     * Provides each value of this Store to the provided {@link Visitor}.
187
     * The values received through the {@link Visitor#visit(Object)} method
188
     * may be transient, reused or externally modifiable, so they can't
189
     * be used to be stored in any external form out of the visit method.
190
     *
191
     * If you need to store any of the values out of the
192
     * {@link Visitor#visit(Object)} method execution, create a copy or clone
193
     * the received value in order to be stored.
194
     *
195
     * @param visitor
196
     *            the visitor to apply to each value.
197
     * @exception BaseException
198
     *                if there is an error while performing the visit
199
     */
200
    public void accept(Visitor visitor) throws BaseException;
201

    
202
        /**
203
     * Provides each value of this Store to the provided {@link Visitor}.
204
     * The values received through the {@link Visitor#visit(Object)} method
205
     * may be transient, reused or externally modifiable, so they can't
206
     * be used to be stored in any external form out of the visit method.
207
     *
208
     * If you need to store any of the values out of the
209
     * {@link Visitor#visit(Object)} method execution, create a copy or clone
210
     * the received value in order to be stored.
211
     *
212
     * @param visitor
213
     *            the visitor to apply to each value.
214
     * @param dataQuery
215
     *            defines the properties of the data to visit
216
     * @exception BaseException
217
     *                if there is an error while performing the visit
218
     */
219
        public void accept(Visitor visitor, DataQuery dataQuery)
220
                        throws BaseException;
221

    
222
        /**
223
         * Loads all available data and notifies the observer for each loaded block of data.
224
         *
225
         * @param observer
226
         *            to be notified for each block of data loaded
227
         * @throws DataException
228
         *             if there is any error while loading the data
229
         */
230
        void getDataSet(Observer observer) throws DataException;
231

    
232
        /**
233
         * Loads a subset of data taking into account the properties and
234
         * restrictions of the DataQuery. Data loading is performed by calling the
235
         * Observer, once each data block is loaded.
236
         *
237
         * @param dataQuery
238
         *            defines the properties of the requested data
239
         * @param observer
240
         *            to be notified for each block of data loaded
241
         * @throws DataException
242
         *             if there is any error while loading the data
243
         */
244
        void getDataSet(DataQuery dataQuery, Observer observer) throws DataException;
245

    
246
        /**
247
         * Returns the selected set of data
248
         *
249
         * @return DataSet
250
         */
251

    
252
        public DataSet getSelection() throws DataException;
253

    
254
        /**
255
         * Sets the current data selection with the given data set.
256
         *
257
         * @param DataSet
258
         *            selection
259
         * @throws DataException
260
         */
261
        public void setSelection(DataSet selection) throws DataException;
262

    
263
        /**
264
         * Creates a new selection.
265
         *
266
         * @return DataSet that contains the selection
267
         *
268
         * @throws DataException
269
         */
270
        public DataSet createSelection() throws DataException;
271

    
272
        /**
273
         * Returns an UnmodifiableBasicMap with this store children.
274
         * If do not have children, return an empty map.
275
         * Never returns null.
276
         *
277
         * @return an UnmodifiableBasicMap with this DataStore children
278
         */
279
        public UnmodifiableBasicMap<String,DataStore> getChildren();
280
        
281

    
282
        /**
283
         * Returns the DataServerExplorer to which this DataStore belongs, if there
284
         * is any.
285
         *
286
         * @return DataServerExplorer to which this DataStore belongs, or
287
         *         <code>null</code> if this was not accessed through any
288
         *         DataServerExplorer.
289
         *
290
         * @throws DataException
291
         * @throws ValidateDataParametersException
292
         */
293
        public DataServerExplorer getExplorer() throws DataException,
294
                        ValidateDataParametersException;
295

    
296

    
297
        /**
298
         * Returns a new instance of a {@link DataQuery}.
299
         *
300
         * @return new {@link DataQuery} instance.
301
         *
302
         * @throws DataException
303
         */
304
        public DataQuery createQuery();
305

    
306
        /**
307
         * Gets the {@link Interval} of the store, that means the temporal
308
         * interval where the store has valid data.
309
         * @return
310
         *         a time interval or null if there is not time support
311
         */
312
        public Interval getInterval();
313

    
314
        /**
315
         * Gets all the possible values of time for which the store has data.
316
         * @return
317
         *         a collection of {@link Time} objects.
318
         */
319
        public Collection getTimes();
320

    
321
        /**
322
         * Gets all the possible values of time for which the store has data
323
         * and intersects with an interval.
324
         * @param interval
325
         *         the interval of time
326
         * @return
327
         *         a collection of {@link Time} objects.
328
         */
329
        public Collection getTimes(Interval interval);
330

    
331
        /**
332
         * @param providerName
333
         * @param parameters
334
         * @throws DataException
335
         */
336
        public void useCache(String providerName, DynObject parameters) throws DataException;
337

    
338
        public DataStoreProviderFactory getProviderFactory();
339

    
340
    /**
341
     * @return
342
     */
343
    public DataCache getCache();
344

    
345
}
346