Mercurial > projects > dwt2
comparison org.eclipse.core.databinding/src/org/eclipse/core/databinding/UpdateValueStrategy.d @ 88:9e0ab372d5d8
Revert from TypeInfo/ClassInfo to java.lang.Class
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sun, 19 Apr 2009 11:10:09 +0200 |
parents | 6be48cf9f95c |
children |
comparison
equal
deleted
inserted
replaced
87:8594250b1d1c | 88:9e0ab372d5d8 |
---|---|
294 IValidator result = null; | 294 IValidator result = null; |
295 | 295 |
296 // We only default the validator if we defaulted the converter since the | 296 // We only default the validator if we defaulted the converter since the |
297 // two are tightly coupled. | 297 // two are tightly coupled. |
298 if (defaultedConverter) { | 298 if (defaultedConverter) { |
299 if (typeid(StringCls) is fromType) { | 299 if (Class.fromType!(StringCls) is fromType) { |
300 result = cast(IValidator) validatorsByConverter.get(cast(Object)converter); | 300 result = cast(IValidator) validatorsByConverter.get(cast(Object)converter); |
301 | 301 |
302 if (result is null) { | 302 if (result is null) { |
303 // TODO sring based lookup | 303 // TODO sring based lookup |
304 if (typeid(Integer).opEquals(toType) | 304 if (Class.fromType!(Integer).opEquals(toType) |
305 || Integer.TYPE.opEquals(toType)) { | 305 || Integer.TYPE.opEquals(toType)) { |
306 result = new StringToIntegerValidator( | 306 result = new StringToIntegerValidator( |
307 cast(NumberFormatConverter) converter); | 307 cast(NumberFormatConverter) converter); |
308 } else if (typeid(Long).opEquals(toType) | 308 } else if (Class.fromType!(Long).opEquals(toType) |
309 || Long.TYPE.opEquals(toType)) { | 309 || Long.TYPE.opEquals(toType)) { |
310 result = new StringToLongValidator( | 310 result = new StringToLongValidator( |
311 cast(NumberFormatConverter) converter); | 311 cast(NumberFormatConverter) converter); |
312 } else if (typeid(Float).opEquals(toType) | 312 } else if (Class.fromType!(Float).opEquals(toType) |
313 || Float.TYPE.opEquals(toType)) { | 313 || Float.TYPE.opEquals(toType)) { |
314 result = new StringToFloatValidator( | 314 result = new StringToFloatValidator( |
315 cast(NumberFormatConverter) converter); | 315 cast(NumberFormatConverter) converter); |
316 } else if (typeid(Double).opEquals(toType) | 316 } else if (Class.fromType!(Double).opEquals(toType) |
317 || Double.TYPE.opEquals(toType)) { | 317 || Double.TYPE.opEquals(toType)) { |
318 result = new StringToDoubleValidator( | 318 result = new StringToDoubleValidator( |
319 cast(NumberFormatConverter) converter); | 319 cast(NumberFormatConverter) converter); |
320 } else if (typeid(Byte).opEquals(toType) | 320 } else if (Class.fromType!(Byte).opEquals(toType) |
321 || Byte.TYPE.opEquals(toType)) { | 321 || Byte.TYPE.opEquals(toType)) { |
322 result = new StringToByteValidator( | 322 result = new StringToByteValidator( |
323 cast(NumberFormatConverter) converter); | 323 cast(NumberFormatConverter) converter); |
324 } else if (typeid(Short).opEquals(toType) | 324 } else if (Class.fromType!(Short).opEquals(toType) |
325 || Short.TYPE.opEquals(toType)) { | 325 || Short.TYPE.opEquals(toType)) { |
326 result = new StringToShortValidator( | 326 result = new StringToShortValidator( |
327 cast(NumberFormatConverter) converter); | 327 cast(NumberFormatConverter) converter); |
328 } else if (typeid(Character).opEquals(toType) | 328 } else if (Class.fromType!(Character).opEquals(toType) |
329 || Character.TYPE.opEquals(toType) | 329 || Character.TYPE.opEquals(toType) |
330 && null !is cast(StringToCharacterConverter)converter ) { | 330 && null !is cast(StringToCharacterConverter)converter ) { |
331 result = new StringToCharacterValidator( | 331 result = new StringToCharacterValidator( |
332 cast(StringToCharacterConverter) converter); | 332 cast(StringToCharacterConverter) converter); |
333 } else if (typeid(Date).opEquals(toType) | 333 } else if (Class.fromType!(Date).opEquals(toType) |
334 && null !is cast(StringToDateConverter)converter ) { | 334 && null !is cast(StringToDateConverter)converter ) { |
335 result = new StringToDateValidator( | 335 result = new StringToDateValidator( |
336 cast(StringToDateConverter) converter); | 336 cast(StringToDateConverter) converter); |
337 } | 337 } |
338 | 338 |
514 * singleton. | 514 * singleton. |
515 */ | 515 */ |
516 private this() { | 516 private this() { |
517 validators = new HashMap(); | 517 validators = new HashMap(); |
518 // Standalone validators here... | 518 // Standalone validators here... |
519 associate(typeid(Integer), Integer.TYPE, | 519 associate(Class.fromType!(Integer), Integer.TYPE, |
520 new ObjectToPrimitiveValidator(Integer.TYPE)); | 520 new ObjectToPrimitiveValidator(Integer.TYPE)); |
521 associate(typeid(Byte), Byte.TYPE, new ObjectToPrimitiveValidator( | 521 associate(Class.fromType!(Byte), Byte.TYPE, new ObjectToPrimitiveValidator( |
522 Byte.TYPE)); | 522 Byte.TYPE)); |
523 associate(typeid(Short), Short.TYPE, new ObjectToPrimitiveValidator( | 523 associate(Class.fromType!(Short), Short.TYPE, new ObjectToPrimitiveValidator( |
524 Short.TYPE)); | 524 Short.TYPE)); |
525 associate(typeid(Long), Long.TYPE, new ObjectToPrimitiveValidator( | 525 associate(Class.fromType!(Long), Long.TYPE, new ObjectToPrimitiveValidator( |
526 Long.TYPE)); | 526 Long.TYPE)); |
527 associate(typeid(Float), Float.TYPE, new ObjectToPrimitiveValidator( | 527 associate(Class.fromType!(Float), Float.TYPE, new ObjectToPrimitiveValidator( |
528 Float.TYPE)); | 528 Float.TYPE)); |
529 associate(typeid(Double), Double.TYPE, | 529 associate(Class.fromType!(Double), Double.TYPE, |
530 new ObjectToPrimitiveValidator(Double.TYPE)); | 530 new ObjectToPrimitiveValidator(Double.TYPE)); |
531 associate(typeid(Boolean), Boolean.TYPE, | 531 associate(Class.fromType!(Boolean), Boolean.TYPE, |
532 new ObjectToPrimitiveValidator(Boolean.TYPE)); | 532 new ObjectToPrimitiveValidator(Boolean.TYPE)); |
533 | 533 |
534 associate(typeid(Object), Integer.TYPE, | 534 associate(Class.fromType!(Object), Integer.TYPE, |
535 new ObjectToPrimitiveValidator(Integer.TYPE)); | 535 new ObjectToPrimitiveValidator(Integer.TYPE)); |
536 associate(typeid(Object), Byte.TYPE, new ObjectToPrimitiveValidator( | 536 associate(Class.fromType!(Object), Byte.TYPE, new ObjectToPrimitiveValidator( |
537 Byte.TYPE)); | 537 Byte.TYPE)); |
538 associate(typeid(Object), Short.TYPE, new ObjectToPrimitiveValidator( | 538 associate(Class.fromType!(Object), Short.TYPE, new ObjectToPrimitiveValidator( |
539 Short.TYPE)); | 539 Short.TYPE)); |
540 associate(typeid(Object), Long.TYPE, new ObjectToPrimitiveValidator( | 540 associate(Class.fromType!(Object), Long.TYPE, new ObjectToPrimitiveValidator( |
541 Long.TYPE)); | 541 Long.TYPE)); |
542 associate(typeid(Object), Float.TYPE, new ObjectToPrimitiveValidator( | 542 associate(Class.fromType!(Object), Float.TYPE, new ObjectToPrimitiveValidator( |
543 Float.TYPE)); | 543 Float.TYPE)); |
544 associate(typeid(Object), Double.TYPE, | 544 associate(Class.fromType!(Object), Double.TYPE, |
545 new ObjectToPrimitiveValidator(Double.TYPE)); | 545 new ObjectToPrimitiveValidator(Double.TYPE)); |
546 associate(typeid(Object), Boolean.TYPE, | 546 associate(Class.fromType!(Object), Boolean.TYPE, |
547 new ObjectToPrimitiveValidator(Boolean.TYPE)); | 547 new ObjectToPrimitiveValidator(Boolean.TYPE)); |
548 } | 548 } |
549 | 549 |
550 /** | 550 /** |
551 * Associate a particular validator that can validate the conversion | 551 * Associate a particular validator that can validate the conversion |