Revision 20599

View differences:

trunk/libraries/libDataSource/src/org/gvsig/data/vectorial/AbstractFeatureStore.java
441 441

  
442 442

  
443 443
	    }
444
	 public IFeature createFeature(IFeatureType type) throws IsNotFeatureSettingException {
445
		 IFeature feature=new CreatedFeature(type,true);
446
		 return feature;
444
	 public IFeature createFeature(IFeatureType type) throws InitializeException {
445
		return this.createDefaultFeature(true);
447 446
	 }
448 447

  
449
	 public IFeature createDefaultFeature(boolean defaultValues){
450
		 IFeature feature=new CreatedFeature(getDefaultFeatureType(),defaultValues);
448
	 public IFeature createDefaultFeature(boolean defaultValues) throws InitializeException{
449
		 IFeature feature;
450
		try {
451
			feature = new CreatedFeature(getDefaultFeatureType(),defaultValues);
452
		} catch (ReadException e) {
453
			throw new InitializeException(this.getName(),e);
454
		}
451 455
		 return feature;
452 456
	 }
453 457

  
trunk/libraries/libDataSource/src/org/gvsig/data/vectorial/IFeature.java
8 8
import org.gvsig.data.spatialprovisional.IExtent;
9 9

  
10 10

  
11
public interface IFeature extends List  {
11
public interface IFeature {
12 12

  
13
	public int size();
14

  
13 15
	public IFeatureID getID();
14 16
	public IFeatureType getType();
15 17

  
......
51 53
	public void set(String name, double value)throws IsNotFeatureSettingException;
52 54
	public void set(String name, byte value)throws IsNotFeatureSettingException;
53 55

  
54
	public void setObject(int index, Object value)throws IsNotFeatureSettingException;
56
	public void set(int index, Object value)throws IsNotFeatureSettingException;
55 57
	public void set(int index, int value)throws IsNotFeatureSettingException;
56 58
	public void set(int index, boolean value)throws IsNotFeatureSettingException;
57 59
	public void set(int index, long value)throws IsNotFeatureSettingException;
trunk/libraries/libDataSource/src/org/gvsig/data/vectorial/MemoryFeature.java
1 1
package org.gvsig.data.vectorial;
2 2

  
3
import java.text.ParseException;
4
import java.util.Date;
5 3
import java.util.Iterator;
6 4
import java.util.List;
7 5

  
8 6
import org.gvsig.data.exception.DataException;
7
import org.gvsig.data.exception.InitializeException;
8
import org.gvsig.data.exception.ReadException;
9 9
import org.gvsig.data.spatialprovisional.IExtent;
10 10

  
11 11
public class MemoryFeature extends Feature implements IFeature {
......
15 15
	 */
16 16
	private static final long serialVersionUID = 5866395773511247527L;
17 17

  
18
	public MemoryFeature(IFeature feature) {
19
		super(feature.getType());
18
	public MemoryFeature(IFeature feature) throws ReadException {
19
		super(feature.getType(),false);
20 20

  
21 21
		Iterator iter=this.featureType.iterator();
22 22

  
......
28 28
			featureAttribute=(IFeatureAttributeDescriptor)iter.next();
29 29
			column=((DefaultAttributeDescriptor)featureAttribute).originalPosition();
30 30
			value=feature.get(column);
31
			try {
31 32
			if (featureAttribute.equals(IFeatureAttributeDescriptor.TYPE_GEOMETRY)){
32 33
				//TODO: Falta clonar geometria
33
				try {
34
					this.setGeometry(column, value);
35
				} catch (IsNotFeatureSettingException e) {
36
					// TODO Auto-generated catch block
37
					e.printStackTrace();
38
				}
34
				this.setGeometry(column, value);
39 35

  
40 36
			}else if (featureAttribute.equals(IFeatureAttributeDescriptor.TYPE_OBJECT)){
41 37
				//TODO falta clonar el objeto
......
44 40
			}else {
45 41
				this.set(column, value);
46 42
			}
43
			} catch (IsNotFeatureSettingException e){
44
				throw new InitializeException("Feature",e);
45
			}
46

  
47 47
		}
48 48
		this.stopLoading();
49 49

  
50 50

  
51 51
	}
52 52

  
53
	public MemoryFeature(IFeatureType type,boolean defaultValues) {
54
		super(type);
55
		if (defaultValues){
56
			Iterator iterator=type.iterator();
57
			this.loading();
58
			while(iterator.hasNext()){
59
				IFeatureAttributeDescriptor featureAttribute=(IFeatureAttributeDescriptor)iterator.next();
60
				int i=((DefaultAttributeDescriptor)featureAttribute).originalPosition();
61
				String attributeType=featureAttribute.getDataType();
62

  
63
				Object defaultValue=featureAttribute.getDefaultValue();
64
				if (attributeType.equals(IFeatureAttributeDescriptor.TYPE_BYTE)){
65
					try {
66
						set(i,Byte.parseByte((String)defaultValue));
67
					} catch (IsNotFeatureSettingException e) {
68
						e.printStackTrace();
69
					}
70
				}else if (attributeType.equals(IFeatureAttributeDescriptor.TYPE_DATE)){
71
					try {
72
						set(i,type.getDateFormat().parse((String)defaultValue));
73
					} catch (ParseException e) {
74
						// TODO Auto-generated catch block
75
						e.printStackTrace();
76
					}
77
				}else if (attributeType.equals(IFeatureAttributeDescriptor.TYPE_DOUBLE)){
78
					set(i,defaultValue);
79
				}else if (attributeType.equals(IFeatureAttributeDescriptor.TYPE_FLOAT)){
80
					set(i,defaultValue);
81
				}else if (attributeType.equals(IFeatureAttributeDescriptor.TYPE_GEOMETRY)){
82
					set(i,defaultValue);
83
				}else if (attributeType.equals(IFeatureAttributeDescriptor.TYPE_INT)){
84
					set(i,defaultValue);
85
				}else if (attributeType.equals(IFeatureAttributeDescriptor.TYPE_LONG)){
86
					set(i,defaultValue);
87
				}else if (attributeType.equals(IFeatureAttributeDescriptor.TYPE_OBJECT)){
88
					set(i,defaultValue);
89
				}else if (attributeType.equals(IFeatureAttributeDescriptor.TYPE_STRING)){
90
					set(i,defaultValue);
91
				}
92
			}
93
			this.stopLoading();
94
		}
53
	public MemoryFeature(IFeatureType type,boolean defaultValues) throws ReadException {
54
		super(type,defaultValues);
95 55
	}
96 56

  
97 57
	public IFeatureID getID() {
trunk/libraries/libDataSource/src/org/gvsig/data/vectorial/Feature.java
1 1
package org.gvsig.data.vectorial;
2 2

  
3
import java.util.ArrayList;
3
import java.text.ParseException;
4 4
import java.util.Date;
5 5
import java.util.Iterator;
6 6

  
7 7
import org.gvsig.data.exception.DataException;
8
import org.gvsig.data.exception.InitializeException;
9
import org.gvsig.data.exception.ReadException;
8 10

  
9
public abstract class Feature extends ArrayList implements IFeature{
11
public abstract class Feature implements IFeature{
10 12
	protected IFeatureType featureType;
11 13
	protected Object defaultGeometry;
12 14
	protected Object object;
13 15
	private boolean editing = false;
14 16
	private boolean loading = false;
15 17
	private IFeature newFeature;
18
	protected Object[] values;
16 19

  
17 20
	protected abstract IFeature cloneFeature() throws DataException;
18 21

  
19
	public Feature(IFeatureType featureType){
20
		super(featureType.getCount());
22
	public Feature(IFeatureType featureType) throws ReadException{
23
		this.init(featureType, false);
24
	}
25

  
26
	public Feature(IFeatureType featureType,boolean loadDefaultValues) throws ReadException{
27
		this.init(featureType, loadDefaultValues);
28
	}
29

  
30
	protected void init(IFeatureType featureType,boolean loadDefaultValues)throws InitializeException{
31
		this.values = new Object[featureType.getCount()];
21 32
		this.featureType=featureType;
22
		for (int i = 0; i < featureType.getCount()+1; i++) {
23
			add(null);
33
		if (loadDefaultValues){
34
			try {
35
				this.loadDefaultValues();
36
			} catch (Exception e) {
37
				throw new InitializeException("Feature",e);
38
			}
24 39
		}
40

  
25 41
	}
42

  
43
	public int size() {
44
		return this.getType().size();
45
	}
46

  
26 47
	public IFeatureType getType() {
27 48
		return featureType;
28 49
	}
......
85 106
		return value;
86 107
	}
87 108
	public Object get(int index) {
88
		if (this.isEditing())
109
		if (this.isEditing() && this.newFeature != null)
89 110
			this.newFeature.get(index);
90
		return super.get(index);
111
		return this.values[index];
91 112
	}
92 113

  
93 114
	public IFeature getFeature(int index) {
......
146 167

  
147 168
	public void set(String name, Object value) throws IsNotFeatureSettingException {
148 169
		int i=featureType.getFieldIndex(name);
149
		this.setObject(i, value);
170
		this.set(i, value);
150 171
	}
151 172

  
152 173
	public void set(String name, int value) throws IsNotFeatureSettingException {
153 174
		int i=featureType.getFieldIndex(name);
154
		this.setObject(i, new Integer(value));
175
		this.set(i, new Integer(value));
155 176
	}
156 177

  
157 178
	public void set(String name, boolean value) throws IsNotFeatureSettingException {
158 179
		int i=featureType.getFieldIndex(name);
159
		this.setObject(i,new Boolean(value));
180
		this.set(i,new Boolean(value));
160 181
	}
161 182

  
162 183
	public void set(String name, long value) throws IsNotFeatureSettingException {
163 184
		int i=featureType.getFieldIndex(name);
164
		this.setObject(i,new Long(value));
185
		this.set(i,new Long(value));
165 186
	}
166 187

  
167 188
	public void set(String name, float value) throws IsNotFeatureSettingException {
168 189
		int i=featureType.getFieldIndex(name);
169
		this.setObject(i,new Float(value));
190
		this.set(i,new Float(value));
170 191
	}
171 192

  
172 193
	public void set(String name, double value) throws IsNotFeatureSettingException {
173 194
		int i=featureType.getFieldIndex(name);
174
		this.setObject(i,new Double(value));
195
		this.set(i,new Double(value));
175 196
	}
176 197

  
177
	public void setObject(int index, Object value) throws IsNotFeatureSettingException {
198
	public void set(int index, Object value) throws IsNotFeatureSettingException {
178 199
		canSetValue(index);
179
		if (newFeature!=null){
200
		if ( this.isEditing() && newFeature!=null){
180 201
			((Feature)newFeature).loading();
181
			newFeature.setObject(index,value);
202
			newFeature.set(index,value);
182 203
			((Feature)newFeature).stopLoading();
183 204
		}else
184
			super.set(index,value);
205
			this.values[index] =value;
185 206

  
186 207
	}
187 208

  
188 209
	public void set(int index, int value) throws IsNotFeatureSettingException {
189
		this.setObject(index,new Integer(value));
210
		this.set(index,new Integer(value));
190 211
	}
191 212

  
192 213
	public void set(int index, boolean value) throws IsNotFeatureSettingException {
193
		this.setObject(index,new Boolean(value));
214
		this.set(index,new Boolean(value));
194 215
	}
195 216

  
196 217
	public void set(int index, long value) throws IsNotFeatureSettingException {
197
		this.setObject(index,new Long(value));
218
		this.set(index,new Long(value));
198 219
	}
199 220

  
200 221
	public void set(int index, float value) throws IsNotFeatureSettingException {
201
		this.setObject(index,new Float(value));
222
		this.set(index,new Float(value));
202 223
	}
203 224

  
204 225
	public void set(int index, double value) throws IsNotFeatureSettingException {
205
		this.setObject(index,new Double(value));
226
		this.set(index,new Double(value));
206 227
	}
207 228

  
208
	public Object set(int index, Object value) {
209
		//FIXME!! Esto tendr?a que tener igual que los otros 'set'
210

  
211
		try {
212
			this.setObject(index,value);
213
		} catch (IsNotFeatureSettingException e) {
214
			new RuntimeException(e);
215
		}
216
		return null;
217
	}
218

  
219 229
	public void validateEnd(IFeatureStore featureStore) {
220 230
		getType().validateFeatureEnd(this,featureStore);
221 231

  
......
230 240
	}
231 241
	public IFeature getFeature(String name) {
232 242
		int i=featureType.getFieldIndex(name);
233
		return (IFeature)super.get(i);
243
		return (IFeature)this.values[i];
234 244
	}
235 245
	public Object getGeometry(int index) {
236 246
		return this.get(index);
......
253 263
		return value.byteValue();
254 264
	}
255 265
	public void set(int index, byte value) throws IsNotFeatureSettingException {
256
		this.setObject(index,new Byte(value));
266
		this.set(index,new Byte(value));
257 267
	}
258 268
	public void set(int index, String value) throws IsNotFeatureSettingException {
259
		this.setObject(index,value);
269
		this.set(index,(Object)value);
260 270
	}
261 271
	public void set(String name, byte value) throws IsNotFeatureSettingException {
262 272
		int i=featureType.getFieldIndex(name);
263
		this.setObject(i,new Byte(value));
273
		this.set(i,new Byte(value));
264 274
	}
265 275
	public void setGeometry(String name,Object geometry) throws IsNotFeatureSettingException {
266 276
		int i=featureType.getFieldIndex(name);
......
270 280
			newFeature.setGeometry(name,geometry);
271 281
			((Feature)newFeature).stopLoading();
272 282
		}else{
273
			super.set(i,geometry);
283
			this.values[i]=geometry;
274 284
			if (featureType.getDefaultGeometry().equals(name)){
275 285
				defaultGeometry=geometry;
276 286
			}
......
283 293
			newFeature.setGeometry(index,geometry);
284 294
			((Feature)newFeature).stopLoading();
285 295
		}else{
286
			super.set(index,geometry);
296
			this.values[index] =geometry;
287 297
			Iterator iterator=featureType.iterator();
288 298
			while (iterator.hasNext()) {
289 299
				IFeatureAttributeDescriptor fad = (IFeatureAttributeDescriptor) iterator.next();
......
316 326
	protected boolean isEditing(){
317 327
		return editing;
318 328
	}
319
	IFeature getNewFeature() {
329
	protected IFeature getNewFeature() {
320 330
		return newFeature;
321 331
	}
322 332
	protected void loading(){
......
335 345
			IFeatureAttributeDescriptor desc = (IFeatureAttributeDescriptor)iter.next();
336 346
			if (desc.isEvaluated()){
337 347
				Object value = desc.getEvaluator().evalue(store, this, desc);
338
				super.set(desc.ordinal(),value);
348
				this.values[desc.ordinal()] = value;
339 349
				if (desc.getDataType().equals(IFeatureAttributeDescriptor.TYPE_GEOMETRY)){
340 350
					if (featureType.getDefaultGeometry().equals(desc.getName())){
341
						defaultGeometry=value;
351
						this.defaultGeometry=value;
342 352
					}
343 353
				}
344 354
			}
345 355
		}
346 356
	}
347 357

  
358
	protected void loadDefaultValues() throws IsNotFeatureSettingException, NumberFormatException, ParseException{
359
		IFeatureType type = this.getType();
360
		Iterator iterator=type.iterator();
361

  
362
		this.loading();
363
		while(iterator.hasNext()){
364
			IFeatureAttributeDescriptor featureAttribute=(IFeatureAttributeDescriptor)iterator.next();
365
			int i=((DefaultAttributeDescriptor)featureAttribute).originalPosition();
366
			String attributeType=featureAttribute.getDataType();
367
			Object defaultValue=featureAttribute.getDefaultValue();
368
			if (attributeType.equals(IFeatureAttributeDescriptor.TYPE_BYTE)){
369
				if (defaultValue instanceof String){
370
					set(i,Byte.parseByte((String)defaultValue));
371
				}else{
372
					set(i,(Byte)defaultValue);
373
				}
374
			}else if (attributeType.equals(IFeatureAttributeDescriptor.TYPE_DATE)){
375
				if (defaultValue instanceof String){
376
					set(i,this.getType().getDateFormat().parse((String)defaultValue));
377
				} else{
378

  
379
				}
380
			}else if (attributeType.equals(IFeatureAttributeDescriptor.TYPE_DOUBLE)){
381
				if (defaultValue instanceof String){
382
					set(i,Double.parseDouble((String)defaultValue));
383
				}else{
384
					set(i,(Double)defaultValue);
385
				}
386
			}else if (attributeType.equals(IFeatureAttributeDescriptor.TYPE_FLOAT)){
387
				if (defaultValue instanceof String){
388
					set(i,Float.parseFloat((String)defaultValue));
389
				}else{
390
					set(i,(Float)defaultValue);
391
				}
392
			}else if (attributeType.equals(IFeatureAttributeDescriptor.TYPE_GEOMETRY)){
393
				setGeometry(i,defaultValue);
394
			}else if (attributeType.equals(IFeatureAttributeDescriptor.TYPE_INT)){
395
				if (defaultValue instanceof String){
396
					set(i,Integer.parseInt((String)defaultValue));
397
				}else{
398
					set(i,(Integer)defaultValue);
399
				}
400
			}else if (attributeType.equals(IFeatureAttributeDescriptor.TYPE_LONG)){
401
				if (defaultValue instanceof String){
402
					set(i,Long.parseLong((String)defaultValue));
403
				}else{
404
					set(i,(Long)defaultValue);
405
				}
406
			}else if (attributeType.equals(IFeatureAttributeDescriptor.TYPE_OBJECT)){
407
				set(i,defaultValue);
408
			}else if (attributeType.equals(IFeatureAttributeDescriptor.TYPE_STRING)){
409
				set(i,(String)defaultValue);
410
			}
411
		}
412
		this.stopLoading();
413

  
414
	}
415

  
348 416
}
trunk/libraries/libDataSource/src/org/gvsig/data/vectorial/MemoryFeatureID.java
8 8
		this.feature=feature;
9 9
	}
10 10
	public IFeature getFeature(IFeatureType featureType) {
11
		Feature auxFeature=new MemoryFeature(featureType,false);
12
		Iterator iterator=featureType.iterator();
13
		try{
14
			auxFeature.loading();
15
			while (iterator.hasNext()) {
16
				IFeatureAttributeDescriptor fad = (IFeatureAttributeDescriptor) iterator.next();
17
//				IFeatureAttributeDescriptor descriptor= (IFeatureAttributeDescriptor)featureType.get(i);
18
				String name=fad.getName();
19
				String dataType=fad.getDataType();
20
				if (IFeatureAttributeDescriptor.TYPE_BOOLEAN==dataType){
21
					auxFeature.set(name,feature.getBoolean(name));
22
				}else if (IFeatureAttributeDescriptor.TYPE_DATE==dataType){
23
					auxFeature.set(name,feature.getDate(name));
24
				}else if (IFeatureAttributeDescriptor.TYPE_DOUBLE==dataType){
25
					auxFeature.set(name,feature.getDouble(name));
26
				}else if (IFeatureAttributeDescriptor.TYPE_FEATURE==dataType){
27
					auxFeature.set(name,feature.getFeature(name));
28
				}else if (IFeatureAttributeDescriptor.TYPE_FLOAT==dataType){
29
					auxFeature.set(name,feature.getFloat(name));
30
				}else if (IFeatureAttributeDescriptor.TYPE_GEOMETRY==dataType){
31
					auxFeature.set(name,feature.getGeometry(name));
32
				}else if (IFeatureAttributeDescriptor.TYPE_INT==dataType){
33
					auxFeature.set(name,feature.getInt(name));
34
				}else if (IFeatureAttributeDescriptor.TYPE_LONG==dataType){
35
					auxFeature.set(name,feature.getLong(name));
36
				}else if (IFeatureAttributeDescriptor.TYPE_STRING==dataType){
37
					auxFeature.set(name,feature.getString(name));
38
				}else if (IFeatureAttributeDescriptor.TYPE_OBJECT==dataType){
39
					auxFeature.set(name,feature.get(name));
40
				}else if (IFeatureAttributeDescriptor.TYPE_BYTE==dataType){
41
					auxFeature.set(name,feature.get(name));
42
				}
43
			}
44
			auxFeature.stopLoading();
45
		}catch (IsNotFeatureSettingException e) {
46
			e.printStackTrace();
47
		}
48
		return auxFeature;
11
		return this.feature;
49 12
	}
50 13
	public boolean equals(Object obj) {
51 14
		if (obj instanceof MemoryFeatureID){
trunk/libraries/libDataSource/src/org/gvsig/data/vectorial/DefaultFeatureType.java
5 5
import java.util.Iterator;
6 6
import java.util.List;
7 7

  
8
import org.gvsig.data.exception.InitializeException;
9

  
8 10
public class DefaultFeatureType extends ArrayList implements IFeatureType{
9 11
	protected List featureRules=new ArrayList();//<IFeatureRule>
10 12
	private String geometryColumn;
......
14 16
	private DateFormat dateFormat=DateFormat.getDateInstance();
15 17
	private String[] fieldsId;
16 18

  
17
	private int count=-1;
19
	private int count=0;
18 20

  
19 21
	public DefaultFeatureType(){
20 22

  
......
68 70
		return geometryColumn;
69 71
	}
70 72

  
71
	public IFeature create(IFeatureStore store) throws IsNotFeatureSettingException {
73
	public IFeature create(IFeatureStore store) throws InitializeException {
72 74
		return store.createFeature(this);
73 75
	}
74 76

  
......
127 129
	}
128 130

  
129 131
	public boolean add(Object arg0) {
132
		((DefaultAttributeDescriptor)arg0).setOrdinal(count);
130 133
		count++;
131
		((DefaultAttributeDescriptor)arg0).setOrdinal(count);
132 134
		return super.add(arg0);
133 135
	}
134 136

  
trunk/libraries/libDataSource/src/org/gvsig/data/vectorial/IFeatureType.java
3 3
import java.text.DateFormat;
4 4
import java.util.List;
5 5

  
6
import org.gvsig.data.exception.InitializeException;
6 7

  
8

  
7 9
public interface IFeatureType extends List {
8 10

  
9 11

  
10 12
		public void setDefaultGeometry(String name);
11 13
		public String getDefaultGeometry();
12 14

  
13
		public IFeature create(IFeatureStore store) throws IsNotFeatureSettingException;
15
		public IFeature create(IFeatureStore store) throws InitializeException;
14 16

  
15 17
		public void addRule(IFeatureRule rule);
16 18
		public void clearRules();
trunk/libraries/libDataSource/src/org/gvsig/data/vectorial/IFeatureStore.java
5 5
import org.gvsig.data.IDataCollection;
6 6
import org.gvsig.data.IDataStore;
7 7
import org.gvsig.data.IDataStoreParameters;
8
import org.gvsig.data.exception.InitializeException;
8 9
import org.gvsig.data.exception.ReadException;
9 10
import org.gvsig.util.observer.IObserver;
10 11

  
......
23 24

  
24 25

  
25 26
	public List getFeatureTypes();
26
	public IFeature createFeature(IFeatureType type) throws IsNotFeatureSettingException;
27
	public IFeature createFeature(IFeatureType type) throws InitializeException;
27 28

  
28
	public IFeature createDefaultFeature(boolean defaultValues);
29
	public IFeature createDefaultFeature(boolean defaultValues) throws InitializeException ;
29 30
	public IFeatureType getDefaultFeatureType();
30 31

  
31 32
	public void update(IFeature feature);
trunk/libraries/libDataSource/src/org/gvsig/data/vectorial/CreatedFeature.java
1 1
package org.gvsig.data.vectorial;
2 2

  
3
import org.gvsig.data.exception.DataException;
4
import org.gvsig.data.exception.InitializeException;
5
import org.gvsig.data.exception.ReadException;
6

  
3 7
/**
4 8
 * Class for Features created in editing mode
5 9
 *
......
7 11
 *
8 12
 */
9 13
public class CreatedFeature extends MemoryFeature {
14
	private boolean isNew=true;
10 15

  
11
	public CreatedFeature(IFeature feature) {
16
	public CreatedFeature(IFeature feature) throws ReadException {
12 17
		super(feature);
13 18
	}
14 19

  
15
	public CreatedFeature(IFeatureType type, boolean b) {
20
	public CreatedFeature(IFeatureType type, boolean b) throws ReadException{
16 21
		super(type,b);
17 22
	}
18 23

  
......
21 26
	 */
22 27
	private static final long serialVersionUID = 2765156962818218014L;
23 28

  
24
	public IFeature getNewFeature() {
25
		if (!this.isEditing())
29

  
30
	protected IFeature cloneFeature() throws DataException {
31
		if (this.isNew){
32
			return null;
33
		}
34
		return new CreatedFeature(this);
35
	}
36

  
37
	protected void stopEditing() {
38
		super.stopEditing();
39
		if (this.isNew){
40
			this.isNew =false;
41
		}
42

  
43
	}
44

  
45
	protected IFeature getNewFeature() {
46
		IFeature feature = super.getNewFeature();
47
		if (feature == null)
26 48
			return this;
27
		return super.getNewFeature();
49
		return feature;
28 50
	}
29 51

  
30 52

  
31 53

  
54

  
32 55
}
trunk/libraries/libDataSource/src/org/gvsig/data/vectorial/FeatureManager.java
46 46
import java.util.HashMap;
47 47
import java.util.Iterator;
48 48

  
49
import org.gvsig.data.exception.InitializeException;
50
import org.gvsig.data.exception.ReadException;
49 51
import org.gvsig.data.vectorial.expansionadapter.IExpansionAdapter;
50 52

  
51 53

  
......
109 111
     * @return DOCUMENT ME!
110 112
     * @throws IsNotFeatureSettingException
111 113
     */
112
    public IFeature getFeature(IFeatureID id,IFeatureStore store) throws IsNotFeatureSettingException {
114
    public IFeature getFeature(IFeatureID id,IFeatureStore store) throws InitializeException {
113 115
        int num = ((Integer) relations.get(id)).intValue();
114 116

  
115 117
        IFeature feature=(IFeature)expansionAdapter.getObject(num);
116 118
       	return getCorrectFeature(feature, store);
117 119
    }
118 120

  
119
    private IFeature getCorrectFeature(IFeature feature,IFeatureStore store) throws IsNotFeatureSettingException {
121
    private IFeature getCorrectFeature(IFeature feature,IFeatureStore store) throws InitializeException {
120 122
    	 Iterator iterator=store.getDefaultFeatureType().iterator();
121 123
         IFeature newFeature=store.createFeature(store.getDefaultFeatureType());
122 124
         ((Feature)newFeature).loading();
123 125
         while (iterator.hasNext()) {
124 126
 			IFeatureAttributeDescriptor fad = (IFeatureAttributeDescriptor) iterator.next();
125 127
 			int i=((DefaultAttributeDescriptor)fad).originalPosition();
126
 			if (i<feature.size()){
127
 				newFeature.set(i,feature.get(i));
128
 			}else{
129
 				newFeature.set(i,fad.getDefaultValue());
128
 			try {
129
 				if (i<feature.size()){
130
 					newFeature.set(i,feature.get(i));
131
 				}else{
132
 					newFeature.set(i,fad.getDefaultValue());
133
 				}
134
 			} catch (IsNotFeatureSettingException e) {
135
 				throw new InitializeException("FeatureManager",e);
130 136
 			}
137

  
131 138
 		}
132 139
         ((Feature)newFeature).stopLoading();
133 140
         return newFeature;
......
164 171
    	return num;
165 172
    }
166 173

  
167
    public IFeature getFeature(int i,IFeatureStore store) throws IsNotFeatureSettingException{
174
    public IFeature getFeature(int i,IFeatureStore store) throws ReadException{
168 175
    	IFeature feature=(IFeature)expansionAdapter.getObject(i);
169 176
    	return getCorrectFeature(feature,store);
170 177
    }

Also available in: Unified diff