Statistics
| Revision:

root / branches / v2_0_0_prep / libraries / libFMap_dal / src / org / gvsig / fmap / dal / DataStore.java @ 32880

History | View | Annotate | Download (6.45 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 this store's name.
83
         *
84
         * @return String containing this store's name.
85
         */
86
        public String getName();
87

    
88
        /**
89
         * Return the of parameters of this store
90
         *
91
         * @return parameters of this store
92
         */
93
        public DataStoreParameters getParameters();
94

    
95
        /**
96
         * Return the provider name that use this store.
97
         * 
98
         * @return provider name of this store
99
         */
100
        public String getProviderName();
101
        
102
        /**
103
         * Refreshes this store state.
104
         *
105
         * @throws DataException
106
         */
107
        public void refresh() throws DataException;
108

    
109
        /**
110
         * Returns all available data.
111
         *
112
         * @return a set of data
113
         * @throws DataException
114
         *             if there is any error while loading the data
115
         */
116
        DataSet getDataSet() throws DataException;
117

    
118
        /**
119
         * Returns a subset of data taking into account the properties and
120
         * restrictions of the DataQuery.
121
         *
122
         * @param dataQuery
123
         *            defines the properties of the requested data
124
         * @return a set of data
125
         * @throws DataException
126
         *             if there is any error while loading the data
127
         */
128
        DataSet getDataSet(DataQuery dataQuery) throws DataException;
129

    
130
        /**
131
         * Provides each value of this container to the provided {@link Visitor}.
132
         * 
133
         * @param visitor
134
         *            the visitor to apply to each value.
135
         * @param dataQuery
136
         *            defines the properties of the data to visit
137
         * @exception BaseException
138
         *                if there is an error while performing the visit
139
         */
140
        public void accept(Visitor visitor, DataQuery dataQuery)
141
                        throws BaseException;
142

    
143
        /**
144
         * Loads all available data and notifies the observer for each loaded block of data.
145
         *
146
         * @param observer
147
         *            to be notified for each block of data loaded
148
         * @throws DataException
149
         *             if there is any error while loading the data
150
         */
151
        void getDataSet(Observer observer) throws DataException;
152

    
153
        /**
154
         * Loads a subset of data taking into account the properties and
155
         * restrictions of the DataQuery. Data loading is performed by calling the
156
         * Observer, once each data block is loaded.
157
         *
158
         * @param dataQuery
159
         *            defines the properties of the requested data
160
         * @param observer
161
         *            to be notified for each block of data loaded
162
         * @throws DataException
163
         *             if there is any error while loading the data
164
         */
165
        void getDataSet(DataQuery dataQuery, Observer observer) throws DataException;
166

    
167
        /**
168
         * Returns the selected set of data
169
         *
170
         * @return DataSet
171
         */
172

    
173
        public DataSet getSelection() throws DataException;
174

    
175
        /**
176
         * Sets the current data selection with the given data set.
177
         *
178
         * @param DataSet
179
         *            selection
180
         * @throws DataException
181
         */
182
        public void setSelection(DataSet selection) throws DataException;
183

    
184
        /**
185
         * Creates a new selection.
186
         *
187
         * @return DataSet that contains the selection
188
         *
189
         * @throws DataException
190
         */
191
        public DataSet createSelection() throws DataException;
192

    
193
        /**
194
         * Returns an iterator over this store children
195
         *
196
         * @return Iterator over this DataStore children
197
         */
198
        public Iterator getChildren();
199

    
200
        /**
201
         * Returns the DataServerExplorer to which this DataStore belongs, if there
202
         * is any.
203
         * 
204
         * @return DataServerExplorer to which this DataStore belongs, or
205
         *         <code>null</code> if this was not accessed through any
206
         *         DataServerExplorer.
207
         * 
208
         * @throws DataException
209
         * @throws ValidateDataParametersException
210
         */
211
        public DataServerExplorer getExplorer() throws DataException,
212
                        ValidateDataParametersException;
213

    
214

    
215
        /**
216
         * Returns a new instance of a {@link DataQuery}.
217
         *
218
         * @return new {@link DataQuery} instance.
219
         *
220
         * @throws DataException
221
         */
222
        public DataQuery createQuery();
223
}
224