Revision 44448 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/impl/dataprofile/DataProfileText.java

View differences:

DataProfileText.java
4 4
import org.gvsig.fmap.dal.DALLocator;
5 5
import org.gvsig.fmap.dal.DataManager;
6 6
import org.gvsig.fmap.dal.feature.AbstractDataProfile;
7
import org.gvsig.tools.dataTypes.CoercionException;
8
import org.gvsig.tools.dataTypes.DataType;
7 9
import org.gvsig.tools.dynobject.Tags;
8 10

  
9 11
/**
......
21 23
    public Object createData(Object data, Tags tags) {
22 24
        return Objects.toString(data, null);
23 25
    }
26

  
27
    @Override
28
    public Object coerce(DataType dataType, Object data, Tags tags) throws CoercionException {
29
        String s = Objects.toString(data, null);
30
        if( s == null ) {
31
            return null;
32
        }    
33
        try {
34
            data = dataType.coerce(s);
35
            return data;
36
        } catch(Exception ex) {
37
            throw new CoercionException("Can't convert String to "+dataType.getName(), ex);            
38
        }
39
    }
24 40
    
25 41
    public static void selfRegister() {
26 42
        DataManager dataManager = DALLocator.getDataManager();

Also available in: Unified diff