Revision 44346 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/FeatureStore.java

View differences:

FeatureStore.java
47 47
import org.gvsig.tools.observer.Observer;
48 48
import org.gvsig.tools.undo.UndoRedoStack;
49 49
import org.gvsig.tools.resourcesstorage.ResourcesStorage;
50
import org.gvsig.tools.util.UnmodifiableBasicList64;
50 51

  
51 52
/**
52 53
 * <p>
......
187 188
     *
188 189
     * Query related services
189 190
     */
191
    
192
    /** 
193
     * Create a {@link FeatureQuery} with the restrictions indicateds.
194
     * 
195
     * "filter" will be null or a valid filter expression for the store.
196
     * 
197
     * "sortBy" can be null to use the store's default order.
198
     * 
199
     * The parameter sortBy can be an attribute name or a comma separated list. 
200
     * Each attribute name can be preceded or followed by "+" or "-" to indicate 
201
     * the order to use to sort by that attribute. 
202
     * 
203
     * If no "+" or "-" is indicated, the "asc" parameter will be used to 
204
     * determine if the order is ascending, "true" or decent, "false".
205
     * 
206
     * @param filter an {@link String} expression used to filter the features in the store.
207
     * @param sortBy Attribute names separated by commas used to sort the list to return.
208
     * @param asc use order ascending, true, or descending, false.
209
     * @return a {@link FeatureQuery} with the restrictions.
210
     * @see {@link FeatureQuery}
211
     */
212
    public FeatureQuery createFeatureQuery(String filter, String sortBy, boolean asc);
190 213

  
214
    /** 
215
     * Create a {@link FeatureQuery} with the restrictions indicateds.
216
     * 
217
     * "filter" will be null or {@link Expression} valid for the store.
218
     * 
219
     * "sortBy" can be null to use the store's default order.
220
     * 
221
     * The parameter sortBy can be an attribute name or a comma separated list. 
222
     * Each attribute name can be preceded or followed by "+" or "-" to indicate 
223
     * the order to use to sort by that attribute. 
224
     * 
225
     * If no "+" or "-" is indicated, the "asc" parameter will be used to 
226
     * determine if the order is ascending, "true" or decent, "false".
227
     * 
228
     * @param filter an {@link String} expression used to filter the features in the store.
229
     * @param sortBy Attribute names separated by commas used to sort the list to return.
230
     * @param asc use order ascending, true, or descending, false.
231
     * @return a {@link FeatureQuery} with the restrictions.
232
     * @see {@link FeatureQuery}
233
     */
234
    public FeatureQuery createFeatureQuery(Expression filter, String sortBy, boolean asc);
235
        
191 236
    /**
192 237
     * Returns all available features in the store.
193
     * <p>
194
     * <em>
195
     * <strong>NOTE:</strong> if you use this method to get a
196
     * {@link FeatureSet}, you  must get sure it is disposed
197
     * (@see {@link DisposableIterator#dispose()}) in any case, even if an
198
     * error occurs while getting the data. It is recommended to use the
199
     * <code>accept</code> methods instead, which handle everything for you.
200
     * Take into account the accept methods may use a fast iterator to
201
     * get the features.
202
     * </em>
203
     * </p>
204 238
     *
205
     * @see #accept(org.gvsig.tools.visitor.Visitor)
206
     *
207
     * @return a collection of features
208
     * @throws ReadException
209
     *             if there is any error while reading the features
239
     * It is a utility method that calls {@link #getFeatureSet(FeatureQuery)}
240
     * 
241
     * @return the {@link FeatureSet} 
242
     * @throws ReadException if there is any error while reading the features
243
     * @see {@link #accept(org.gvsig.tools.visitor.Visitor)}, {@link #getFeatureSet(FeatureQuery)}
210 244
     */
211 245
    FeatureSet getFeatureSet() throws DataException;
212 246

  
247
    /**
248
     * Return a subset of features.
249
     * 
250
     * It is a utility method that calls {@link #getFeatureSet(FeatureQuery)}
251
     * 
252
     * @param filter an {@link String} expression used to filter the features in the store.
253
     * @return the {@link FeatureSet} 
254
     * @throws ReadException if there is any error while reading the features
255
     * @see {@link #createFeatureQuery(Expression,String,boolean)}, {@link #getFeatureSet(FeatureQuery)}
256
     */
213 257
    FeatureSet getFeatureSet(String filter) throws DataException;
214 258

  
259
    /**
260
     * Return a subset of features.
261
     * 
262
     * It is a utility method that calls {@link #getFeatureSet(FeatureQuery)}
263
     * 
264
     * The sort order used is ascending.
265
     * 
266
     * @param filter an {@link String} expression used to filter the features in the store.
267
     * @param sortBy Attribute names separated by commas used to sort the list to return.
268
     * @return the {@link FeatureSet} 
269
     * @throws ReadException if there is any error while reading the features
270
     * @see {@link #createFeatureQuery(Expression,String,boolean)}, {@link #getFeatureSet(FeatureQuery)}
271
     */
215 272
    FeatureSet getFeatureSet(String filter, String sortBy) throws DataException;
216 273

  
274
    /**
275
     * Return a subset of features.
276
     * 
277
     * It is a utility method that calls {@link #getFeatureSet(FeatureQuery)}
278
     * 
279
     * @param filter an {@link String} expression used to filter the features in the store.
280
     * @param sortBy Attribute names separated by commas used to sort the list to return.
281
     * @param asc use order ascending, true, or descending, false.
282
     * @return the {@link FeatureSet} 
283
     * @throws ReadException if there is any error while reading the features
284
     * @see {@link #createFeatureQuery(Expression,String,boolean)}, {@link #getFeatureSet(FeatureQuery)}
285
     */
217 286
    FeatureSet getFeatureSet(String filter, String sortBy, boolean asc) throws DataException;
218 287

  
288
    /**
289
     * Return a subset of features.
290
     * 
291
     * It is a utility method that calls {@link #getFeatureSet(FeatureQuery)}
292
     * 
293
     * @param filter an {@link Expression} used to filter the features in the store.
294
     * @return the {@link FeatureSet} 
295
     * @throws DataException 
296
     * @see {@link #createFeatureQuery(Expression,String,boolean)}, {@link #getFeatureSet(FeatureQuery)}
297
     */
219 298
    FeatureSet getFeatureSet(Expression filter) throws DataException;
220 299

  
300
    /**
301
     * Return a subset of features.
302
     * 
303
     * It is a utility method that calls {@link #getFeatureSet(FeatureQuery)}
304
     * 
305
     * The sort order used is ascending.
306
     * 
307
     * @param filter an {@link Expression} used to filter the features in the store.
308
     * @param sortBy Attribute names separated by commas used to sort the list to return.
309
     * @return the {@link FeatureSet} 
310
     * @throws ReadException if there is any error while reading the features
311
     * @see {@link #createFeatureQuery(Expression,String,boolean)}, {@link #getFeatureSet(FeatureQuery)}
312
     */
221 313
    FeatureSet getFeatureSet(Expression filter, String sortBy) throws DataException;
222 314

  
315
    /**
316
     * Return a subset of features.
317
     * 
318
     * It is a utility method that calls {@link #getFeatureSet(FeatureQuery)}
319
     * 
320
     * @param filter an {@link Expression} used to filter the features in the store.
321
     * @param sortBy Attribute names separated by commas used to sort the list to return.
322
     * @param asc use order ascending, true, or descending, false.
323
     * @return the {@link FeatureSet} 
324
     * @throws DataException 
325
     * @see {@link #createFeatureQuery(Expression,String,boolean)}, {@link #getFeatureSet(FeatureQuery)}
326
     */
223 327
    FeatureSet getFeatureSet(Expression filter, String sortBy, boolean asc) throws DataException;
328

  
224 329
    /**
225 330
     * Returns a subset of features taking into account the properties and
226
     * restrictions of the FeatureQuery.
331
     * restrictions of the {@link FeatureQuery}.
332
     * 
333
     * If {@link FeatureQuery} is null, return al features in the store.
334
     * 
227 335
     * <p>
228 336
     * <em>
229 337
     * <strong>NOTE:</strong> if you use this method to get a
......
236 344
     * </em>
237 345
     * </p>
238 346
     *
239
     * @see #accept(org.gvsig.tools.visitor.Visitor,
240
     *      org.gvsig.fmap.dal.DataQuery)
241
     *
242
     * @param featureQuery
243
     *            defines the characteristics of the features to return
244
     * @return a collection of features
245
     * @throws ReadException
246
     *             if there is any error while reading the features
347
     * @param featureQuery defines the characteristics of the features to return.
348
     * @return the {@link FeatureSet} 
349
     * @throws ReadException if there is any error while reading the features.
350
     * @see #accept(org.gvsig.tools.visitor.Visitor, org.gvsig.fmap.dal.DataQuery)
247 351
     */
248 352
    FeatureSet getFeatureSet(FeatureQuery featureQuery) throws DataException;
249 353

  
250 354
    /**
251 355
     * Loads a subset of features taking into account the properties and
252
     * restrictions of the FeatureQuery. Feature loading is performed by calling
253
     * the Observer, once each loaded Feature.
356
     * restrictions of the FeatureQuery. 
357
     * When feature loading is finished call the Observer passing the
358
     * {@link FeatureSet}  loaded.
254 359
     *
255
     * @param featureQuery
256
     *            defines the characteristics of the features to return
257
     * @param observer
258
     *            to be notified of each loaded Feature
259
     * @throws DataException
260
     *             if there is any error while loading the features
360
     * @param featureQuery defines the characteristics of the features to return.
361
     * @param observer to be notified when loading is finished.
362
     * @throws DataException if there is any error while loading the features
261 363
     */
262
    void getFeatureSet(FeatureQuery featureQuery, Observer observer)
263
        throws DataException;
364
    void getFeatureSet(FeatureQuery featureQuery, Observer observer) throws DataException;
264 365

  
265 366
    /**
266 367
     * Loads all available feature in the store. The loading of Features is
267 368
     * performed by calling the Observer, once each loaded Feature.
268 369
     *
269
     * @param observer
270
     *            to be notified of each loaded Feature
271
     * @throws DataException
272
     *             if there is any error while loading the features
370
     * @param observer to be notified of each loaded Feature
371
     * @throws DataException if there is any error while loading the features
273 372
     */
274 373
    void getFeatureSet(Observer observer) throws DataException;
275 374

  
276 375
    /**
277 376
     * Return a paginated list of Features filtered by the query.
377
     * 
378
     * If the query  is null, return all features in the store sorteds 
379
     * by default order.
380
     * 
381
     * The return value implements {@link List} and {@link UnmodifiableBasicList64} 
382
     * to support large list of features.
383
     * 
384
     * The returned list of Features is paginated, and the page size
385
     * used is "pageSize". 
386
     * 
387
     * If the page size is less than or equal to 0, the default page size of 
388
     * 100 will be used.
278 389
     *
279
     * The returned List of Features is paginated, and the page size
280
     * used is "pageSize".
281
     *
282
     * @param query to filter the returned feature list
390
     * @param query to filter and sort the returned feature list
283 391
     * @param pageSize the page size of the list
284
     * @return the list of features
392
     * @return the {@link List}/{@link UnmodifiableBasicList64} of features
285 393
     */
286 394
    public List<Feature> getFeatures(FeatureQuery query, int pageSize);
287 395

  
396
    /**
397
     * Return a paginated list of Features.
398
     * 
399
     * It is a utility method that calls {@link #getFeatures(FeatureQuery, int)}
400
     * using the default page size.
401
     * 
402
     * @param query to filter and sort the returned feature list
403
     * @return the {@link List}/{@link UnmodifiableBasicList64} of features
404
     * @see {@link #getFeatures(FeatureQuery, int)}
405
     */
288 406
    public List<Feature> getFeatures(FeatureQuery query);
289 407

  
408
    /**
409
     * Return a paginated list with al Features in the store.
410
     * 
411
     * It is a utility method that calls {@link #getFeatures(FeatureQuery, int)}
412
     * using the default page size.
413
     * 
414
     * @return the {@link List}/{@link UnmodifiableBasicList64} of features
415
     * @see {@link #getFeatures(FeatureQuery, int)}
416
     */
290 417
    public List<Feature> getFeatures();
291 418

  
419
    /**
420
     * Return a paginated list of Features
421
     * 
422
     * It is a utility method that calls {@link #getFeatures(FeatureQuery, int)}
423
     * 
424
     * @param filter used to filter the features in the store.
425
     * @return the List of Features
426
     * @see {@link #getFeatures(FeatureQuery, int)}, {@link #createFeatureQuery(String,String,boolean)}
427
     */
292 428
    public List<Feature> getFeatures(String filter);
293 429

  
430
    /**
431
     * Return a paginated list of Features.
432
     * 
433
     * It is a utility method that calls {@link #getFeatures(FeatureQuery, int)}
434
     * using the default page size.
435
     * 
436
     * @param filter used to filter the features in the store.
437
     * @param sortBy Attribute names separated by commas used to sort the list to return.
438
     * @return the {@link List}/{@link UnmodifiableBasicList64} of features
439
     * @see {@link #getFeatures(FeatureQuery, int)}, {@link #createFeatureQuery(String,String,boolean)}
440
     */
294 441
    public List<Feature> getFeatures(String filter, String sortBy);
295 442

  
443
    /**
444
     * Return a paginated list of Features.
445
     *  
446
     * It is a utility method that calls {@link #getFeatures(FeatureQuery, int)}
447
     * using the default page size.
448
     * 
449
     * @param filter an {@link String} expression used to filter the features in the store.
450
     * @param sortBy Attribute names separated by commas used to sort the list to return.
451
     * @param asc use order ascending, true, or descending, false.
452
     * @return the {@link List}/{@link UnmodifiableBasicList64} of features
453
     * @see {@link #getFeatures(FeatureQuery, int)}, {@link #createFeatureQuery(String,String,boolean)}
454
     */
296 455
    public List<Feature> getFeatures(String filter, String sortBy, boolean asc);
297 456

  
457
    /**
458
     * Return a paginated list of Features
459
     * 
460
     * It is a utility method that calls {@link #getFeatures(FeatureQuery, int)}
461
     * using the default page size.
462
     * 
463
     * @param filter an {@link Expression} used to filter the features in the store.
464
     * @return the List of Features
465
     * @see {@link #getFeatures(FeatureQuery, int)}, {@link #createFeatureQuery(Expression,String,boolean)}
466
     */
298 467
    public List<Feature> getFeatures(Expression filter);
299 468

  
469
    /**
470
     * Return a paginated list of Features
471
     * 
472
     * It is a utility method that calls {@link #getFeatures(FeatureQuery, int)}
473
     * using the default page size.
474
     * 
475
     * @param filter an {@link Expression} used to filter the features in the store.
476
     * @param sortBy Attribute names separated by commas used to sort the list to return.
477
     * @return the {@link List}/{@link UnmodifiableBasicList64} of features
478
     * @see {@link #getFeatures(FeatureQuery, int)}, {@link #createFeatureQuery(Expression,String,boolean)}
479
     */
300 480
    public List<Feature> getFeatures(Expression filter, String sortBy);
301 481

  
482
    /**
483
     * Return a paginated list of Features
484
     * 
485
     * It is a utility method that calls {@link #getFeatures(FeatureQuery, int)}
486
     * using the default page size.
487
     * 
488
     * @param filter an {@link Expression} used to filter the features in the store.
489
     * @param sortBy Attribute names separated by commas used to sort the list to return.
490
     * @param asc use order ascending, true, or descending, false.
491
     * @return the {@link List}/{@link UnmodifiableBasicList64} of features
492
     * @see {@link #getFeatures(FeatureQuery, int)}, {@link #createFeatureQuery(Expression,String,boolean)}
493
     */
302 494
    public List<Feature> getFeatures(Expression filter, String sortBy, boolean asc);
303 495

  
496
    /**
497
     * Return the first {@link Feature} of the store.
498
     * 
499
     * @return the first {@link Feature} or null if the store is empty.
500
     * @throws DataException 
501
     */
304 502
    public Feature first() throws DataException;
305 503

  
504
    /**
505
     * Returns the first {@link Feature} that meets the criteria indicated.
506
     * 
507
     * It is a utility method that calls {@link #findFirst(FeatureQuery)}.
508
     * 
509
     * @param filter {@link String} expression used to filter the features.
510
     * @return the first {@link Feature} or null if the filter don't return any feature.
511
     * @throws DataException 
512
     * @see {@link #findFirst(FeatureQuery)}, {@link #createFeatureQuery(String,String,boolean)}
513
     */
306 514
    public Feature findFirst(String filter) throws DataException;
307 515

  
516
    /**
517
     * Returns the first {@link Feature} that meets the criteria indicated.
518
     * 
519
     * It is a utility method that calls {@link #findFirst(FeatureQuery)}.
520
     * 
521
     * @param filter {@link String} expression used to filter the features.
522
     * @param sortBy Attribute names separated by commas used to sort the list to return.
523
     * @return the first {@link Feature} or null if the filter don't return any feature.
524
     * @throws DataException 
525
     * @see {@link #findFirst(FeatureQuery)}, {@link #createFeatureQuery(String,String,boolean)}
526
     */
308 527
    public Feature findFirst(String filter, String sortBy) throws DataException;
309 528

  
529
    /**
530
     * Returns the first {@link Feature} that meets the criteria indicated.
531
     * 
532
     * It is a utility method that calls {@link #findFirst(FeatureQuery)}.
533
     * 
534
     * @param filter {@link String} expression used to filter the features.
535
     * @param sortBy Attribute names separated by commas used to sort the list to return.
536
     * @param asc use order ascending, true, or descending, false.
537
     * @return the first {@link Feature} or null if the filter don't return any feature.
538
     * @throws DataException 
539
     * @see {@link #findFirst(FeatureQuery)}, {@link #createFeatureQuery(String,String,boolean)}
540
     */
310 541
    public Feature findFirst(String filter, String sortBy, boolean asc) throws DataException;
311 542

  
543
    /**
544
     * Returns the first {@link Feature} that meets the criteria indicated.
545
     * 
546
     * It is a utility method that calls {@link #findFirst(FeatureQuery)}.
547
     * 
548
     * @param filter {@link String} expression used to filter the features.
549
     * @return the first {@link Feature} or null if the filter don't return any feature.
550
     * @throws DataException 
551
     * @see {@link #findFirst(FeatureQuery)}, {@link #createFeatureQuery(Expession,String,boolean)}
552
     */
312 553
    public Feature findFirst(Expression filter) throws DataException;
313 554

  
555
    /**
556
     * Returns the first {@link Feature} that meets the criteria indicated.
557
     * 
558
     * It is a utility method that calls {@link #findFirst(FeatureQuery)}.
559
     * 
560
     * @param filter {@link String} expression used to filter the features.
561
     * @param sortBy Attribute names separated by commas used to sort the list to return.
562
     * @return the first {@link Feature} or null if the filter don't return any feature.
563
     * @throws DataException 
564
     * @see {@link #findFirst(FeatureQuery)}, {@link #createFeatureQuery(Expession,String,boolean)}
565
     */
314 566
    public Feature findFirst(Expression filter, String sortBy) throws DataException;
315 567

  
568
    /**
569
     * Returns the first {@link Feature} that meets the criteria indicated.
570
     * 
571
     * It is a utility method that calls {@link #findFirst(FeatureQuery)}.
572
     * 
573
     * @param filter {@link String} expression used to filter the features.
574
     * @param sortBy Attribute names separated by commas used to sort the list to return.
575
     * @param asc use order ascending, true, or descending, false.
576
     * @return the first {@link Feature} or null if the filter don't return any feature.
577
     * @throws DataException 
578
     * @see {@link #findFirst(FeatureQuery)}, {@link #createFeatureQuery(Expession,String,boolean)}
579
     */
316 580
    public Feature findFirst(Expression filter, String sortBy, boolean asc) throws DataException;
317 581

  
582
    /**
583
     * Returns the first {@link Feature} that meets the criteria indicated.
584
     * 
585
     * It is a utility method that calls {@link #findFirst(FeatureQuery)}.
586
     * 
587
     * @param query to filter and sort the returned feature list
588
     * @return the first {@link Feature} or null if the filter don't return any feature.
589
     * @throws DataException 
590
     * @see {@link #findFirst(FeatureQuery)}, {@link #createFeatureQuery(Expession,String,boolean)}
591
     */
318 592
    public Feature findFirst(FeatureQuery query) throws DataException;
593

  
319 594
    /**
320 595
     * Returns the feature given its reference.
321 596
     *
322
     * @param reference
323
     *            a unique FeatureReference
324
     * @return
325
     *         The Feature
326
     *
597
     * @param reference a unique FeatureReference
598
     * @return 
599
     * @returnThe Feature
327 600
     * @throws DataException
328 601
     *
329 602
     */
330
    public Feature getFeatureByReference(FeatureReference reference)
331
        throws DataException;
603
    public Feature getFeatureByReference(FeatureReference reference) throws DataException;
332 604

  
333 605
    /**
334 606
     * Returns the feature given its reference and feature type.

Also available in: Unified diff