Revision 43089 trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.impl/src/main/java/org/gvsig/fmap/dal/feature/impl/featureset/DefaultFeatureSet.java

View differences:

DefaultFeatureSet.java
48 48
import org.gvsig.fmap.dal.feature.impl.DefaultFeatureStoreTransforms;
49 49
import org.gvsig.fmap.dal.feature.spi.FeatureSetProvider;
50 50
import org.gvsig.tools.dispose.DisposableIterator;
51
import org.gvsig.tools.dispose.DisposeUtils;
52 51
import org.gvsig.tools.dynobject.DynObjectSet;
53 52
import org.gvsig.tools.evaluator.Evaluator;
54 53
import org.gvsig.tools.exception.BaseException;
......
56 55
import org.gvsig.tools.observer.Observer;
57 56
import org.gvsig.tools.visitor.VisitCanceledException;
58 57
import org.gvsig.tools.visitor.Visitor;
59
import org.gvsig.tools.visitor.impl.AbstractIndexedVisitable;
60 58

  
61
public class DefaultFeatureSet extends AbstractIndexedVisitable implements
59
public class DefaultFeatureSet extends AbstractFeatureSet implements
62 60
    FeatureSet, Observer {
63 61

  
64 62
    private static final int NO_CHECKED = -1;
......
283 281
        this.defatulFeatureTypeForProvider = null;
284 282
    }
285 283

  
286
    public boolean isFromStore(DataStore store) {
287
        return this.store.equals(store);
288
    }
289

  
290 284
    public void update(Observable obsevable, Object notification) {
291 285
        if (sourceStoreModified) {
292 286
            return;
......
324 318
        }
325 319
    }
326 320

  
327
    protected void doAccept(Visitor visitor, long firstValueIndex)
328
        throws VisitCanceledException, BaseException {
329
        DisposableIterator iterator = fastIterator(firstValueIndex);
330

  
331
        try {
332
            while (iterator.hasNext()) {
333
                Feature feature = (Feature) iterator.next();
334
                visitor.visit(feature);
335
            }
336
        } finally {
337
            iterator.dispose();
338
        }
339
    }
340

  
341 321
    protected void checkSourceStoreModified() {
342 322
        if (sourceStoreModified) {
343 323
			throw new ConcurrentDataModificationException(store == null ? ""
......
345 325
        }
346 326
    }
347 327

  
348
    public boolean isEmpty() throws DataException {
349
        checkSourceStoreModified();
350
        return this.getSize() == 0;
351
    }
352

  
353
    @Override
354
    public Feature first() {
355
        DisposableIterator it = null;
356
        try {
357
            it = this.iterator();
358
            if( it == null ) {
359
                return null;
360
            }
361
            Feature f = (Feature) it.next();
362
            return f;
363
        } finally {
364
            DisposeUtils.disposeQuietly(it);
365
        }
366
    }
367

  
368

  
369
    public DisposableIterator fastIterator() throws DataException {
370
        return this.fastIterator(0);
371
    }
372

  
373 328
    public DisposableIterator fastIterator(long index) throws DataException {
374 329
        if (index < 0) {
375 330
            throw new IndexOutOfBoundsException("The index (" + index
......
426 381
        }
427 382
    }
428 383

  
429
    public DisposableIterator iterator() {
430
        try {
431
            return this.fastIterator(0);
432
        } catch (DataException ex) {
433
            throw new RuntimeException("Can't obtain itertor.",ex);
434
        }
435
    }
436 384

  
437 385
    public DisposableIterator iterator(long index) throws DataException {
438 386
        if (index < 0) {
......
564 512
        this.ownFeaturesModified = true;
565 513
    }
566 514

  
567
    public DynObjectSet getDynObjectSet() {
568
        return this.getDynObjectSet(true);
569
    }
570

  
571
    public DynObjectSet getDynObjectSet(boolean fast) {
572
        return new DynObjectSetFeatureSetFacade(this, store, fast);
573
    }
574

  
575 515
    public FeatureStore getFeatureStore() {
576 516
        return store;
577 517
    }

Also available in: Unified diff