Revision 2088 org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.lib/src/main/java/org/gvsig/tools/dataTypes/impl/DefaultDataTypesManager.java
DefaultDataTypesManager.java | ||
---|---|---|
31 | 31 |
import java.util.Date; |
32 | 32 |
import java.util.Iterator; |
33 | 33 |
import java.util.List; |
34 |
import java.util.Locale; |
|
34 | 35 |
import java.util.Map; |
35 | 36 |
import java.util.Set; |
36 | 37 |
|
... | ... | |
46 | 47 |
import static org.gvsig.tools.dataTypes.DataType.DOUBLE_DEFAULT_PRECISION; |
47 | 48 |
import static org.gvsig.tools.dataTypes.DataType.DOUBLE_DEFAULT_SCALE; |
48 | 49 |
import static org.gvsig.tools.dataTypes.DataType.DOUBLE_MAX_PRECISION; |
50 |
import static org.gvsig.tools.dataTypes.DataType.FLAG_FLOATING_POINT; |
|
51 |
import static org.gvsig.tools.dataTypes.DataType.FLAG_NUMBER; |
|
52 |
import static org.gvsig.tools.dataTypes.DataType.FLAG_PREDEFINED_PRECISION; |
|
53 |
import static org.gvsig.tools.dataTypes.DataType.FLAG_SUPPORT_PRECISION; |
|
54 |
import static org.gvsig.tools.dataTypes.DataType.FLAG_SUPPORT_SCALE; |
|
55 |
import static org.gvsig.tools.dataTypes.DataType.FLAG_SUPPORT_SIZE; |
|
49 | 56 |
import static org.gvsig.tools.dataTypes.DataType.FLOAT_DEFAULT_PRECISION; |
50 | 57 |
import static org.gvsig.tools.dataTypes.DataType.FLOAT_DEFAULT_SCALE; |
51 | 58 |
import static org.gvsig.tools.dataTypes.DataType.FLOAT_MAX_PRECISION; |
... | ... | |
53 | 60 |
import static org.gvsig.tools.dataTypes.DataType.INT_MAX_PRECISION; |
54 | 61 |
import static org.gvsig.tools.dataTypes.DataType.LONG_DEFAULT_PRECISION; |
55 | 62 |
import static org.gvsig.tools.dataTypes.DataType.LONG_MAX_PRECISION; |
63 |
import static org.gvsig.tools.dataTypes.DataType.PRECISION_NONE; |
|
64 |
import static org.gvsig.tools.dataTypes.DataType.SCALE_NONE; |
|
56 | 65 |
import org.gvsig.tools.dataTypes.DataTypes; |
57 | 66 |
import org.gvsig.tools.dataTypes.DataTypesManager; |
58 |
import static org.gvsig.tools.dataTypes.impl.DefaultDataType.NO_SUPPORT_SCALE; |
|
59 | 67 |
import org.gvsig.tools.dataTypes.impl.coercion.CoerceToDecimal; |
60 | 68 |
import org.gvsig.tools.dataTypes.impl.coercion.CoerceToBoolean; |
61 | 69 |
import org.gvsig.tools.dataTypes.impl.coercion.CoerceToByte; |
... | ... | |
66 | 74 |
import org.gvsig.tools.dataTypes.impl.coercion.CoerceToFile; |
67 | 75 |
import org.gvsig.tools.dataTypes.impl.coercion.CoerceToFloat; |
68 | 76 |
import org.gvsig.tools.dataTypes.impl.coercion.CoerceToInt; |
77 |
import org.gvsig.tools.dataTypes.impl.coercion.CoerceToLocale; |
|
69 | 78 |
import org.gvsig.tools.dataTypes.impl.coercion.CoerceToLong; |
70 | 79 |
import org.gvsig.tools.dataTypes.impl.coercion.CoerceToObject; |
71 | 80 |
import org.gvsig.tools.dataTypes.impl.coercion.CoerceToString; |
... | ... | |
93 | 102 |
); |
94 | 103 |
this.addtype(BYTE, null, "Byte", Byte.class, new CoerceToByte(), |
95 | 104 |
"datatype-byte", |
96 |
true, BYTE_MAX_PRECISION, BYTE_DEFAULT_PRECISION |
|
105 |
FLAG_NUMBER|FLAG_SUPPORT_PRECISION|FLAG_PREDEFINED_PRECISION, |
|
106 |
BYTE_MAX_PRECISION, BYTE_DEFAULT_PRECISION |
|
97 | 107 |
); |
98 | 108 |
this.addtype(CHAR, null, "Char", Character.class, new CoerceToString()); |
99 | 109 |
this.addtype(INT, null, "Integer", Integer.class, new CoerceToInt(), |
100 | 110 |
"datatype-integer", |
101 |
true, INT_MAX_PRECISION, INT_DEFAULT_PRECISION |
|
111 |
FLAG_NUMBER|FLAG_SUPPORT_PRECISION|FLAG_PREDEFINED_PRECISION, |
|
112 |
INT_MAX_PRECISION, INT_DEFAULT_PRECISION |
|
102 | 113 |
); |
103 | 114 |
this.addtype(LONG, null, "Long", Long.class, new CoerceToLong(), |
104 | 115 |
"datatype-long", |
105 |
true, LONG_MAX_PRECISION, LONG_DEFAULT_PRECISION |
|
116 |
FLAG_NUMBER|FLAG_SUPPORT_PRECISION|FLAG_PREDEFINED_PRECISION, |
|
117 |
LONG_MAX_PRECISION, LONG_DEFAULT_PRECISION |
|
106 | 118 |
); |
107 | 119 |
this.addtype(FLOAT, null, "Float", Float.class, new CoerceToFloat(), |
108 | 120 |
"datatype-float", |
109 |
false, FLOAT_MAX_PRECISION, FLOAT_DEFAULT_PRECISION, FLOAT_DEFAULT_SCALE |
|
121 |
FLAG_FLOATING_POINT|FLAG_SUPPORT_PRECISION|FLAG_PREDEFINED_PRECISION|FLAG_SUPPORT_SCALE, |
|
122 |
FLOAT_MAX_PRECISION, FLOAT_DEFAULT_PRECISION, FLOAT_DEFAULT_SCALE |
|
110 | 123 |
); |
111 | 124 |
this.addtype(DOUBLE, null, "Double", Double.class, new CoerceToDouble(), |
112 | 125 |
"datatype-double", |
113 |
false, DOUBLE_MAX_PRECISION, DOUBLE_DEFAULT_PRECISION, DOUBLE_DEFAULT_SCALE |
|
126 |
FLAG_FLOATING_POINT|FLAG_SUPPORT_PRECISION|FLAG_PREDEFINED_PRECISION|FLAG_SUPPORT_SCALE, |
|
127 |
DOUBLE_MAX_PRECISION, DOUBLE_DEFAULT_PRECISION, DOUBLE_DEFAULT_SCALE |
|
114 | 128 |
); |
115 | 129 |
this.addtype(DECIMAL, null, "Decimal", BigDecimal.class, new CoerceToDecimal(), |
116 | 130 |
"datatype-decimal", |
117 |
false, DECIMAL_MAX_PRECISION, DECIMAL_DEFAULT_PRECISION, DECIMAL_DEFAULT_SCALE |
|
131 |
FLAG_NUMBER|FLAG_SUPPORT_PRECISION|FLAG_SUPPORT_SCALE, |
|
132 |
DECIMAL_MAX_PRECISION, DECIMAL_DEFAULT_PRECISION, DECIMAL_DEFAULT_SCALE |
|
118 | 133 |
); |
119 |
this.addtype(STRING, null, "String", String.class, new CoerceToString(), "datatype-string"); |
|
134 |
this.addtype(STRING, null, "String", String.class, new CoerceToString(), |
|
135 |
"datatype-string", |
|
136 |
FLAG_SUPPORT_SIZE |
|
137 |
); |
|
120 | 138 |
this.addtype(DATE, SUBTYPE_DATE, "Date", Date.class, new CoerceToDate(), "datatype-date"); |
121 | 139 |
this.addtype(TIME, SUBTYPE_DATE, "Time", Date.class, new CoerceToTime(), "datatype-time"); |
122 | 140 |
// this.addtype(TIMESTAMP, null, "Timestamp", Timestamp.class, new CoerceToTimestamp(),"datatype-timestamp"); |
123 | 141 |
this.addtype(TIMESTAMP, null, "Timestamp", Date.class, new CoerceToDateTime(), "datatype-timestamp"); |
142 |
|
|
143 |
this.addtype(LOCALE, null, "Locale", Locale.class, new CoerceToLocale(), |
|
144 |
"datatype-locale" |
|
145 |
); |
|
146 |
|
|
147 |
|
|
124 | 148 |
this.addtype(VERSION, null, "Version", Version.class, new CoerceToVersion()); |
125 | 149 |
|
126 | 150 |
this.addtype(BYTEARRAY, null, "ByteArray", |
127 | 151 |
(new byte[1]).getClass(), |
128 | 152 |
new CoerceToBytearray(), |
129 |
"datatype-bytearray" |
|
153 |
"datatype-bytearray", |
|
154 |
FLAG_SUPPORT_SIZE |
|
130 | 155 |
); |
131 | 156 |
this.addtype(FILE, SUBTYPE_FILE, "File", File.class, new CoerceToFile()); |
132 | 157 |
this.addtype(FOLDER, SUBTYPE_FOLDER, "Folder", File.class, new CoerceToFile()); |
... | ... | |
145 | 170 |
@Override |
146 | 171 |
public final synchronized int addtype(int type, String subtype, String name, |
147 | 172 |
Class defaultClass, Coercion coercion) { |
148 |
return addtype(type, subtype, name, defaultClass, coercion, null, false, 0, 0, 0);
|
|
173 |
return addtype(type, subtype, name, defaultClass, coercion, null, 0, PRECISION_NONE, PRECISION_NONE, SCALE_NONE);
|
|
149 | 174 |
} |
150 | 175 |
|
151 | 176 |
public final synchronized int addtype(int type, String subtype, String name, |
152 | 177 |
Class defaultClass, Coercion coercion, String iconName) { |
153 |
return addtype(type, subtype, name, defaultClass, coercion, iconName, false, 0, 0, 0);
|
|
178 |
return addtype(type, subtype, name, defaultClass, coercion, iconName, 0, PRECISION_NONE, PRECISION_NONE, SCALE_NONE);
|
|
154 | 179 |
} |
155 | 180 |
|
181 |
@Override |
|
156 | 182 |
public final synchronized int addtype(int type, String subtype, String name, |
183 |
Class defaultClass, Coercion coercion, String iconName, int flags) { |
|
184 |
return addtype(type, subtype, name, defaultClass, coercion, iconName, |
|
185 |
flags, PRECISION_NONE, PRECISION_NONE, SCALE_NONE |
|
186 |
); |
|
187 |
} |
|
188 |
|
|
189 |
public final synchronized int addtype(int type, String subtype, String name, |
|
157 | 190 |
Class defaultClass, Coercion coercion, String iconName, |
158 |
boolean predefinedPrecision, int max_precision, int default_precision) {
|
|
191 |
int flags, int max_precision, int default_precision) {
|
|
159 | 192 |
return addtype(type, subtype, name, defaultClass, coercion, iconName, |
160 |
predefinedPrecision, max_precision, default_precision, NO_SUPPORT_SCALE
|
|
193 |
flags, max_precision, default_precision, SCALE_NONE
|
|
161 | 194 |
); |
162 | 195 |
} |
163 | 196 |
|
164 | 197 |
@Override |
165 | 198 |
public final synchronized int addtype(int type, String subtype, String name, |
166 | 199 |
Class defaultClass, Coercion coercion, String iconName, |
167 |
boolean predefinedPrecision, int max_precision, int default_precision, int default_scale) {
|
|
200 |
int flags, int max_precision, int default_precision, int default_scale) {
|
|
168 | 201 |
if (type == INVALID) { |
169 | 202 |
type = getNewObjectIndexType(); |
170 | 203 |
} |
... | ... | |
185 | 218 |
|
186 | 219 |
DataType dataType = new DefaultDataType( |
187 | 220 |
type, subtype, name, defaultClass, coercion, iconName, |
188 |
predefinedPrecision, max_precision, default_precision, default_scale
|
|
221 |
flags, max_precision, default_precision, default_scale
|
|
189 | 222 |
); |
190 | 223 |
types[type] = dataType; |
191 | 224 |
LOG.info("Registered data type {}.", dataType.toString()); |
Also available in: Unified diff