Mercurial > projects > dwt2
comparison org.eclipse.core.databinding/src/org/eclipse/core/internal/databinding/conversion/NumberToNumberConverter.d @ 85:6be48cf9f95c
Work on databinding
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sat, 18 Apr 2009 13:54:50 +0200 |
parents | 383ce7bd736b |
children | 9e0ab372d5d8 |
comparison
equal
deleted
inserted
replaced
84:fcf926c91ca4 | 85:6be48cf9f95c |
---|---|
11 | 11 |
12 module org.eclipse.core.internal.databinding.conversion.NumberToNumberConverter; | 12 module org.eclipse.core.internal.databinding.conversion.NumberToNumberConverter; |
13 import org.eclipse.core.internal.databinding.conversion.StringToNumberParser; | 13 import org.eclipse.core.internal.databinding.conversion.StringToNumberParser; |
14 | 14 |
15 import java.lang.all; | 15 import java.lang.all; |
16 import java.nonstandard.RuntimeTraits; | |
16 | 17 |
17 import org.eclipse.core.databinding.conversion.Converter; | 18 import org.eclipse.core.databinding.conversion.Converter; |
18 | 19 |
19 import com.ibm.icu.text.NumberFormat; | 20 import com.ibm.icu.text.NumberFormat; |
20 | 21 |
32 private bool primitive; | 33 private bool primitive; |
33 | 34 |
34 private String outOfRangeMessage; | 35 private String outOfRangeMessage; |
35 | 36 |
36 protected this(NumberFormat numberFormat, | 37 protected this(NumberFormat numberFormat, |
37 ClassInfo fromType, ClassInfo toType) { | 38 TypeInfo fromType, TypeInfo toType) { |
38 super(fromType, toType); | 39 super(fromType, toType); |
39 this.numberFormat = numberFormat; | 40 this.numberFormat = numberFormat; |
40 this.primitive = toType.isPrimitive(); | 41 this.primitive = isJavaPrimitive(toType); |
41 } | 42 } |
42 | 43 |
43 /* | 44 /* |
44 * (non-Javadoc) | 45 * (non-Javadoc) |
45 * | 46 * |
46 * @see org.eclipse.core.databinding.conversion.IConverter#convert(java.lang.Object) | 47 * @see org.eclipse.core.databinding.conversion.IConverter#convert(java.lang.Object) |
47 */ | 48 */ |
48 public final Object convert(Object fromObject) { | 49 // DWT not final, need to override to reimplement interface IConvert |
50 public /+final+/ Object convert(Object fromObject) { | |
49 if (fromObject is null) { | 51 if (fromObject is null) { |
50 if (primitive) { | 52 if (primitive) { |
51 throw new IllegalArgumentException( | 53 throw new IllegalArgumentException( |
52 "Parameter 'fromObject' cannot be null."); //$NON-NLS-1$ | 54 "Parameter 'fromObject' cannot be null."); //$NON-NLS-1$ |
53 } | 55 } |
68 } | 70 } |
69 | 71 |
70 synchronized (this) { | 72 synchronized (this) { |
71 if (outOfRangeMessage is null) { | 73 if (outOfRangeMessage is null) { |
72 outOfRangeMessage = StringToNumberParser | 74 outOfRangeMessage = StringToNumberParser |
73 .createOutOfRangeMessage(new Shortcast(Short.MIN_VALUE), | 75 .createOutOfRangeMessage(new Short(Short.MIN_VALUE), |
74 new Shortcast(Short.MAX_VALUE), numberFormat); | 76 new Short(Short.MAX_VALUE), numberFormat); |
75 } | 77 } |
76 | 78 |
77 throw new IllegalArgumentException(outOfRangeMessage); | 79 throw new IllegalArgumentException(outOfRangeMessage); |
78 } | 80 } |
79 } | 81 } |