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 / feature / FeatureQuery.java @ 44023

History | View | Annotate | Download (8.37 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
/*
25
 * AUTHORS (In addition to CIT):
26
 * 2008 {DiSiD Technologies}  {Create Parameter object to define FeatureCollections queries}
27
 */
28
package org.gvsig.fmap.dal.feature;
29

    
30
import org.gvsig.expressionevaluator.Expression;
31
import org.gvsig.fmap.dal.DataQuery;
32
import org.gvsig.tools.evaluator.Evaluator;
33
import org.gvsig.tools.lang.Cloneable;
34

    
35
/**
36
 * Defines the properties of a collection of Features, as a result of a query
37
 * through a FeatureStore.
38
 * <p>
39
 * A FeatureQuery is always defined by a FeatureType, or by the list of
40
 * attribute names of the FeatureStore to return.
41
 * </p>
42
 * <p>
43
 * The filter allows to select Features whose properties have values with the
44
 * characteristics defined by the filter.
45
 * </p>
46
 * <p>
47
 * The order is used to set the order of the result FeatureCollection, based on
48
 * the values of the properties of the Features.
49
 * </p>
50
 * <p>
51
 * The scale parameter can be used by the FeatureStore as a hint about the
52
 * quality or resolution of the data needed to view or operate with the data
53
 * returned. As an example, the FeatureStore may use the scale to return only a
54
 * representative subset of the data, or maybe to return Features with less
55
 * detail, like a point or a line instead of a polygon.
56
 * </p>
57
 * <p>
58
 * If an implementation of FeatureStore is able to get other parameters to
59
 * customize the behavior of the getDataCollection methods, there is an option
60
 * to set more parameters through the setAttribute method.
61
 * </p>
62
 *
63
 * @author 2009- <a href="cordinyana@gvsig.org">C?sar Ordi?ana</a> - gvSIG team
64
 */
65
public interface FeatureQuery extends DataQuery, Cloneable {
66

    
67
        /**
68
         * Returns the names of the attributes to load from each {@link Feature}.
69
         *
70
         * @return the attribute names to load
71
         */
72
        String[] getAttributeNames();
73

    
74
        /**
75
         * Sets the names of the attributes to load from each {@link Feature}.
76
         *
77
         * @param attributeNames
78
         *            the attribute names to load
79
         */
80
        void setAttributeNames(String[] attributeNames);
81

    
82
        void retrievesAllAttributes();
83
    
84
    /**
85
         * Adds the name of an attribute that has to be used to load each
86
         * {@link Feature}.
87
         *
88
         * @param attributeName
89
         *             the attribute name to load
90
         */
91
        void addAttributeName(String attributeName);
92

    
93
    public void addPrimaryKeyAttributeNames(FeatureStore store);
94

    
95
    public void addEssentialAttributeNames(FeatureStore store);
96

    
97
    /**
98
     * Return true if has set attribute names
99
     *
100
     * @return true if has attribute names, otherwise false
101
     */
102
    boolean hasAttributeNames();
103

    
104
    /**
105
     * Remove all the attribute names specifieds.
106
     */
107
    void clearAttributeNames();
108

    
109
    /**
110
         * Returns the names of the attributes that are constants in each {@link Feature}.
111
         * These attributes will not be charged.
112
         *
113
         * @return the attribute names that are constant
114
         */
115
        String[] getConstantsAttributeNames();
116

    
117
        /**
118
         * Set of attribute names to be treated as constants for each {@link Feature}.
119
         *
120
         * @param attributeNames
121
         *            the attribute names to be constants
122
         */
123
        void setConstantsAttributeNames(String[] attributeNames);
124

    
125
        /**
126
         * Add an attribute name that will be treated as constant for each
127
         * {@link Feature}.
128
         *
129
         * @param attributeName
130
         *             the attribute name to be treated as constant
131
         */
132
        void addConstantAttributeName(String attributeName);
133

    
134
        /**
135
         * Return true if has set constants attribute names
136
         *
137
         * @return true if has constants attribute names, otherwise false
138
         */
139
        boolean hasConstantsAttributeNames();
140

    
141
        /**
142
         * Remove all the names specified as constants attributes.
143
         */
144
        void clearConstantsAttributeNames();
145

    
146
        /**
147
         * Sets the {@link FeatureType} of the {@link Feature}s to load. It may be
148
         * used as an alternative way to set a subset of the list of attribute names
149
         * to load, by creating a sub-FeatureType.
150
         *
151
         * @param featureType
152
         *            the feature type of the data to load
153
         */
154
        void setFeatureType(FeatureType featureType);
155

    
156
        /**
157
         * Returns the {@link FeatureType} id of the {@link Feature}s to load.
158
         *
159
         * @return the {@link FeatureType} id of the {@link Feature}s to load
160
         */
161
        String getFeatureTypeId();
162

    
163
        /**
164
         * Sets the {@link FeatureType} id of the {@link Feature}s to load. This way
165
         * all {@link Feature} attributes will be loaded.
166
         *
167
         * @param featureTypeId
168
         *            the {@link FeatureType} id of the {@link Feature}s to load
169
         */
170
        void setFeatureTypeId(String featureTypeId);
171

    
172
        /**
173
         * Returns the filter to apply to the {@link Feature}s to load.
174
         *
175
         * @return the filter
176
         */
177
        Evaluator getFilter();
178

    
179
        /**
180
         * Sets the filter to apply to the {@link Feature}s to load.
181
         *
182
         * @param filter
183
         *            the filter to apply to the {@link Feature}s to load
184
         */
185
        void setFilter(Evaluator filter);
186

    
187
        void setFilter(Expression filter);
188

    
189
        void setFilter(String filter);
190

    
191
        /**
192
         * Adds a filter to apply to the {@link Feature}s to load. A query
193
         * can have more that one filter and all of them are applied when
194
         * the query is applied.
195
         * If filter is null do nothing.
196
         *
197
         * @param filter
198
         *             a filter to apply to the {@link Feature}s to load
199
         */
200
        void addFilter(Evaluator filter);
201

    
202
        void addFilter(Expression filter);
203

    
204
        void addFilter(String filter);
205

    
206
        void clearFilter();
207
        
208
        /**
209
         * Returns if a filter has been defined for the query.
210
         *
211
         * @return if a filter has been defined for the query
212
         */
213
        boolean hasFilter();
214

    
215
        /**
216
         * Returns the order of the {@link Feature}s to load.
217
         *
218
         * @return the order of the {@link Feature}s to load
219
         */
220
        FeatureQueryOrder getOrder();
221

    
222
        /**
223
         * Sets the order of the {@link Feature}s to load.
224
         *
225
         * @param order
226
         *            the order of the {@link Feature}s to load
227
         */
228
        void setOrder(FeatureQueryOrder order);
229

    
230
        /**
231
         * Returns if an order has been set for the elements returned by the query.
232
         *
233
         * @return if an order has been set for the elements returned by the query
234
         */
235
        boolean hasOrder();
236

    
237
        /**
238
     * @return 
239
         * @deprecated to be removed in gvSIG 2.0
240
         * @see #clone()
241
         */
242
        FeatureQuery getCopy();
243

    
244
        /**
245
         * Returns the maximum number of elements to return with this query.
246
         * <p>
247
         * <strong>NOTE:</strong> this value may be ignored by the underlying data
248
         * source, or only used as a hint, so don't rely on it being used, as you
249
         * may actually get more values than the limit.
250
         * </p>
251
         *
252
         * @return the maximum number of elements to return with this query
253
         */
254
        long getLimit();
255

    
256
        /**
257
         * Sets the maximum number of elements to return with this query.
258
         * <p>
259
         * <strong>NOTE:</strong> this value may be ignored by the underlying data
260
         * source, or only used as a hint, so don't rely on it being used, as you
261
         * may actually get more values than the limit.
262
         * </p>
263
         *
264
         * @param limit
265
         *            the maximum number of elements to return with this query
266
         */
267
        void setLimit(long limit);
268

    
269
        /**
270
         * Returns the load page size, as the number of elements to be retrieved in
271
         * block by the data source. This value is only used as a hint to the
272
         * underlying data source, as a way to tell how many Features may be read in
273
         * a block.
274
         *
275
         * @return the load page size
276
         */
277
        long getPageSize();
278

    
279
        /**
280
         * Sets the load page size, as the number of elements to be retrieved in
281
         * block by the data source. This value is only used as a hint to the
282
         * underlying data source, as a way to tell how many Features may be read in
283
         * a block.
284
         *
285
         * @param pageSize
286
         *            the load page size
287
         */
288
        void setPageSize(long pageSize);
289
}