Revision 25994

View differences:

branches/v2_0_0_prep/libraries/libFMap_dal/src/org/gvsig/fmap/dal/feature/impl/featureset/FastFilteredIterator.java
11 11
	FastFilteredIterator(DefaultFeatureSet featureSet, long index)
12 12
			throws DataException {
13 13
		super(featureSet, index);
14
		myFeature = new DefaultFeature(fset.store);
14
		initializeFeature();
15 15

  
16 16
		this.iterator = featureSet.provider.fastIterator();
17 17
		if (index > 0) {
......
31 31
					myFeature, fset.getDefaultFeatureType());
32 32
		}
33 33
	}
34

  
35
	protected void initializeFeature() {
36
		myFeature = new DefaultFeature(fset.store);
37
	}
38

  
39
	public void remove() {
40
		super.remove();
41
		this.initializeFeature();
42
	}
43

  
44

  
34 45
}
branches/v2_0_0_prep/libraries/libFMap_dal/src/org/gvsig/fmap/dal/feature/impl/featureset/EditedIterator.java
3 3
import java.util.Iterator;
4 4

  
5 5
import org.gvsig.fmap.dal.exception.DataException;
6
import org.gvsig.fmap.dal.feature.Feature;
7 6
import org.gvsig.fmap.dal.feature.FeatureReference;
8 7
import org.gvsig.fmap.dal.feature.impl.DefaultFeature;
9 8
import org.gvsig.fmap.dal.feature.impl.DefaultFeatureReference;
......
13 12

  
14 13
	Iterator newsFeatures;
15 14
	boolean featureIsNew;
16
	protected Feature lastFeature = null;
17 15

  
16

  
18 17
	public EditedIterator(DefaultFeatureSet featureSet) {
19 18
		super(featureSet);
20 19
	}
......
94 93
		return fset.store.getFeatureManager().isDeleted(ref);
95 94
	}
96 95

  
97
	public void remove() {
98
		if (lastFeature == null) {
99
			throw new IllegalStateException();
100
		}
101
		try {
102
			this.fset.store.delete(this.lastFeature);
103
		} catch (DataException e) {
104
			// FIXME Cambiar excepcion a una Runtime de DAL
105
			throw new RuntimeException(e);
106
		}
107
		lastFeature = null;
108
	}
109

  
110
	public Object next() {
111
		lastFeature = null;
112
		lastFeature = (Feature) super.next();
113
		return lastFeature;
114
	}
115

  
116 96
}
branches/v2_0_0_prep/libraries/libFMap_dal/src/org/gvsig/fmap/dal/feature/impl/featureset/FilteredIterator.java
108 108
		if (this.current == null) {
109 109
			throw new NoSuchElementException();
110 110
		}
111
		this.lastFeature = null;
111 112
		nextChecked = false;
112 113
		DefaultFeature feature = this.current;
113 114
		this.current = null;
115
		this.lastFeature = feature;
114 116
		return feature;
115 117
	}
116 118

  
branches/v2_0_0_prep/libraries/libFMap_dal/src/org/gvsig/fmap/dal/feature/impl/featureset/DefaultFeatureSet.java
89 89
	}
90 90

  
91 91
	public long getSize() throws DataException {
92
		this.checkModified();
92 93
		if (size < 0) {
93 94
			size = calculateSize();
94 95
		}
......
337 338
	public void delete(Feature feature) throws DataException {
338 339
		this.featureToIgnoreNotification = feature;
339 340
		this.store.delete(feature);
341
		if (this.size > 0) {
342
			this.size--;
343
		}
340 344
		this.featureToIgnoreNotification = null;
341 345
	}
342 346

  
343 347
	public void insert(EditableFeature feature) throws DataException {
344 348
		this.featureToIgnoreNotification = feature;
345 349
		this.store.insert(feature);
350
		if (this.size >= 0) {
351
			this.size++;
352
		}
346 353
		this.featureToIgnoreNotification = null;
347 354
	}
348 355

  
branches/v2_0_0_prep/libraries/libFMap_dal/src/org/gvsig/fmap/dal/feature/impl/featureset/FastDefaultIterator.java
11 11
	public FastDefaultIterator(DefaultFeatureSet featureSet, long index)
12 12
			throws DataException {
13 13
		super(featureSet);
14
		myFeature = new DefaultFeature(fset.store);
14
		this.initializeFeature();
15 15
		if (index > 0) {
16 16
			if (featureSet.provider.canIterateFromIndex()) {
17 17
				try {
......
43 43
							.getDefaultFeatureType());
44 44
		}
45 45
	}
46

  
47
	protected void initializeFeature() {
48
		myFeature = new DefaultFeature(fset.store);
49
	}
50

  
51
	public void remove() {
52
		super.remove();
53
		this.initializeFeature();
54
	}
55

  
56

  
46 57
}
branches/v2_0_0_prep/libraries/libFMap_dal/src/org/gvsig/fmap/dal/feature/impl/featureset/DefaultIterator.java
3 3
import java.util.Iterator;
4 4

  
5 5
import org.gvsig.fmap.dal.exception.DataException;
6
import org.gvsig.fmap.dal.feature.Feature;
6 7
import org.gvsig.fmap.dal.feature.impl.DefaultFeature;
7 8
import org.gvsig.fmap.dal.feature.spi.FeatureData;
8 9

  
......
11 12

  
12 13
	protected Iterator iterator;
13 14
	protected DefaultFeatureSet fset;
15
	protected Feature lastFeature = null;
14 16

  
15 17
	public DefaultIterator(DefaultFeatureSet featureSet) {
16 18
		this.fset = featureSet;
......
52 54

  
53 55
	public Object next() {
54 56
		fset.checkModified();
57
		lastFeature = null;
55 58
		try {
56
			return this.createFeature((FeatureData) this.getIterator().next());
59
			lastFeature = this.createFeature((FeatureData) this.getIterator()
60
					.next());
61
			return lastFeature;
57 62
		} catch (DataException e) {
58 63
			RuntimeException ex = new RuntimeException();
59 64
			e.initCause(e);
......
62 67
	}
63 68

  
64 69
	public void remove() {
65
		throw new UnsupportedOperationException();
70
		if (!fset.store.isEditing()) {
71
			throw new UnsupportedOperationException();
72
		}
73
		if (lastFeature == null) {
74
			throw new IllegalStateException();
75
		}
76
		try {
77
			this.fset.delete(this.lastFeature);
78
		} catch (DataException e) {
79
			// FIXME Cambiar excepcion a una Runtime de DAL
80
			throw new RuntimeException(e);
81
		}
82
		lastFeature = null;
66 83
	}
67 84

  
68 85
	protected DefaultFeature createFeature(FeatureData fData)
branches/v2_0_0_prep/libraries/libFMap_dal/src/org/gvsig/fmap/dal/feature/impl/featureset/OrderedIterator.java
5 5
import java.util.Iterator;
6 6
import java.util.List;
7 7

  
8
import org.gvsig.fmap.dal.exception.DataException;
9 8
import org.gvsig.fmap.dal.feature.Feature;
10 9
import org.gvsig.fmap.dal.feature.impl.DefaultFeature;
11 10

  
......
39 38
		}
40 39
	}
41 40

  
42
	public Object next() {
43
		lastFeature = null;
44
		lastFeature = (Feature) super.next();
45
		return lastFeature;
46
	}
47

  
48 41
	public void remove() {
49
		if (!fset.store.isEditing()) {
50
			throw new UnsupportedOperationException();
51
		}
52
		if (this.lastFeature == null) {
53
			throw new IllegalStateException();
54
		}
55
		try {
56
			fset.store.delete(this.lastFeature);
57
		} catch (DataException e) {
58
			// FIXME Cambiar excepcion a una Runtime de DAL
59
			throw new RuntimeException(e);
60
		}
42
		super.remove();
61 43
		this.iterator.remove();
62 44
	}
63 45

  

Also available in: Unified diff