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

History | View | Annotate | Download (10.2 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.exception.BaseException;
36
import org.gvsig.tools.observer.ComplexWeakReferencingObservable;
37
import org.gvsig.tools.observer.Observer;
38
import org.gvsig.tools.persistence.Persistent;
39
import org.gvsig.tools.service.spi.Services;
40
import org.gvsig.tools.visitor.Visitable;
41
import org.gvsig.tools.visitor.Visitor;
42

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

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

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

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

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

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

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

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

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

    
108
        /**
109
         * Returns the name associated to the store.
110
         * This name is provided for informational purposes only.
111
         * Explamples:
112
         * 
113
         * In a dbf the filename without the path
114
         * 
115
         * In a DDBB table the name of the table
116
         * 
117
         * In a WFS layer the name of the layer.
118
         *
119
         * @return String containing this store's name.
120
         */
121
        public String getName();
122
        
123
        /**
124
         * Returns a more descriptive name for the store that getName.
125
         * This name is provided for informational purposes only.
126
         * Explamples:
127
         * 
128
         * In a file based store may return the full name of the filename, path and filename.
129
         * 
130
         * In a data base based store may return "server:dbname:tablename"
131
         * 
132
         * In a WFS layer based store may return "server:layername"
133
         * 
134
         * @return String Containing the full name of the store
135
         */
136
        public String getFullName();
137

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

    
145
        /**
146
         * Return the provider name that use this store.
147
         * 
148
         * @return provider name of this store
149
         */
150
        public String getProviderName();
151
        
152
        /**
153
         * Refreshes this store state.
154
         *
155
         * @throws DataException
156
         */
157
        public void refresh() throws DataException;
158

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

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

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

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

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

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

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

    
247
        public DataSet getSelection() throws DataException;
248

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

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

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

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

    
288

    
289
        /**
290
         * Returns a new instance of a {@link DataQuery}.
291
         *
292
         * @return new {@link DataQuery} instance.
293
         *
294
         * @throws DataException
295
         */
296
        public DataQuery createQuery();
297
        
298
        /**
299
         * Gets the {@link Interval} of the store, that means the temporal
300
         * interval where the store has valid data.
301
         * @return
302
         *         a time interval or null if there is not time support
303
         */
304
        public Interval getInterval();
305
        
306
        /**
307
         * Gets all the possible values of time for which the store has data.  
308
         * @return
309
         *         a collection of {@link Time} objects.
310
         */
311
        public Collection getTimes();
312
        
313
        /**
314
         * Gets all the possible values of time for which the store has data
315
         * and intersects with an interval.
316
         * @param interval
317
         *         the interval of time
318
         * @return
319
         *         a collection of {@link Time} objects.
320
         */
321
        public Collection getTimes(Interval interval);
322
}
323