Revision 44077 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
68 68
	protected boolean hasEvaluators;
69 69
	protected boolean hasEmulators;
70 70
	protected String defaultGeometryAttributeName;
71
	protected String defaultTimeAttributeName;
71 72
	protected int defaultGeometryAttributeIndex;
72 73
	protected int defaultTimeAttributeIndex;
73
	private String id;
74
        private String id;
74 75
	protected boolean hasOID;
75 76
	protected boolean allowAtomaticValues;
76 77
	protected FeatureAttributeDescriptor[] pk = null;
......
78 79

  
79 80
	private List srsList = null;
80 81
        private WeakReference storeRef;
81
    private boolean requiredFields;
82
        private boolean requiredFields;
82 83

  
83 84
	protected DefaultFeatureType(FeatureStore store, String id) {
84 85
            if (StringUtils.isEmpty(id)) {
......
95 96
            this.hasEvaluators = false;
96 97
            this.hasEmulators = false;
97 98
            this.defaultGeometryAttributeName = null;
99
            this.defaultTimeAttributeName = null;
98 100
            this.defaultGeometryAttributeIndex = -1;
99 101
            this.defaultTimeAttributeIndex = -1;
100 102
            this.allowAtomaticValues = false;
......
132 134
                    }
133 135
		}
134 136
		this.defaultGeometryAttributeName = other.defaultGeometryAttributeName;
137
		this.defaultTimeAttributeName = other.defaultTimeAttributeName;
135 138
		this.hasEvaluators = other.hasEvaluators;
136 139
		this.hasEmulators = other.hasEmulators;
137 140
		this.rules = (DefaultFeatureRules) other.rules.getCopy();
......
194 197
		return this.defaultGeometryAttributeName;
195 198
	}
196 199

  
200
	public int getDefaultTimeAttributeIndex() {
201
		return this.defaultTimeAttributeIndex;
202
	}
203

  
204
	public String getDefaultTimeAttributeName() {
205
		return this.defaultTimeAttributeName;
206
	}
207

  
197 208
	public EditableFeatureType getEditable() {
198 209
		return new DefaultEditableFeatureType(this);
199 210
	}
......
361 372
                        }
362 373
                    }
363 374

  
364
                    this.defaultGeometryAttributeIndex = this
365
                            .getIndex(this.defaultGeometryAttributeName);
375
                    this.defaultGeometryAttributeIndex = this.getIndex(this.defaultGeometryAttributeName);
366 376
                    if ( this.defaultGeometryAttributeIndex < 0 ) {
367 377
                        this.defaultGeometryAttributeName = null;
368 378
                    }
379
                    this.defaultTimeAttributeIndex = this.getIndex(this.defaultTimeAttributeName);
380
                    if ( this.defaultTimeAttributeIndex < 0 ) {
381
                        this.defaultTimeAttributeName = null;
382
                    }
369 383
                    this.parent = new WeakReference(parent);
370 384
                }
371 385

  
......
491 505

  
492 506

  
493 507

  
494
	public boolean equals(Object other) {
495
		if (this == other) {
496
			return true;
497
		}
498
		if (!(other instanceof DefaultFeatureType)) {
499
			return false;
500
		}
501
		DefaultFeatureType otherType = (DefaultFeatureType) other;
502
		if (!this.id.equals(otherType.id)) {
503
			return false;
504
		}
505
		if (this.size() != otherType.size()) {
506
			return false;
507
		}
508
		FeatureAttributeDescriptor attr,attrOther;
509
		Iterator iter,iterOther;
510
		iter = this.iterator();
511
		iterOther = otherType.iterator();
512
		while (iter.hasNext()) {
513
			attr = (FeatureAttributeDescriptor) iter.next();
514
			attrOther = (FeatureAttributeDescriptor) iterOther.next();
515
			if (!attr.equals(attrOther)) {
516
				return false;
517
			}
518
		}
508
	public boolean equals(Object o) {
509
            if (this == o) {
510
                    return true;
511
            }
512
            if (!(o instanceof DefaultFeatureType)) {
513
                    return false;
514
            }
515
            DefaultFeatureType other = (DefaultFeatureType) o;
516
            if (!this.id.equals(other.id)) {
517
                    return false;
518
            }
519
            if (this.size() != other.size()) {
520
                    return false;
521
            }
522
            FeatureAttributeDescriptor attr,attrOther;
523
            Iterator iter,iterOther;
524
            iter = this.iterator();
525
            iterOther = other.iterator();
526
            while (iter.hasNext()) {
527
                    attr = (FeatureAttributeDescriptor) iter.next();
528
                    attrOther = (FeatureAttributeDescriptor) iterOther.next();
529
                    if (!attr.equals(attrOther)) {
530
                            return false;
531
                    }
532
            }
519 533

  
520
		if (defaultGeometryAttributeName != otherType.defaultGeometryAttributeName) {
521
			if (defaultGeometryAttributeName == null) {
522
				return false;
523
			}
524
			return defaultGeometryAttributeName
525
					.equals(otherType.defaultGeometryAttributeName);
534
            if( !StringUtils.equals(defaultGeometryAttributeName, other.defaultGeometryAttributeName)) {
535
                return false;
536
            }
537
            if( !StringUtils.equals(defaultTimeAttributeName, other.defaultTimeAttributeName)) {
538
                return false;
539
            }
540
            return true;
526 541

  
527
		}
528
		return true;
529

  
530 542
	}
531 543

  
532 544
	/**
......
826 838
            if (this.defaultGeometryAttributeName == null && attr.getType() == DataTypes.GEOMETRY) {
827 839
                this.defaultGeometryAttributeName = attr.getName();
828 840
            }
841
            if (this.defaultTimeAttributeName == null && 
842
                    (attr.getType() == DataTypes.INSTANT || attr.getType() == DataTypes.INTERVAL) ) {
843
                this.defaultTimeAttributeName = attr.getName();
844
            }
829 845
        }
830 846
        if (this.defaultGeometryAttributeName != null) {
831 847
            this.defaultGeometryAttributeIndex = this.getIndex(this.defaultGeometryAttributeName);
832 848
        }
849
        if (this.defaultTimeAttributeName != null) {
850
            this.defaultTimeAttributeIndex = this.getIndex(this.defaultTimeAttributeName);
851
        }
833 852
        this.internalID = Long.toHexString(this.getCRC());
834 853
        
835 854
    }

Also available in: Unified diff