Revision 2082 org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.lib/src/main/java/org/gvsig/tools/dataTypes/impl/DefaultDataTypesManager.java
DefaultDataTypesManager.java | ||
---|---|---|
38 | 38 |
import org.gvsig.tools.dataTypes.Coercion; |
39 | 39 |
import org.gvsig.tools.dataTypes.CoercionException; |
40 | 40 |
import org.gvsig.tools.dataTypes.DataType; |
41 |
import static org.gvsig.tools.dataTypes.DataType.DECIMAL_DEFAULT_PRECISION; |
|
42 |
import static org.gvsig.tools.dataTypes.DataType.DECIMAL_DEFAULT_SCALE; |
|
43 |
import static org.gvsig.tools.dataTypes.DataType.DECIMAL_MAX_PRECISION; |
|
44 |
import static org.gvsig.tools.dataTypes.DataType.DOUBLE_DEFAULT_PRECISION; |
|
45 |
import static org.gvsig.tools.dataTypes.DataType.DOUBLE_DEFAULT_SCALE; |
|
46 |
import static org.gvsig.tools.dataTypes.DataType.DOUBLE_MAX_PRECISION; |
|
47 |
import static org.gvsig.tools.dataTypes.DataType.FLOAT_DEFAULT_PRECISION; |
|
48 |
import static org.gvsig.tools.dataTypes.DataType.FLOAT_DEFAULT_SCALE; |
|
49 |
import static org.gvsig.tools.dataTypes.DataType.FLOAT_MAX_PRECISION; |
|
41 | 50 |
import org.gvsig.tools.dataTypes.DataTypes; |
42 | 51 |
import org.gvsig.tools.dataTypes.DataTypesManager; |
43 | 52 |
import org.gvsig.tools.dataTypes.impl.coercion.CoerceToDecimal; |
... | ... | |
78 | 87 |
this.addtype(CHAR, null, "Char", Character.class, new CoerceToString()); |
79 | 88 |
this.addtype(INT, null, "Integer", Integer.class, new CoerceToInt(), "datatype-integer"); |
80 | 89 |
this.addtype(LONG, null, "Long", Long.class, new CoerceToLong(),"datatype-long"); |
81 |
this.addtype(FLOAT, null, "Float", Float.class, new CoerceToFloat(),"datatype-float"); |
|
82 |
this.addtype(DOUBLE, null, "Double", Double.class, new CoerceToDouble(),"datatype-double"); |
|
83 |
this.addtype(DECIMAL, null, "Decimal", BigDecimal.class, new CoerceToDecimal()); |
|
90 |
this.addtype(FLOAT, null, "Float", Float.class, new CoerceToFloat(),"datatype-float", FLOAT_MAX_PRECISION, FLOAT_DEFAULT_PRECISION, FLOAT_DEFAULT_SCALE);
|
|
91 |
this.addtype(DOUBLE, null, "Double", Double.class, new CoerceToDouble(),"datatype-double", DOUBLE_MAX_PRECISION, DOUBLE_DEFAULT_PRECISION, DOUBLE_DEFAULT_SCALE);
|
|
92 |
this.addtype(DECIMAL, null, "Decimal", BigDecimal.class, new CoerceToDecimal(),"datatype-decimal",DECIMAL_MAX_PRECISION, DECIMAL_DEFAULT_PRECISION, DECIMAL_DEFAULT_SCALE);
|
|
84 | 93 |
this.addtype(STRING, null, "String", String.class, new CoerceToString(), "datatype-string"); |
85 | 94 |
this.addtype(DATE, SUBTYPE_DATE, "Date", Date.class, new CoerceToDate(),"datatype-date"); |
86 | 95 |
this.addtype(TIME, SUBTYPE_DATE, "Time", Date.class, new CoerceToTime(),"datatype-time"); |
... | ... | |
110 | 119 |
@Override |
111 | 120 |
public final synchronized int addtype(int type, String subtype, String name, |
112 | 121 |
Class defaultClass, Coercion coercion) { |
113 |
return addtype(type, subtype, name, defaultClass, coercion, null); |
|
122 |
return addtype(type, subtype, name, defaultClass, coercion, null, 0, 0, 0);
|
|
114 | 123 |
} |
115 | 124 |
|
116 | 125 |
public final synchronized int addtype(int type, String subtype, String name, |
117 | 126 |
Class defaultClass, Coercion coercion, String iconName) { |
127 |
return addtype(type, subtype, name, defaultClass, coercion, iconName, 0, 0, 0); |
|
128 |
} |
|
129 |
|
|
130 |
@Override |
|
131 |
public final synchronized int addtype(int type, String subtype, String name, |
|
132 |
Class defaultClass, Coercion coercion, String iconName, |
|
133 |
int max_precision, int default_precision, int default_scale) { |
|
118 | 134 |
if (type == INVALID) { |
119 | 135 |
type = getNewObjectIndexType(); |
120 | 136 |
} |
... | ... | |
133 | 149 |
// OK, the type is still not registered. |
134 | 150 |
} |
135 | 151 |
|
136 |
DataType dataType = |
|
137 |
new DefaultDataType(type, subtype, name, defaultClass, coercion, iconName); |
|
152 |
DataType dataType = new DefaultDataType( |
|
153 |
type, subtype, name, defaultClass, coercion, iconName, |
|
154 |
max_precision, default_precision, default_scale |
|
155 |
); |
|
138 | 156 |
types[type] = dataType; |
139 | 157 |
LOG.info("Registered data type {}.", dataType.toString()); |
140 | 158 |
return type; |
Also available in: Unified diff