Revision 20414

View differences:

trunk/libraries/libDataSourceBaseDrivers/src-test/org/gvsig/data/datastores/vectorial/file/shp/SHPTest.java
78 78
		while (iter.hasNext()) {
79 79
			IFeature feature = (IFeature)iter.next();
80 80
			System.out.println("SHP Feature ------------------- ");
81
			for (int i=0;i<ft.size();i++){
82

  
83
				IFeatureAttributeDescriptor descriptor=(IFeatureAttributeDescriptor)ft.get(i);
81
			Iterator iterator=ft.iterator();
82
			while (iterator.hasNext()) {
83
				IFeatureAttributeDescriptor descriptor = (IFeatureAttributeDescriptor) iterator.next();
84
				int i=descriptor.ordinal();
84 85
				String type=descriptor.getDataType();
85 86
				if (type.equals(IFeatureAttributeDescriptor.TYPE_BOOLEAN)){
86 87
					System.out.println("Boolean ----- "+ feature.getBoolean(i));
trunk/libraries/libDataSourceBaseDrivers/src-test/org/gvsig/data/datastores/vectorial/file/dbf/DBFTest.java
71 71

  
72 72
			IFeature feature = (IFeature)iter.next();
73 73
			System.out.println("DBF Feature ------------------- ");
74
			for (int i=0;i<ft.size();i++){
75
				IFeatureAttributeDescriptor descriptor=(IFeatureAttributeDescriptor)ft.get(i);
74
			Iterator iterator=ft.iterator();
75
			while (iterator.hasNext()) {
76
				IFeatureAttributeDescriptor descriptor = (IFeatureAttributeDescriptor) iterator.next();
77
				int i=descriptor.ordinal();
76 78
				String type=descriptor.getDataType();
77 79
				if (type.equals(IFeatureAttributeDescriptor.TYPE_BOOLEAN)){
78 80
					System.out.println("Boolean ----- "+ feature.getBoolean(i));
trunk/libraries/libDataSourceBaseDrivers/src-test/org/gvsig/data/datastores/vectorial/file/dxf/DXFTest.java
19 19
import org.gvsig.data.vectorial.IFeatureAttributeDescriptor;
20 20
import org.gvsig.data.vectorial.IFeatureCollection;
21 21
import org.gvsig.data.vectorial.IFeatureType;
22
import org.gvsig.data.vectorial.IsNotFeatureSettingException;
22 23
import org.gvsig.data.vectorial.expansionadapter.FeatureManager;
23 24
import org.gvsig.data.vectorial.expansionadapter.MemoryExpansionAdapter;
24 25

  
......
56 57
		} catch (OpenException e1) {
57 58
			// TODO Auto-generated catch block
58 59
			e1.printStackTrace();
60
		} catch (IsNotFeatureSettingException e) {
61
			// TODO Auto-generated catch block
62
			e.printStackTrace();
59 63
		}
60 64

  
61 65
		IFeatureType ft=store.getDefaultFeatureType();
......
66 70
		} catch (ReadException e) {
67 71
			// TODO Auto-generated catch block
68 72
			e.printStackTrace();
73
		} catch (IsNotFeatureSettingException e) {
74
			// TODO Auto-generated catch block
75
			e.printStackTrace();
69 76
		}
70 77
		Iterator iter = featureCollection.iterator();
71 78
		while (iter.hasNext()) {
72 79
			IFeature feature = (IFeature)iter.next();
73 80
			System.out.println("DXF Feature ------------------- ");
74
			for (int i=0;i<ft.size();i++){
75

  
76
				IFeatureAttributeDescriptor descriptor=(IFeatureAttributeDescriptor)ft.get(i);
81
			Iterator iterator=ft.iterator();
82
			while (iterator.hasNext()) {
83
				IFeatureAttributeDescriptor descriptor = (IFeatureAttributeDescriptor) iterator.next();
84
				int i=descriptor.ordinal();
77 85
				String type=descriptor.getDataType();
78 86
				if (type.equals(IFeatureAttributeDescriptor.TYPE_BOOLEAN)){
79 87
					System.out.println("Boolean ----- "+ feature.getBoolean(i));
trunk/libraries/libDataSourceBaseDrivers/src-test/org/gvsig/data/datastores/vectorial/file/DataStoreTest.java
26 26
import org.gvsig.data.vectorial.IFeatureCollection;
27 27
import org.gvsig.data.vectorial.IFeatureStore;
28 28
import org.gvsig.data.vectorial.IFeatureType;
29
import org.gvsig.data.vectorial.IsNotFeatureSettingException;
29 30
import org.gvsig.data.vectorial.visitor.PrintlnFeaturesVisitor;
30 31
import org.gvsig.exceptions.BaseException;
31 32

  
......
326 327
		} catch (ReadException e) {
327 328
			// TODO Auto-generated catch block
328 329
			e.printStackTrace();
330
		} catch (IsNotFeatureSettingException e) {
331
			// TODO Auto-generated catch block
332
			e.printStackTrace();
329 333
		}
330 334
	}
331 335

  
......
639 643
		} catch (ReadException e) {
640 644
			// TODO Auto-generated catch block
641 645
			e.printStackTrace();
646
		} catch (IsNotFeatureSettingException e) {
647
			// TODO Auto-generated catch block
648
			e.printStackTrace();
642 649
		}
643 650
	}
644 651

  
......
788 795
		} catch (ReadException e) {
789 796
			// TODO Auto-generated catch block
790 797
			e.printStackTrace();
798
		} catch (IsNotFeatureSettingException e) {
799
			// TODO Auto-generated catch block
800
			e.printStackTrace();
791 801
		}
792 802
	}
793 803

  
......
936 946
		} catch (ReadException e) {
937 947
			// TODO Auto-generated catch block
938 948
			e.printStackTrace();
949
		} catch (IsNotFeatureSettingException e) {
950
			// TODO Auto-generated catch block
951
			e.printStackTrace();
939 952
		}
940 953
	}
941 954

  
......
981 994
		} catch (OpenException e2) {
982 995
			e2.printStackTrace();
983 996
			fail();
997
		} catch (IsNotFeatureSettingException e) {
998
			// TODO Auto-generated catch block
999
			e.printStackTrace();
984 1000
		}
985 1001

  
986 1002
		if (fs.isEditable() && testEdit) {
......
990 1006
				e.printStackTrace();
991 1007
				fail();
992 1008
			}
1009
			try {
1010
			IFeature feature1 = fs.createDefaultFeature(false);
993 1011

  
994
			IFeature feature1 = fs.createDefaultFeature(false);
995 1012
			IFeature feature2 = fs.createDefaultFeature(false);
996 1013
			IFeature feature3 = fs.createDefaultFeature(false);
997 1014

  
......
1001 1018
			fs.update(feature3,feature1);
1002 1019
			fs.delete(feature3);
1003 1020
			fs.delete(feature2);
1021
			} catch (IsNotFeatureSettingException e) {
1022
				// TODO Auto-generated catch block
1023
				e.printStackTrace();
1024
			}
1004 1025
		}
1005 1026

  
1006 1027
		//Mostrar por consola todos los registros.
......
1014 1035
		} catch (ReadException e2) {
1015 1036
			// TODO Auto-generated catch block
1016 1037
			e2.printStackTrace();
1038
		} catch (IsNotFeatureSettingException e) {
1039
			// TODO Auto-generated catch block
1040
			e.printStackTrace();
1017 1041
		}
1018 1042

  
1019 1043
		PrintlnFeaturesVisitor visitor=new PrintlnFeaturesVisitor(ft);
......
1035 1059
			} catch (ReadException e) {
1036 1060
				e.printStackTrace();
1037 1061
				fail("Exception: "+e);
1062
			} catch (IsNotFeatureSettingException e) {
1063
				// TODO Auto-generated catch block
1064
				e.printStackTrace();
1038 1065
			}
1039 1066
		}
1040 1067
		try {
trunk/libraries/libDataSourceBaseDrivers/src-test/org/gvsig/data/datastores/vectorial/file/dgn/DGNTest.java
18 18
import org.gvsig.data.vectorial.IFeatureAttributeDescriptor;
19 19
import org.gvsig.data.vectorial.IFeatureCollection;
20 20
import org.gvsig.data.vectorial.IFeatureType;
21
import org.gvsig.data.vectorial.IsNotFeatureSettingException;
21 22
import org.gvsig.data.vectorial.expansionadapter.FeatureManager;
22 23
import org.gvsig.data.vectorial.expansionadapter.MemoryExpansionAdapter;
23 24

  
......
52 53
		} catch (OpenException e) {
53 54
			// TODO Auto-generated catch block
54 55
			e.printStackTrace();
56
		} catch (IsNotFeatureSettingException e) {
57
			// TODO Auto-generated catch block
58
			e.printStackTrace();
55 59
		}
56 60

  
57 61
		IFeatureType ft=store.getDefaultFeatureType();
......
66 70
		while (iter.hasNext()) {
67 71
			IFeature feature = (IFeature)iter.next();
68 72
			System.out.println("DGN Feature ------------------- ");
69
			for (int i=0;i<ft.size();i++){
70

  
71
				IFeatureAttributeDescriptor descriptor=(IFeatureAttributeDescriptor)ft.get(i);
73
			Iterator iterator=ft.iterator();
74
			while (iterator.hasNext()) {
75
				IFeatureAttributeDescriptor descriptor = (IFeatureAttributeDescriptor) iterator.next();
76
				int i=descriptor.ordinal();
72 77
				String type=descriptor.getDataType();
73 78
				if (type.equals(IFeatureAttributeDescriptor.TYPE_BOOLEAN)){
74 79
					System.out.println("Boolean ----- "+ feature.getBoolean(i));
trunk/libraries/libDataSourceBaseDrivers/src/org/gvsig/data/datastores/vectorial/file/shp/ShpFeatureCollection.java
1 1
package org.gvsig.data.datastores.vectorial.file.shp;
2 2

  
3
import java.util.ArrayList;
4
import java.util.Comparator;
3 5
import java.util.Iterator;
6
import java.util.TreeSet;
4 7

  
5 8
import org.gvsig.data.datastores.vectorial.file.dbf.DBFFeatureCollection;
9
import org.gvsig.data.datastores.vectorial.file.dbf.DBFStore;
10
import org.gvsig.data.exception.ReadException;
11
import org.gvsig.data.vectorial.IFeature;
12
import org.gvsig.data.vectorial.IFeatureCollection;
6 13
import org.gvsig.data.vectorial.IFeatureID;
7 14
import org.gvsig.data.vectorial.IFeatureType;
8 15
import org.gvsig.data.vectorial.expansionadapter.FeatureManager;
16
import org.gvsig.data.vectorial.order.FeatureComparator;
9 17

  
10 18
public class ShpFeatureCollection extends DBFFeatureCollection {
11 19

  
......
18 26
	}
19 27

  
20 28
	protected class SHPIterator extends DBFFeatureCollection.DBFIterator{
21
		protected IFeatureID createCurrectFeatureID(long pos){
29
		protected IFeatureID createCurrentFeatureID(long pos){
22 30
			if (pos<driverFeatureCount){
23 31
				return new ShpFeatureID((SHPStore)store,pos);
24 32
			} else {
......
28 36

  
29 37

  
30 38
	}
39

  
31 40
}
trunk/libraries/libDataSourceBaseDrivers/src/org/gvsig/data/datastores/vectorial/file/shp/ShpFeature.java
3 3
import java.text.DateFormat;
4 4
import java.text.ParseException;
5 5
import java.util.Date;
6
import java.util.Iterator;
6 7
import java.util.List;
7 8
import java.util.Locale;
8 9

  
......
14 15
import org.gvsig.data.vectorial.IFeatureAttributeDescriptor;
15 16
import org.gvsig.data.vectorial.IFeatureID;
16 17
import org.gvsig.data.vectorial.IFeatureType;
18
import org.gvsig.data.vectorial.IsNotFeatureSettingException;
17 19

  
18 20
import com.iver.cit.gvsig.fmap.core.IGeometry;
19 21

  
......
30 32
	}
31 33

  
32 34

  
33
	void load(DbaseFile dbf,IGeometry geometry) throws ReadException{
34
		for (int i=0;i<featureType.size();i++) {
35
			IFeatureAttributeDescriptor descriptor= (IFeatureAttributeDescriptor)featureType.get(i);
35
	void load(DbaseFile dbf,IGeometry geometry) throws ReadException, IsNotFeatureSettingException{
36
		Iterator iterator=featureType.iterator();
37
		this.loading();
38
		while (iterator.hasNext()) {
39
			IFeatureAttributeDescriptor descriptor = (IFeatureAttributeDescriptor) iterator.next();
40
			int i=descriptor.ordinal();
36 41
			String fieldType=descriptor.getDataType();
37 42
			if (fieldType.equals(IFeatureAttributeDescriptor.TYPE_GEOMETRY)){
38 43
				this.setGeometry(i,geometry);
......
83 88
				this.set(i,null);
84 89
			}
85 90
		}
86

  
91
		this.stopLoading();
87 92
	}
88 93

  
89 94

  
trunk/libraries/libDataSourceBaseDrivers/src/org/gvsig/data/datastores/vectorial/file/shp/SHPStore.java
35 35
import org.gvsig.data.vectorial.IFeatureCollection;
36 36
import org.gvsig.data.vectorial.IFeatureID;
37 37
import org.gvsig.data.vectorial.IFeatureType;
38
import org.gvsig.data.vectorial.IsNotFeatureSettingException;
38 39
import org.gvsig.exceptions.BaseException;
39 40
import org.gvsig.metadata.IMetadata;
40 41
import org.gvsig.metadata.IMetadataManager;
......
67 68
			featureType=super.getDefaultFeatureType();
68 69

  
69 70
			DefaultAttributeDescriptor dad=new DefaultAttributeDescriptor();
70
	        dad.setOrdinal(featureType.size());
71 71
	        dad.setName("GEOMETRY");
72 72
	        dad.setType(IFeatureAttributeDescriptor.TYPE_GEOMETRY);
73 73
	        featureType.add(dad);
......
139 139
//
140 140
//	    }
141 141

  
142
	protected void doFinishEdition() throws WriteException, ReadException {
142
	protected void doFinishEdition() throws WriteException, ReadException, IsNotFeatureSettingException {
143 143
		IFeaturesWriter writer = getFeaturesWriter();
144 144
        writer.init(this);
145 145
        writer.updateFeatureType(featureType);
......
169 169
		return coll;
170 170
	}
171 171

  
172
	public IFeature getFeatureByID(IFeatureID id) throws ReadException {
172
	public IFeature getFeatureByID(IFeatureID id) throws ReadException, IsNotFeatureSettingException {
173 173
		if (this.alterMode){
174 174
    		if (featureManager.contains(id)) {
175 175
    			return featureManager.getFeature(id);
......
339 339
		}
340 340
		return metadata;
341 341
	}
342
	protected IFeature getFeatureByPosition(IFeatureType featureType,long position) throws ReadException {
342
	protected IFeature getFeatureByPosition(IFeatureType featureType,long position) throws ReadException, IsNotFeatureSettingException {
343 343
		ShpFeature feature=new ShpFeature(featureType,this,position);
344 344
		feature.load(dbf, this.getGeometry(position));
345 345
		return feature;
trunk/libraries/libDataSourceBaseDrivers/src/org/gvsig/data/datastores/vectorial/file/shp/ShpFeatureCollectionWithFeatureID.java
1 1
package org.gvsig.data.datastores.vectorial.file.shp;
2 2

  
3
import java.util.ArrayList;
4
import java.util.Comparator;
5
import java.util.Iterator;
6
import java.util.TreeSet;
7

  
8
import org.gvsig.data.datastores.vectorial.file.dbf.DBFFeatureCollection;
3 9
import org.gvsig.data.datastores.vectorial.file.dbf.DBFFeatureCollectionWithFeatureID;
10
import org.gvsig.data.datastores.vectorial.file.dbf.DBFStore;
4 11
import org.gvsig.data.exception.ReadException;
12
import org.gvsig.data.vectorial.IFeature;
13
import org.gvsig.data.vectorial.IFeatureCollection;
5 14
import org.gvsig.data.vectorial.IFeatureType;
6 15
import org.gvsig.data.vectorial.expansionadapter.FeatureManager;
16
import org.gvsig.data.vectorial.order.FeatureComparator;
7 17

  
8 18
public class ShpFeatureCollectionWithFeatureID extends
9 19
		DBFFeatureCollectionWithFeatureID {
......
12 22
		super(fm, store, type, filter, Order);
13 23
		// TODO Auto-generated constructor stub
14 24
	}
25
	protected void intilizeFeatureIDs(FeatureManager fm,DBFStore store, String filter,String order) throws ReadException {
26
		try{
27
		if (order == null){
28
			if (filter == null){
29
				featureIDs = new ArrayList(); // Si queremos optimizar deberiamos inicializar
30
				// el tama?o
31
			} else {
32
				featureIDs = new ArrayList();
33
			}
34
		} else {
35
			Comparator comparator = new FeatureComparator(this.featureType,order);
36
			featureIDs = new TreeSet(comparator);
37
		}
38
		IFeatureCollection coll = new ShpFeatureCollection(fm,(SHPStore)store,this.featureType,filter);
39
		Iterator iter = coll.iterator();
40
		while (iter.hasNext()){
41
			IFeature feature =(IFeature)iter.next();
42
			featureIDs.add(feature.getID());
43
		}
44
		}catch (Exception e) {
45
			throw new ReadException("DBFFeatureCollection",e);
46
		}
47
	}
15 48

  
16 49
}
trunk/libraries/libDataSourceBaseDrivers/src/org/gvsig/data/datastores/vectorial/file/dbf/utils/DbaseFileHeader.java
12 12
import java.nio.channels.FileChannel;
13 13
import java.util.Calendar;
14 14
import java.util.Date;
15
import java.util.Iterator;
15 16

  
16 17
import org.gvsig.data.exception.UnsupportedTypeException;
17 18
import org.gvsig.data.exception.UnsupportedVersionException;
......
301 302
        return myUpdateDate;
302 303
    }
303 304

  
304
    /**
305
     /**
305 306
     * Return the number of fields in the records.
306 307
     *
307 308
     * @return DOCUMENT ME!
......
525 526

  
526 527
	public static DbaseFileHeader createDbaseHeader(IFeatureType featureType) throws UnsupportedTypeException {
527 528
		DbaseFileHeader header = new DbaseFileHeader();
529
		Iterator iterator=featureType.iterator();
530
		while (iterator.hasNext()) {
531
			IFeatureAttributeDescriptor descriptor = (IFeatureAttributeDescriptor) iterator.next();
528 532

  
529
		for (int i=0;i<featureType.size();i++) {
530
			IFeatureAttributeDescriptor descriptor= (IFeatureAttributeDescriptor)featureType.get(i);
531 533

  
532 534
			String type = descriptor.getDataType();
533 535
			String colName = descriptor.getName();
trunk/libraries/libDataSourceBaseDrivers/src/org/gvsig/data/datastores/vectorial/file/dbf/utils/DbaseFileWriter.java
72 72
import java.text.NumberFormat;
73 73
import java.util.Calendar;
74 74
import java.util.Date;
75
import java.util.Iterator;
75 76
import java.util.Locale;
76 77

  
77 78
import org.gvsig.data.exception.CloseException;
......
167 168
    // put the 'not-deleted' marker
168 169
    buffer.put( (byte) ' ');
169 170

  
170
    for (int i = 0; i < header.getNumFields(); i++) {
171
    	String type=((IFeatureAttributeDescriptor)featureType.get(i)).getDataType();
172
    	String fieldString = fieldString(type, feature, i);
173
    	if (fieldString==null){
174
    		if (type==IFeatureAttributeDescriptor.TYPE_STRING){
175
    			fieldString = NULL_STRING;
176
    		}else if (type==IFeatureAttributeDescriptor.TYPE_DATE){
177
    			fieldString = NULL_DATE;
178
    		}else{
179
    			fieldString = "0";
180
    		}
181
    	}
182
    		try {
183
				buffer.put(fieldString.getBytes(charset.name()));
184
			} catch (java.io.UnsupportedEncodingException e) {
185
				throw new UnsupportedEncodingException("DBF Writer",e);
186
			}
187
    }
171
    Iterator iterator=featureType.iterator();
172
   while (iterator.hasNext()) {
173
	   IFeatureAttributeDescriptor fad = (IFeatureAttributeDescriptor) iterator.next();
174
	   String type=fad.getDataType();
175
	   int i=fad.ordinal();
176
	   if (featureType.getDefaultGeometry()!=null && featureType.getDefaultGeometry().equals(fad.getName())){
177
		   continue;
178
	   }
179
	   String fieldString = fieldString(type, feature, i);
180
	   if (fieldString==null){
181
		   if (type==IFeatureAttributeDescriptor.TYPE_STRING){
182
			   fieldString = NULL_STRING;
183
		   }else if (type==IFeatureAttributeDescriptor.TYPE_DATE){
184
			   fieldString = NULL_DATE;
185
		   }else{
186
			   fieldString = "0";
187
		   }
188
	   }
189
	   try {
190
		   buffer.put(fieldString.getBytes(charset.name()));
191
	   } catch (java.io.UnsupportedEncodingException e) {
192
		   throw new UnsupportedEncodingException("DBF Writer",e);
193
	   }
194
   }
188 195
    write();
189 196
  }
190 197

  
......
215 222
    // put the 'not-deleted' marker
216 223
    buffer.put( (byte) ' ');
217 224

  
218
    for (int i = 0; i < header.getNumFields(); i++) {
219
    	IFeatureAttributeDescriptor descriptor=(IFeatureAttributeDescriptor)featureType.get(i);
220
    	String type=descriptor.getDataType();
225
    Iterator iterator=featureType.iterator();
226
    while (iterator.hasNext()) {
227
 	   IFeatureAttributeDescriptor fad = (IFeatureAttributeDescriptor) iterator.next();
228
    	int i=fad.ordinal();
229
 	   String type=fad.getDataType();
221 230
    	String fieldString = fieldString(type, feature, i);
222 231
    	try {
223 232
			buffer.put(fieldString.getBytes(charset.name()));
224 233
		} catch (java.io.UnsupportedEncodingException e) {
225 234
			throw new UnsupportedEncodingException("DBF",e);
226 235
		}
236
	}
227 237

  
228
    }
229

  
230 238
    try {
231 239
		fileChannel.write(buffer, newPos);
232 240
	} catch (IOException e) {
trunk/libraries/libDataSourceBaseDrivers/src/org/gvsig/data/datastores/vectorial/file/dbf/DBFFeatureCollection.java
13 13
import org.gvsig.data.vectorial.IFeatureID;
14 14
import org.gvsig.data.vectorial.IFeatureStore;
15 15
import org.gvsig.data.vectorial.IFeatureType;
16
import org.gvsig.data.vectorial.IsNotFeatureSettingException;
16 17
import org.gvsig.data.vectorial.expansionadapter.FeatureManager;
17 18
import org.gvsig.data.vectorial.filter.FeatureFilterParser;
18 19

  
......
156 157
				throw new ConcurrentModificationException("FeatureCollection modified");
157 158
		}
158 159

  
159
		protected IFeatureID createCurrectFeatureID(long pos){
160
		protected IFeatureID createCurrentFeatureID(long pos){
160 161
			if (pos<driverFeatureCount){
161 162
				return new DBFFeatureID((DBFStore)store,pos);
162 163
			} else {
......
174 175
			nextChecked=true;
175 176
			while (true){
176 177
				if (position<driverFeatureCount){
177
					IFeatureID featureID = this.createCurrectFeatureID(position);
178
					IFeatureID featureID = this.createCurrentFeatureID(position);
178 179
					try {
179 180
						feature=featureID.getFeature(featureType);
180 181
					} catch (ReadException e) {
181 182
						throw new RuntimeException(e);
183
					}catch (IsNotFeatureSettingException e) {
184
						throw new RuntimeException(e);
182 185
					}
183 186
				}else if (featureManager!=null && (position-driverFeatureCount)<featureManager.getNum()){
184 187
					int pos=(int)(position-driverFeatureCount);
trunk/libraries/libDataSourceBaseDrivers/src/org/gvsig/data/datastores/vectorial/file/dbf/DBFFeatureID.java
4 4
import org.gvsig.data.vectorial.IFeature;
5 5
import org.gvsig.data.vectorial.IFeatureID;
6 6
import org.gvsig.data.vectorial.IFeatureType;
7
import org.gvsig.data.vectorial.IsNotFeatureSettingException;
7 8

  
8 9
public class DBFFeatureID implements IFeatureID{
9 10
	protected long featureIndex;
......
16 17
	long getIndex(){
17 18
		return featureIndex;
18 19
	}
19
	public IFeature getFeature(IFeatureType featureType) throws ReadException {
20
	public IFeature getFeature(IFeatureType featureType) throws ReadException, IsNotFeatureSettingException {
20 21
		return store.getFeatureByID(this);
21 22
	}
22 23
	public boolean equals(Object obj) {
trunk/libraries/libDataSourceBaseDrivers/src/org/gvsig/data/datastores/vectorial/file/dbf/DBFFeature.java
3 3
import java.text.DateFormat;
4 4
import java.text.ParseException;
5 5
import java.util.Date;
6
import java.util.Iterator;
6 7
import java.util.List;
7 8
import java.util.Locale;
8 9

  
......
13 14
import org.gvsig.data.vectorial.IFeatureAttributeDescriptor;
14 15
import org.gvsig.data.vectorial.IFeatureID;
15 16
import org.gvsig.data.vectorial.IFeatureType;
17
import org.gvsig.data.vectorial.IsNotFeatureSettingException;
16 18

  
17 19

  
18 20
public class DBFFeature extends Feature{
......
27 29
	}
28 30

  
29 31

  
30
	void load(DbaseFile dbf) throws ReadException{
31
		for (int i=0;i<this.featureType.size();i++) {
32
			IFeatureAttributeDescriptor descriptor= (IFeatureAttributeDescriptor)this.featureType.get(i);
33
			if (dbf.getFieldCount()<=i)
32
	void load(DbaseFile dbf) throws ReadException, IsNotFeatureSettingException{
33
		 Iterator iterator=featureType.iterator();
34
		 this.loading();
35
		 while (iterator.hasNext()) {
36
			   IFeatureAttributeDescriptor descriptor = (IFeatureAttributeDescriptor) iterator.next();
37
			   int i=descriptor.ordinal();
38
			   if (dbf.getFieldCount()<=i)
34 39
				return;
35 40
			String value=dbf.getStringFieldValue((int) this.featureIndex, i);
36 41
			value=value.trim();
......
76 81
				this.set(i,null);
77 82
			}
78 83
		}
84
		 this.stopLoading();
79 85

  
80 86
	}
81 87

  
trunk/libraries/libDataSourceBaseDrivers/src/org/gvsig/data/datastores/vectorial/file/dbf/DBFFeatureCollectionWithFeatureID.java
13 13
import org.gvsig.data.vectorial.IFeatureCollection;
14 14
import org.gvsig.data.vectorial.IFeatureID;
15 15
import org.gvsig.data.vectorial.IFeatureType;
16
import org.gvsig.data.vectorial.IsNotFeatureSettingException;
16 17
import org.gvsig.data.vectorial.expansionadapter.FeatureManager;
17 18
import org.gvsig.data.vectorial.order.FeatureComparator;
18 19

  
......
143 144
				feature = fid.getFeature(featureType);
144 145
			} catch (ReadException e) {
145 146
				throw new RuntimeException(e);
147
			} catch (IsNotFeatureSettingException e) {
148
				throw new RuntimeException(e);
146 149
			}
147 150
			return feature;
148 151
		}
trunk/libraries/libDataSourceBaseDrivers/src/org/gvsig/data/datastores/vectorial/file/dbf/DBFStore.java
31 31
import org.gvsig.data.vectorial.IFeatureCollection;
32 32
import org.gvsig.data.vectorial.IFeatureID;
33 33
import org.gvsig.data.vectorial.IFeatureType;
34
import org.gvsig.data.vectorial.IsNotFeatureSettingException;
34 35
import org.gvsig.exceptions.BaseException;
35 36
import org.gvsig.metadata.IMetadata;
36 37
import org.gvsig.metadata.IMetadataManager;
......
53 54
			dbf.open(file);
54 55
			featureType=new DefaultFeatureType();
55 56
			    for (int i = 0; i < dbf.getFieldCount(); i++) {
56
	                featureType.add(createFeatureAttribute(i));
57
			    	IFeatureAttributeDescriptor fad=createFeatureAttribute(i);
58
	                featureType.add(fad);
57 59
	            }
58 60
	    }
59 61

  
......
61 63
	 private IFeatureAttributeDescriptor createFeatureAttribute(int i) {
62 64
	        char fieldType = dbf.getFieldType(i);
63 65
	        DefaultAttributeDescriptor dad=new DefaultAttributeDescriptor();
64
	        dad.setOrdinal(i);
65 66
	        dad.setName(dbf.getFieldName(i));
66 67
	        dad.setSize(dbf.getFieldLength(i));
67 68
	        if (fieldType == 'L') {
......
86 87

  
87 88
	    }
88 89

  
89
	protected void doFinishEdition() throws WriteException, ReadException {
90
	protected void doFinishEdition() throws WriteException, ReadException, IsNotFeatureSettingException {
90 91
		IFeaturesWriter writer = getFeaturesWriter();
91 92
        writer.init(this);
92 93
        writer.updateFeatureType(featureType);
......
118 119

  
119 120
	}
120 121

  
121
	public IFeature getFeatureByID(IFeatureID id) throws ReadException {
122
	public IFeature getFeatureByID(IFeatureID id) throws ReadException, IsNotFeatureSettingException {
122 123
		if (this.alterMode){
123 124
    		if (featureManager.contains(id)) {
124 125
    			return featureManager.getFeature(id);
......
223 224
		return metadata;
224 225
	}
225 226

  
226
	protected IFeature getFeatureByPosition(IFeatureType ft,long position) throws ReadException {
227
	protected IFeature getFeatureByPosition(IFeatureType ft,long position) throws ReadException, IsNotFeatureSettingException {
227 228
//		 Field Type (C  or M)
228 229
//       char cfieldType = fieldTypes[fieldId];
229 230
//       int fieldType = getFieldType(fieldId);
trunk/libraries/libDataSourceBaseDrivers/src/org/gvsig/data/datastores/vectorial/file/dxf/DXFFeature.java
1 1
package org.gvsig.data.datastores.vectorial.file.dxf;
2 2

  
3 3
import org.gvsig.data.vectorial.IFeatureType;
4
import org.gvsig.data.vectorial.IsNotFeatureSettingException;
4 5
import org.gvsig.data.vectorial.MemoryFeature;
5 6

  
6 7
public class DXFFeature extends MemoryFeature{
7 8

  
8
	public DXFFeature(IFeatureType type, boolean defaultValues) {
9
	public DXFFeature(IFeatureType type, boolean defaultValues) throws IsNotFeatureSettingException {
9 10
		super(type, defaultValues);
10 11
	}
11 12
}
trunk/libraries/libDataSourceBaseDrivers/src/org/gvsig/data/datastores/vectorial/file/dxf/DXFFeaturesWriter.java
4 4
import java.awt.geom.Point2D;
5 5
import java.io.File;
6 6
import java.io.IOException;
7
import java.util.Iterator;
7 8
import java.util.Vector;
8 9

  
9 10
import org.cresques.cts.IProjection;
......
103 104

  
104 105
		entityMaker = new DxfEntityMaker(proj);
105 106
//		FieldDescription[] fieldDescriptions=getTableDefinition().getFieldsDesc();
106
		for (int i=0;i<featureType.size();i++){
107
			IFeatureAttributeDescriptor fad=(IFeatureAttributeDescriptor)featureType.get(i);
107
		Iterator iterator=featureType.iterator();
108
		int i=0;
109
		while (iterator.hasNext()) {
110
			IFeatureAttributeDescriptor fad = (IFeatureAttributeDescriptor) iterator.next();
108 111
			if (fad.getName().equals("Text")){
109 112
				indexText=i;
110 113
			}else if (fad.getName().equals("HeightText")){
......
112 115
			}else if (fad.getName().equals("RotationText")){
113 116
				indexRotationText=i;
114 117
			}
118
			i++;
115 119
		}
116 120
	}
117 121

  
......
293 297
//		Double elevation=DEFAULT_ELEVATION;
294 298
		Double thickness=DEFAULT_THICKNESS;
295 299
		if (featureType.size() > 6) {
296
			IFeatureAttributeDescriptor fad=(IFeatureAttributeDescriptor)featureType.get(3);
297
			if (fad.getName().equals("Layer") &&
300
			IFeatureAttributeDescriptor fad=(IFeatureAttributeDescriptor)featureType.get("Layer");
301
//			IFeatureAttributeDescriptor fad=(IFeatureAttributeDescriptor)featureType.get(3);
302
			if (fad!=null &&
298 303
					!(feature.get(3) == null) &&
299 304
					feature.get(3) instanceof String) {
300 305
				layer = feature.get(3).toString();
301 306
			}
302
			fad=(IFeatureAttributeDescriptor)featureType.get(4);
303
			if (fad.getName().equals("Color")
307
			fad=(IFeatureAttributeDescriptor)featureType.get("Color");
308
//			fad=(IFeatureAttributeDescriptor)featureType.get(4);
309
			if (fad!=null
304 310
					&& !(feature.get(4) == null) &&
305 311
					feature.get(4) instanceof Number) {
306 312
				color = new Integer(((Number) feature.get(4)).intValue());
......
308 314
			// if (!(values[5] instanceof NullValue)){
309 315
			// elevation= new Double(((NumericValue)values[5]).doubleValue());
310 316
			// }
311
			fad=(IFeatureAttributeDescriptor)featureType.get(6);
312
			if (fad.getName().equals("Thickness") &&
317
			fad=(IFeatureAttributeDescriptor)featureType.get("Thickness");
318
//			fad=(IFeatureAttributeDescriptor)featureType.get(6);
319
			if (fad!=null &&
313 320
					!(feature.get(6) == null) &&
314 321
					feature.get(6) instanceof Number) {
315 322
				thickness = new Double(((Number) feature.get(6)).doubleValue());
trunk/libraries/libDataSourceBaseDrivers/src/org/gvsig/data/datastores/vectorial/file/dxf/DXFStore.java
44 44
import org.gvsig.data.vectorial.IFeatureCollection;
45 45
import org.gvsig.data.vectorial.IFeatureID;
46 46
import org.gvsig.data.vectorial.IFeatureType;
47
import org.gvsig.data.vectorial.IsNotFeatureSettingException;
47 48
import org.gvsig.data.vectorial.MemoryFeature;
48 49
import org.gvsig.data.vectorial.filter.FeatureFilterParser;
49 50
import org.gvsig.data.vectorial.order.FeatureComparator;
......
172 173
			descriptorRotationText.setDefaultValue(new Double(10));
173 174
			fType.add(descriptorRotationText);
174 175

  
176

  
175 177
			return fType;
176 178

  
177 179
	 }
......
180 182
			featureType= newFeatureType();
181 183
		}
182 184

  
183
	protected void doFinishEdition() throws WriteException, ReadException {
185
	protected void doFinishEdition() throws WriteException, ReadException, IsNotFeatureSettingException {
184 186
		IFeaturesWriter writer = getFeaturesWriter();
185 187
        writer.init(this);
186 188
        writer.updateFeatureType(featureType);
......
196 198

  
197 199
	}
198 200

  
199
	public IDataCollection getDataCollection(IFeatureType type, String filter, String order) throws ReadException {
201
	public IDataCollection getDataCollection(IFeatureType type, String filter, String order) throws ReadException, IsNotFeatureSettingException {
200 202
		if (type==null){
201 203
			type=getDefaultFeatureType();
202 204
		}
......
230 232
			if (featureManager == null || !featureManager.isDeleted(feature)){
231 233
				try {
232 234
						MemoryFeature auxfeature=new MemoryFeature(type,false);
235
						auxfeature.loading();
233 236
//						auxfeature.setDefaultGeometry(feature.getDefaultGeometry());
234
						for (Iterator iter = type.iterator(); iter
235
								.hasNext();) {
236
							IFeatureAttributeDescriptor fad = (IFeatureAttributeDescriptor) iter.next();
237
							String name=fad.getName();
238
							auxfeature.set(name,feature.get(name));
237
						Iterator iterator=type.iterator();
238
						while (iterator.hasNext()) {
239
							IFeatureAttributeDescriptor fad = (IFeatureAttributeDescriptor) iterator.next();
240
							int index=fad.ordinal();
241
							auxfeature.set(index,feature.get(index));
239 242
						}
240 243
						if (filter==null || parser.match(auxfeature)){
241 244
							allFeatures.add(auxfeature);
242 245
						}
246
						auxfeature.stopLoading();
243 247

  
244 248
				} catch (ReadException e) {
245 249
					// TODO Auto-generated catch block
......
255 259

  
256 260
	}
257 261

  
258
	public IFeature getFeatureByID(IFeatureID id) throws ReadException {
262
	public IFeature getFeatureByID(IFeatureID id) throws ReadException, NumberFormatException, IsNotFeatureSettingException {
259 263
		if (this.alterMode){
260 264
    		if (featureManager.contains(id)) {
261 265
    			return featureManager.getFeature(id);
......
298 302
		return DATASTORE_NAME;
299 303
	}
300 304

  
301
	public void open() throws OpenException {
305
	public void open() throws OpenException, IsNotFeatureSettingException {
302 306
		this.observable.notifyObservers(
303 307
				new FeatureStoreNotification(this,FeatureStoreNotification.BEFORE_OPEN)
304 308
		);
......
422 426
//			auxRow[ID_FIELD_HEIGHTTEXT] = new Double(0.0);
423 427
//			auxRow[ID_FIELD_ROTATIONTEXT] = new Double(0.0);
424 428
//			auxRow[ID_FIELD_TEXT] = null;
425

  
429
			feature.loading();
426 430
			Feature fea = (Feature) features.get(i);
427 431
			if (fea.getGeometry() instanceof Point
428 432
					&& !(fea.getGeometry() instanceof org.cresques.px.gml.Point3D)) {
......
850 854
			} else {
851 855
				// System.out.println("Detectado feature desconocido");
852 856
			}
857
			feature.stopLoading();
853 858
		}
854 859

  
855 860
		defaultLegend = LegendFactory
trunk/libraries/libDataSourceBaseDrivers/src/org/gvsig/data/datastores/vectorial/file/dgn/DGNFeature.java
2 2

  
3 3
import org.gvsig.data.vectorial.IFeature;
4 4
import org.gvsig.data.vectorial.IFeatureType;
5
import org.gvsig.data.vectorial.IsNotFeatureSettingException;
5 6
import org.gvsig.data.vectorial.MemoryFeature;
6 7

  
7 8
public class DGNFeature extends MemoryFeature{
......
9 10
	public DGNFeature(IFeature feature){
10 11
		super(feature);
11 12
	}
12
	public DGNFeature(IFeatureType type, boolean defaultValues) {
13
	public DGNFeature(IFeatureType type, boolean defaultValues) throws IsNotFeatureSettingException {
13 14
		super(type, defaultValues);
14 15
	}
15 16
}
trunk/libraries/libDataSourceBaseDrivers/src/org/gvsig/data/datastores/vectorial/file/dgn/DGNStore.java
39 39
import org.gvsig.data.vectorial.IFeatureCollection;
40 40
import org.gvsig.data.vectorial.IFeatureID;
41 41
import org.gvsig.data.vectorial.IFeatureType;
42
import org.gvsig.data.vectorial.IsNotFeatureSettingException;
42 43
import org.gvsig.data.vectorial.filter.FeatureFilterParser;
43 44
import org.gvsig.data.vectorial.order.FeatureComparator;
44 45
import org.gvsig.exceptions.BaseException;
......
140 141
		descriptorText.setDefaultValue("");
141 142
		fType.add(descriptorText);
142 143

  
143

  
144

  
145

  
146

  
147 144
		DefaultAttributeDescriptor descriptorShape = new DefaultAttributeDescriptor();
148 145
		descriptorShape.setType(IFeatureAttributeDescriptor.TYPE_GEOMETRY);
149 146
		descriptorShape.setName("GEOMETRY");
......
159 156
		featureType = newFeatureType();
160 157
	}
161 158

  
162
	protected void doFinishEdition() throws WriteException, ReadException {
159
	protected void doFinishEdition() throws WriteException, ReadException, IsNotFeatureSettingException {
163 160
		IFeaturesWriter writer = getFeaturesWriter();
164 161
		writer.init(this);
165 162
		writer.updateFeatureType(featureType);
......
236 233
		return coll;
237 234
	}
238 235

  
239
	public IFeature getFeatureByID(IFeatureID id) throws ReadException {
236
	public IFeature getFeatureByID(IFeatureID id) throws ReadException, IsNotFeatureSettingException {
240 237
		if (this.alterMode){
241 238
			if (featureManager.contains(id)) {
242 239
				return featureManager.getFeature(id);
......
279 276
		return DATASTORE_NAME;
280 277
	}
281 278

  
282
	public void open() throws OpenException {
279
	public void open() throws OpenException, IsNotFeatureSettingException {
283 280
		this.observable.notifyObservers(
284 281
				new FeatureStoreNotification(this,FeatureStoreNotification.BEFORE_OPEN)
285 282
		);
......
297 294
//		Value[] cellRow = new Value[7];
298 295
//		Value[] complexRow = new Value[7];
299 296
		IFeature auxFeature=new DGNFeature(featureType,true);
297
		auxFeature.loading();
300 298
		IFeature cellFeature=new DGNFeature(featureType,false);
299
		cellFeature.loading();
301 300
		IFeature complexFeature=new DGNFeature(featureType,false);
301
		complexFeature.loading();
302 302
		initializeFeatureType();
303 303
//		ArrayList arrayFields = new ArrayList();
304 304
//		arrayFields.add("ID");
......
768 768
//				addShape(new FPolygon2D(elementoCompuesto), auxRow);
769 769
			}
770 770
		}
771

  
771
		cellFeature.stopLoading();
772
		auxFeature.stopLoading();
773
		complexFeature.stopLoading();
772 774
		defaultLegend = LegendFactory.createVectorialUniqueValueLegend(FShape.MULTI);
773 775
		defaultLegend.setClassifyingFieldNames(new String[] {"Color"} );
774 776
		defaultLegend.setClassifyingFieldTypes(new int[]{Types.INTEGER,Types.VARCHAR,Types.INTEGER,Types.INTEGER,Types.FLOAT,Types.DOUBLE,Types.VARCHAR});

Also available in: Unified diff