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

History | View | Annotate | Download (9.3 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 java.util.List;
31
import java.util.Map;
32
import org.gvsig.expressionevaluator.Expression;
33
import org.gvsig.fmap.dal.DataQuery;
34
import org.gvsig.tools.evaluator.Evaluator;
35
import org.gvsig.tools.lang.Cloneable;
36

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

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

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

    
83
  void retrievesAllAttributes();
84

    
85
  /**
86
   * Adds the name of an attribute that has to be used to load each
87
   * {@link Feature}.
88
   *
89
   * @param attributeName 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
111
   * {@link Feature}. 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 the attribute names to be constants
121
   */
122
  void setConstantsAttributeNames(String[] attributeNames);
123

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

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

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

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

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

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

    
169
  /**
170
   * Returns the filter to apply to the {@link Feature}s to load.
171
   *
172
   * @return the filter
173
   */
174
  Evaluator getFilter();
175
  
176
  /** 
177
   * Return the Expression associated to the filter.
178
   * If the current filter is not an Expression, return null.
179
   * 
180
   * @return the expression of the filter.
181
   */
182
  Expression getExpressionFilter();
183

    
184
  /**
185
   * Sets the filter to apply to the {@link Feature}s to load.
186
   *
187
   * @param filter the filter to apply to the {@link Feature}s to load
188
   */
189
  void setFilter(Evaluator filter);
190

    
191
  void setFilter(Expression filter);
192

    
193
  void setFilter(String filter);
194

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

    
204
  void addFilter(Expression filter);
205

    
206
  void addFilter(String filter);
207

    
208
  void clearFilter();
209

    
210
  /**
211
   * Returns if a filter has been defined for the query.
212
   *
213
   * @return if a filter has been defined for the query
214
   */
215
  boolean hasFilter();
216

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

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

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

    
238
  /**
239
   * @return @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 may
249
   * 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 may
261
   * actually get more values than the limit.
262
   * </p>
263
   *
264
   * @param limit the maximum number of elements to return with this query
265
   */
266
  void setLimit(long limit);
267

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

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

    
287
  /**
288
   * Return the names of attributes for group the features.
289
   * 
290
   * @return the list of names to group features.
291
   */
292
  public List<String> getGroupByColumns();
293
  
294
  public boolean isAGroupByColumn(String name);
295
  
296
  public boolean hasGroupByColumns();
297

    
298
  /**
299
   * Return the aggregate functions useds for every attribute of the feature.
300
   * The map is indexed by the name of the attribute and contains the aggregate 
301
   * functions used by each attribute.
302
   * 
303
   * @return a Map with the aggregate function by attribute
304
   */
305
  public Map<String,String> getAggregateFunctions();
306

    
307
  @Deprecated
308
  public String getAggregate(String name);
309
  
310
  public String getAggregate(String tableName, String name);
311
  
312
  public boolean hasAggregateFunctions();
313

    
314
  public void copyFrom(FeatureQuery query);
315
      
316
  public FeatureExtraColumns getExtraColumn();
317

    
318
}