Revision 47436 trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.spi/src/main/java/org/gvsig/fmap/dal/feature/spi/DefaultFeatureProvider.java

View differences:

DefaultFeatureProvider.java
22 22
 */
23 23
package org.gvsig.fmap.dal.feature.spi;
24 24

  
25
import java.math.BigDecimal;
25 26
import org.apache.commons.lang3.ArrayUtils;
26 27
import org.apache.commons.lang3.StringUtils;
27 28
import org.gvsig.fmap.dal.DataTypes;
......
34 35
import org.gvsig.tools.ToolsLocator;
35 36
import org.gvsig.tools.dataTypes.Coercion;
36 37
import org.gvsig.tools.dataTypes.CoercionException;
38
import org.gvsig.tools.math.BigDecimalUtils;
37 39

  
38 40
/**
39 41
 * Default implementation for {@link FeatureProvider}
......
51 53
    
52 54
    private String[] extraValuesNames;
53 55
    private Object[] extraValues;
56
    
57
    protected boolean broken;
54 58

  
55 59
    public DefaultFeatureProvider(FeatureType type) {
56
        if (type instanceof EditableFeatureType) {
57
            throw new IllegalArgumentException("type can't by editable.");
58
        }
60
//        if (type instanceof EditableFeatureType) {
61
//            throw new IllegalArgumentException("type can't be editable.");
62
//        }
59 63
        this.featureType = type;
60 64
        this.values = new Object[featureType.size()];
61 65
        this.nulls = new boolean[featureType.size()];
......
63 67
        this.envelope = null;
64 68
        this.defaultGeometry = null;
65 69
        this.oid = null;
70
        this.broken = false;
66 71
    }
67 72

  
68 73
    public DefaultFeatureProvider(FeatureType type, Object oid) {
......
124 129
                                + value.toString()
125 130
                                + "' and context '"
126 131
                                + attribute.getCoercionContext()
127
                                + "'.");
132
                                + "' to assign to '"
133
                                + attribute.getName()
134
                                + "'.",e);
128 135
                    }
136
                } else {
137
                    try {
138
                        switch(attribute.getType()){
139
                            case DataTypes.DECIMAL:
140
                                value = BigDecimalUtils.force((BigDecimal) value, attribute.getScale(), attribute.getPrecision());
141
                                break;
142
                        }
143
                    } catch(Throwable th) {
144
                            throw new IllegalArgumentException("Can't assign "
145
                                + value.toString()
146
                                + " to '"
147
                                + attribute.getName()
148
                                + "'.",th);
149

  
150
                    }
129 151
                }
130 152
            }
131 153
        }
......
211 233
        } else {
212 234
            data.extraValuesNames = null;
213 235
        }
236
        data.broken = this.broken;
214 237
        return data;
215 238
    }
216 239

  
......
369 392
        this.extraValuesNames = extraValueNames;
370 393
        this.extraValues = new Object[this.extraValuesNames.length];
371 394
    }
395

  
396
    @Override
397
    public boolean isBroken() {
398
        return this.broken;
399
    }
372 400
    
373 401
    
374 402
}

Also available in: Unified diff