Revision 35465 branches/dal_time_support/libraries/libFMap_dal/src/org/gvsig/fmap/dal/feature/impl/attributegetter/AbstractRelativeInstantFeatureAttributeGetter.java

View differences:

AbstractRelativeInstantFeatureAttributeGetter.java
22 22
package org.gvsig.fmap.dal.feature.impl.attributegetter;
23 23

  
24 24
import org.gvsig.fmap.dal.DataTypes;
25
import org.gvsig.timesupport.RelativeInstant;
25 26
import org.gvsig.tools.dataTypes.DataType;
26 27

  
27 28

  
......
32 33
 */
33 34
public abstract class AbstractRelativeInstantFeatureAttributeGetter  extends AbstractObjectToTimefeatureAttributeGetter {
34 35
    protected DataType dataType = null;
36
    protected long millisInUnit = 1;
35 37

  
36
    public AbstractRelativeInstantFeatureAttributeGetter() {
38
    public AbstractRelativeInstantFeatureAttributeGetter(long millisInUnit) {
37 39
        super();
38 40
        this.dataType = DATA_TYPES_MANAGER.get(DataTypes.INSTANT);
41
        this.millisInUnit = millisInUnit;
39 42
    }
40 43

  
41 44
    public DataType getDataType() {  
42 45
        return dataType;
43 46
    }
47
    
48
    public Object getter(Object sourceAttributeValue) {
49
        if (sourceAttributeValue == null){
50
            return TIME_SUPPORT_MANAGER.createRelativeInstant(0);
51
        }
52
        return TIME_SUPPORT_MANAGER.createRelativeInstant((long)new Double(sourceAttributeValue.toString()).doubleValue() * millisInUnit);
53
     }
44 54

  
55
    public Object setter(Object targetAttributeValue) {
56
        return new Long(((RelativeInstant)targetAttributeValue).getMillis() / millisInUnit);
57
    }
58

  
45 59
}

Also available in: Unified diff