Revision 43358 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/DefaultFeatureType.java

View differences:

DefaultFeatureType.java
31 31
import java.util.Iterator;
32 32
import java.util.List;
33 33
import java.util.Set;
34
import org.apache.commons.lang3.ArrayUtils;
34 35

  
35 36
import org.cresques.cts.IProjection;
36 37

  
......
259 260
	}
260 261

  
261 262
	public FeatureType getSubtype(String[] names, String[] constantsNames) throws DataException {
262
                if( (names==null || names.length <1) && (constantsNames==null || constantsNames.length <1) ) {
263
                    return (FeatureType) this.clone();
264
                }
263
        if( ArrayUtils.isEmpty(names) && ArrayUtils.isEmpty(constantsNames) ) {
264
            return (FeatureType) this.clone();
265
        }
265 266
		return new SubtypeFeatureType(this, names,constantsNames);
266 267
	}
267 268

  
......
283 284
                    super(parent, false);
284 285
                    DefaultFeatureAttributeDescriptor attrcopy;
285 286
                    DefaultFeatureAttributeDescriptor attr;
286
                    Set attrnames = null;
287
                    List attrnames = null;
287 288

  
288 289
                    // Copy attributes
289 290
                    if ( names != null && names.length > 0 ) {
290
                        attrnames = new HashSet();
291
                        attrnames = new ArrayList();
291 292
                        attrnames.addAll(Arrays.asList(names));
292 293
                        if ( parent.hasEmulators ) {
293 294
                            for ( int i = 0; i < parent.size(); i++ ) {
......
326 327
                    }
327 328

  
328 329
                    // Set the consttants attributes.
329
                    if ( constantsNames != null && constantsNames.length > 0 ) {
330
                    if ( !ArrayUtils.isEmpty(constantsNames) ) {
330 331
                        for ( int i = 0; i < constantsNames.length; i++ ) {
331 332
                            if ( attrnames != null && attrnames.contains(constantsNames[i]) ) {
332 333
                                continue;
......
451 452

  
452 453
	public FeatureAttributeDescriptor[] getPrimaryKey() {
453 454
		if (pk == null) {
454
			List pkList = new ArrayList();
455
			List pks = new ArrayList();
455 456
			Iterator iter = super.iterator();
456 457
			FeatureAttributeDescriptor attr;
457 458
			while (iter.hasNext()){
458 459
				attr = (FeatureAttributeDescriptor) iter.next();
459 460
				if (attr.isPrimaryKey()){
460
					pkList.add(attr);
461
					pks.add(attr);
461 462
				}
462 463
			}
463
			pk = (FeatureAttributeDescriptor[]) pkList
464
					.toArray(new FeatureAttributeDescriptor[pkList.size()]);
464
            if( pks.isEmpty() ) {
465
                pk = new FeatureAttributeDescriptor[0];
466
            } else {
467
                pk = (FeatureAttributeDescriptor[])pks.toArray(new FeatureAttributeDescriptor[pks.size()]);
468
            }
465 469
		}
466 470
		return pk;
467 471
	}

Also available in: Unified diff