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 @ 43152

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

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

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

    
65
        public static final String METADATA_DEFINITION_NAME = "DataProvider";
66

    
67
        public static final String FEATURE_METADATA_DEFINITION_NAME = "FeatureProvider";
68

    
69
        public static final String SPATIAL_METADATA_DEFINITION_NAME = "SpatialProvider";
70

    
71
        /**
72
         * Metadata property name for the provider name provided by the data provider.
73
         *
74
         * This metadata is provided by all data providers.
75
         */
76
        public static final String METADATA_PROVIDER = "ProviderName";
77

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

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

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

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

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

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

    
139
        /**
140
         * Return the of parameters of this store
141
         *
142
         * @return parameters of this store
143
         */
144
        public DataStoreParameters getParameters();
145

    
146
        /**
147
         * Return the provider name that use this store.
148
         *
149
         * @return provider name of this store
150
         */
151
        public String getProviderName();
152

    
153
        /**
154
         * Refreshes this store state.
155
         *
156
         * @throws DataException
157
         */
158
        public void refresh() throws DataException;
159

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

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

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

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

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

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

    
242
        /**
243
         * Returns the selected set of data
244
         *
245
         * @return DataSet
246
         */
247

    
248
        public DataSet getSelection() throws DataException;
249

    
250
        /**
251
         * Sets the current data selection with the given data set.
252
         *
253
         * @param DataSet
254
         *            selection
255
         * @throws DataException
256
         */
257
        public void setSelection(DataSet selection) throws DataException;
258

    
259
        /**
260
         * Creates a new selection.
261
         *
262
         * @return DataSet that contains the selection
263
         *
264
         * @throws DataException
265
         */
266
        public DataSet createSelection() throws DataException;
267

    
268
        /**
269
         * Returns an iterator over this store children
270
         *
271
         * @return Iterator over this DataStore children
272
         */
273
        public Iterator getChildren();
274

    
275
        /**
276
         * Returns the DataServerExplorer to which this DataStore belongs, if there
277
         * is any.
278
         *
279
         * @return DataServerExplorer to which this DataStore belongs, or
280
         *         <code>null</code> if this was not accessed through any
281
         *         DataServerExplorer.
282
         *
283
         * @throws DataException
284
         * @throws ValidateDataParametersException
285
         */
286
        public DataServerExplorer getExplorer() throws DataException,
287
                        ValidateDataParametersException;
288

    
289

    
290
        /**
291
         * Returns a new instance of a {@link DataQuery}.
292
         *
293
         * @return new {@link DataQuery} instance.
294
         *
295
         * @throws DataException
296
         */
297
        public DataQuery createQuery();
298

    
299
        /**
300
         * Gets the {@link Interval} of the store, that means the temporal
301
         * interval where the store has valid data.
302
         * @return
303
         *         a time interval or null if there is not time support
304
         */
305
        public Interval getInterval();
306

    
307
        /**
308
         * Gets all the possible values of time for which the store has data.
309
         * @return
310
         *         a collection of {@link Time} objects.
311
         */
312
        public Collection getTimes();
313

    
314
        /**
315
         * Gets all the possible values of time for which the store has data
316
         * and intersects with an interval.
317
         * @param interval
318
         *         the interval of time
319
         * @return
320
         *         a collection of {@link Time} objects.
321
         */
322
        public Collection getTimes(Interval interval);
323

    
324
        /**
325
         * @param providerName
326
         * @param parameters
327
         * @throws DataException
328
         */
329
        public void useCache(String providerName, DynObject parameters) throws DataException;
330

    
331
        public DataStoreProviderFactory getFactory();
332
}
333