Revision 23303 branches/v2_0_0_prep/libraries/libFMap_data/src/org/gvsig/fmap/data/feature/DefaultFeatureType.java
DefaultFeatureType.java | ||
---|---|---|
185 | 185 |
|
186 | 186 |
public boolean add(Object arg0) { |
187 | 187 |
((AttributeDescriptor)arg0).setOrdinal(count); |
188 |
((AttributeDescriptor) arg0).setFeatureType(this); |
|
188 | 189 |
count++; |
189 | 190 |
return super.add(arg0); |
190 | 191 |
} |
191 | 192 |
|
192 | 193 |
protected boolean addWithoutOrdinal(Object arg0) { |
194 |
((AttributeDescriptor) arg0).setFeatureType(this); |
|
193 | 195 |
int max=((FeatureAttributeDescriptor)arg0).ordinal(); |
194 | 196 |
if (count<=max){ |
195 | 197 |
count=max+1; |
... | ... | |
273 | 275 |
} |
274 | 276 |
public FeatureType getSubFeatureType(String[] fields) throws DataException { |
275 | 277 |
DefaultFeatureType featureType=(DefaultFeatureType)this.cloneFeatureType(); |
276 |
ArrayList toRemove = new ArrayList(); |
|
277 |
Iterator iter = this.iterator(); |
|
278 |
int index=-1; |
|
279 |
int i=0; |
|
280 |
String name; |
|
281 |
boolean found; |
|
282 |
for(i=0;i<fields.length;i++){ |
|
283 |
index=this.getFieldIndex(fields[i]); |
|
284 |
if (index<0){ |
|
285 |
throw new DataException("Field '"+fields[i]+"' not found"); |
|
278 |
|
|
279 |
if (fields != null) { |
|
280 |
ArrayList toRemove = new ArrayList(); |
|
281 |
Iterator iter = this.iterator(); |
|
282 |
int index = -1; |
|
283 |
int i = 0; |
|
284 |
String name; |
|
285 |
boolean found; |
|
286 |
for (i = 0; i < fields.length; i++) { |
|
287 |
index = this.getFieldIndex(fields[i]); |
|
288 |
if (index < 0) { |
|
289 |
throw new DataException("Field '" + fields[i] |
|
290 |
+ "' not found"); |
|
291 |
} |
|
286 | 292 |
} |
287 |
}
|
|
288 |
while (iter.hasNext()){
|
|
289 |
name = ((AttributeDescriptor)iter.next()).getName();
|
|
290 |
found=false;
|
|
291 |
for (i=0;i<fields.length;i++){
|
|
292 |
if (name.equals(fields[i])){
|
|
293 |
found=true;
|
|
294 |
break;
|
|
293 |
while (iter.hasNext()) {
|
|
294 |
name = ((AttributeDescriptor) iter.next()).getName();
|
|
295 |
found = false;
|
|
296 |
for (i = 0; i < fields.length; i++) {
|
|
297 |
if (name.equals(fields[i])) {
|
|
298 |
found = true;
|
|
299 |
break;
|
|
300 |
}
|
|
295 | 301 |
} |
302 |
if (!found) { |
|
303 |
index = this.getFieldIndex(name); |
|
304 |
toRemove.add(new Integer(index)); |
|
305 |
} |
|
306 |
|
|
296 | 307 |
} |
297 |
if (!found){ |
|
298 |
index=this.getFieldIndex(name); |
|
299 |
toRemove.add(new Integer(index)); |
|
308 |
for (i = toRemove.size() - 1; i >= 0; i--) { |
|
309 |
featureType.remove(((Integer) toRemove.get(i)).intValue()); |
|
300 | 310 |
} |
301 |
|
|
302 | 311 |
} |
303 |
for (i=toRemove.size()-1;i>=0;i--){ |
|
304 |
featureType.remove(((Integer)toRemove.get(i)).intValue()); |
|
305 |
} |
|
306 | 312 |
|
307 | 313 |
return featureType; |
308 | 314 |
} |
Also available in: Unified diff