Revision 44669 trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.swing/org.gvsig.fmap.dal.swing.impl/src/main/java/org/gvsig/fmap/dal/swing/impl/featuretable/table/DynFieldFacadeOfAFeatureAttributeDescriptor.java
DynFieldFacadeOfAFeatureAttributeDescriptor.java | ||
---|---|---|
1 | 1 |
|
2 | 2 |
package org.gvsig.fmap.dal.swing.impl.featuretable.table; |
3 | 3 |
|
4 |
import java.math.BigDecimal; |
|
5 |
import java.math.MathContext; |
|
4 | 6 |
import java.text.DateFormat; |
5 | 7 |
import java.util.List; |
6 | 8 |
import java.util.Objects; |
... | ... | |
16 | 18 |
import org.gvsig.fmap.geom.Geometry; |
17 | 19 |
import org.gvsig.fmap.geom.type.GeometryType; |
18 | 20 |
import org.gvsig.timesupport.Interval; |
21 |
import org.gvsig.tools.dataTypes.Coercion; |
|
19 | 22 |
import org.gvsig.tools.dataTypes.CoercionException; |
20 | 23 |
import org.gvsig.tools.dataTypes.DataType; |
24 |
import org.gvsig.tools.dataTypes.DataTypeUtils; |
|
21 | 25 |
import org.gvsig.tools.dynobject.DynField; |
22 | 26 |
import org.gvsig.tools.dynobject.DynField_v2; |
23 | 27 |
import org.gvsig.tools.dynobject.DynMethod; |
... | ... | |
28 | 32 |
import org.gvsig.tools.dynobject.exception.DynFieldIsNotAContainerException; |
29 | 33 |
import org.gvsig.tools.dynobject.exception.DynFieldValidateException; |
30 | 34 |
import org.gvsig.tools.evaluator.Evaluator; |
35 |
import org.gvsig.tools.dataTypes.CoercionContext; |
|
31 | 36 |
|
32 | 37 |
|
33 | 38 |
public class DynFieldFacadeOfAFeatureAttributeDescriptor implements FeatureAttributeDescriptor { |
34 | 39 |
|
35 | 40 |
private DynField field; |
41 |
private CoercionContext coerceContext; |
|
42 |
|
|
36 | 43 |
public DynFieldFacadeOfAFeatureAttributeDescriptor(DynField field) { |
37 | 44 |
this.field = field; |
38 | 45 |
} |
... | ... | |
47 | 54 |
} |
48 | 55 |
|
49 | 56 |
@Override |
57 |
public MathContext getMathContext() { |
|
58 |
return MathContext.UNLIMITED; |
|
59 |
} |
|
60 |
|
|
61 |
@Override |
|
50 | 62 |
public String getDataTypeName() { |
51 | 63 |
return field.getDataType().getName(); |
52 | 64 |
} |
... | ... | |
62 | 74 |
} |
63 | 75 |
|
64 | 76 |
@Override |
77 |
public int getScale() { |
|
78 |
return 0; |
|
79 |
} |
|
80 |
|
|
81 |
@Override |
|
82 |
public Coercion getCoercion() { |
|
83 |
return this.field.getDataType().getCoercion(); |
|
84 |
} |
|
85 |
|
|
86 |
@Override |
|
87 |
public CoercionContext getCoercionContext() { |
|
88 |
if( this.coerceContext==null ) { |
|
89 |
if( this.getDataType().isNumeric() ) { |
|
90 |
if( this.getSize()==0 ) { |
|
91 |
this.coerceContext = DataTypeUtils.coerceContextDefaultDecimal(); |
|
92 |
} else { |
|
93 |
this.coerceContext = DataTypeUtils.coerceContextDecimal( |
|
94 |
null, |
|
95 |
this.getSize(), |
|
96 |
this.getPrecision(), |
|
97 |
BigDecimal.ROUND_HALF_UP |
|
98 |
); |
|
99 |
} |
|
100 |
} else { |
|
101 |
this.coerceContext = DataTypeUtils.coerceContextDefaultLocale(); |
|
102 |
} |
|
103 |
} |
|
104 |
return this.coerceContext; |
|
105 |
} |
|
106 |
|
|
107 |
@Override |
|
65 | 108 |
public Class getObjectClass() { |
66 | 109 |
return this.getDataType().getDefaultClass(); |
67 | 110 |
} |
... | ... | |
181 | 224 |
} |
182 | 225 |
|
183 | 226 |
@Override |
227 |
public Object getDefaultValueCoerced() { |
|
228 |
try { |
|
229 |
return this.getDataType().coerce(this.getDefaultValue()); |
|
230 |
} catch (CoercionException ex) { |
|
231 |
return null; |
|
232 |
} |
|
233 |
} |
|
234 |
|
|
235 |
@Override |
|
184 | 236 |
public String getSubtype() { |
185 | 237 |
return null; |
186 | 238 |
} |
Also available in: Unified diff