Statistics
| Revision:

root / tags / v2_0_0_Build_2021 / libraries / libFMap_dal / src / org / gvsig / fmap / dal / DataStore.java @ 34087

History | View | Annotate | Download (7.16 KB)

1
package org.gvsig.fmap.dal;
2

    
3
import java.util.Iterator;
4

    
5
import org.gvsig.fmap.dal.exception.DataException;
6
import org.gvsig.fmap.dal.exception.ValidateDataParametersException;
7
import org.gvsig.metadata.Metadata;
8
import org.gvsig.tools.dispose.Disposable;
9
import org.gvsig.tools.exception.BaseException;
10
import org.gvsig.tools.observer.ComplexWeakReferencingObservable;
11
import org.gvsig.tools.observer.Observer;
12
import org.gvsig.tools.persistence.Persistent;
13
import org.gvsig.tools.visitor.Visitable;
14
import org.gvsig.tools.visitor.Visitor;
15

    
16
/**
17
 * <p>
18
 * This is the basic interface for all data stores. Depending on the context, it
19
 * can represent a geographic layer, an alphanumeric database table or any data
20
 * file. DataStore offers generic services like:
21
 * <ul>
22
 * <li>Open and close data stores</li>
23
 * <li>Access to data sets, with the possibility of loading data in background.</li>
24
 * <li>Use of selection and locks, as well as data sets</li>
25
 * <li>Editing</li>
26
 * <li>Register event observers through the Observable interface</li>
27
 * <li>Access to embedded data stores (like GML)</li>
28
 * <li>Information about the Spatial Reference Systems used by the data store</li>
29
 * </ul>
30
 * </p>
31
 * <br>
32
 *
33
 */
34
public interface DataStore extends ComplexWeakReferencingObservable,
35
                Persistent, Metadata, Disposable, Visitable {
36

    
37
        public static final String METADATA_DEFINITION_NAME = "DataProvider";
38

    
39
        public static final String FEATURE_METADATA_DEFINITION_NAME = "FeatureProvider";
40

    
41
        public static final String SPATIAL_METADATA_DEFINITION_NAME = "SpatialProvider";
42

    
43
        /**
44
         * Metadata property name for the provider name provided by the data provider.
45
         * 
46
         * This metadata is provided by all data providers.
47
         */
48
        public static final String METADATA_PROVIDER = "ProviderName";
49

    
50
        /**
51
         * Metadata property name for Container name provided by the data provider.
52
         * By explample, in a dbf file, this is the name of dbf.
53
         * 
54
         * This metadata is provided by all data providers.
55
         */
56
        public static final String METADATA_CONTAINERNAME = "ContainerName";
57

    
58
        /**
59
         * Metadata property name for the feature type provided by the data provider.
60
         * 
61
         * This metadata is provided by all tabular data providers.
62
         */
63
        public static final String METADATA_FEATURETYPE = "FeatureType";
64

    
65
        /**
66
         * Metadata property name for CRS provided by the data provider.
67
         * 
68
         * This metadata is only provided by data provider with spatial 
69
         * information.
70
         */
71
        public static final String METADATA_CRS = "CRS";
72

    
73
        /**
74
         * Metadata property name for Envelope provided by the data provider
75
         * 
76
         * This metadata is only provided by data provider with spatial 
77
         * information.
78
         */
79
        public static final String METADATA_ENVELOPE = "Envelope";
80

    
81
        /**
82
         * Returns the name associated to the store.
83
         * This name is provided for informational purposes only.
84
         * Explamples:
85
         * 
86
         * In a dbf the filename without the path
87
         * 
88
         * In a DDBB table the name of the table
89
         * 
90
         * In a WFS layer the name of the layer.
91
         *
92
         * @return String containing this store's name.
93
         */
94
        public String getName();
95
        
96
        /**
97
         * Returns a more descriptive name for the store that getName.
98
         * This name is provided for informational purposes only.
99
         * Explamples:
100
         * 
101
         * In a file based store may return the full name of the filename, path and filename.
102
         * 
103
         * In a data base based store may return "server:dbname:tablename"
104
         * 
105
         * In a WFS layer based store may return "server:layername"
106
         * 
107
         * @return String Containing the full name of the store
108
         */
109
        public String getFullName();
110

    
111
        /**
112
         * Return the of parameters of this store
113
         *
114
         * @return parameters of this store
115
         */
116
        public DataStoreParameters getParameters();
117

    
118
        /**
119
         * Return the provider name that use this store.
120
         * 
121
         * @return provider name of this store
122
         */
123
        public String getProviderName();
124
        
125
        /**
126
         * Refreshes this store state.
127
         *
128
         * @throws DataException
129
         */
130
        public void refresh() throws DataException;
131

    
132
        /**
133
         * Returns all available data.
134
         *
135
         * @return a set of data
136
         * @throws DataException
137
         *             if there is any error while loading the data
138
         */
139
        DataSet getDataSet() throws DataException;
140

    
141
        /**
142
         * Returns a subset of data taking into account the properties and
143
         * restrictions of the DataQuery.
144
         *
145
         * @param dataQuery
146
         *            defines the properties of the requested data
147
         * @return a set of data
148
         * @throws DataException
149
         *             if there is any error while loading the data
150
         */
151
        DataSet getDataSet(DataQuery dataQuery) throws DataException;
152

    
153
        /**
154
         * Provides each value of this container to the provided {@link Visitor}.
155
         * 
156
         * @param visitor
157
         *            the visitor to apply to each value.
158
         * @param dataQuery
159
         *            defines the properties of the data to visit
160
         * @exception BaseException
161
         *                if there is an error while performing the visit
162
         */
163
        public void accept(Visitor visitor, DataQuery dataQuery)
164
                        throws BaseException;
165

    
166
        /**
167
         * Loads all available data and notifies the observer for each loaded block of data.
168
         *
169
         * @param observer
170
         *            to be notified for each block of data loaded
171
         * @throws DataException
172
         *             if there is any error while loading the data
173
         */
174
        void getDataSet(Observer observer) throws DataException;
175

    
176
        /**
177
         * Loads a subset of data taking into account the properties and
178
         * restrictions of the DataQuery. Data loading is performed by calling the
179
         * Observer, once each data block is loaded.
180
         *
181
         * @param dataQuery
182
         *            defines the properties of the requested data
183
         * @param observer
184
         *            to be notified for each block of data loaded
185
         * @throws DataException
186
         *             if there is any error while loading the data
187
         */
188
        void getDataSet(DataQuery dataQuery, Observer observer) throws DataException;
189

    
190
        /**
191
         * Returns the selected set of data
192
         *
193
         * @return DataSet
194
         */
195

    
196
        public DataSet getSelection() throws DataException;
197

    
198
        /**
199
         * Sets the current data selection with the given data set.
200
         *
201
         * @param DataSet
202
         *            selection
203
         * @throws DataException
204
         */
205
        public void setSelection(DataSet selection) throws DataException;
206

    
207
        /**
208
         * Creates a new selection.
209
         *
210
         * @return DataSet that contains the selection
211
         *
212
         * @throws DataException
213
         */
214
        public DataSet createSelection() throws DataException;
215

    
216
        /**
217
         * Returns an iterator over this store children
218
         *
219
         * @return Iterator over this DataStore children
220
         */
221
        public Iterator getChildren();
222

    
223
        /**
224
         * Returns the DataServerExplorer to which this DataStore belongs, if there
225
         * is any.
226
         * 
227
         * @return DataServerExplorer to which this DataStore belongs, or
228
         *         <code>null</code> if this was not accessed through any
229
         *         DataServerExplorer.
230
         * 
231
         * @throws DataException
232
         * @throws ValidateDataParametersException
233
         */
234
        public DataServerExplorer getExplorer() throws DataException,
235
                        ValidateDataParametersException;
236

    
237

    
238
        /**
239
         * Returns a new instance of a {@link DataQuery}.
240
         *
241
         * @return new {@link DataQuery} instance.
242
         *
243
         * @throws DataException
244
         */
245
        public DataQuery createQuery();
246
}
247