Mercurial > projects > dwt2
comparison org.eclipse.core.databinding/src/org/eclipse/core/internal/databinding/conversion/StringToBooleanPrimitiveConverter.d @ 85:6be48cf9f95c
Work on databinding
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sat, 18 Apr 2009 13:54:50 +0200 |
parents | 0a55d2d5a946 |
children | 9e0ab372d5d8 |
comparison
equal
deleted
inserted
replaced
84:fcf926c91ca4 | 85:6be48cf9f95c |
---|---|
24 | 24 |
25 /** | 25 /** |
26 * StringToBooleanPrimitiveConverter. | 26 * StringToBooleanPrimitiveConverter. |
27 */ | 27 */ |
28 public class StringToBooleanPrimitiveConverter : IConverter { | 28 public class StringToBooleanPrimitiveConverter : IConverter { |
29 private static final String[] trueValues; | 29 private static String[] trueValues; |
30 | 30 |
31 private static final String[] falseValues; | 31 private static String[] falseValues; |
32 | 32 |
33 static this(){ | 33 static this(){ |
34 String delimiter = BindingMessages.getStringcast(BindingMessages.VALUE_DELIMITER); | 34 String delimiter = BindingMessages.getString(BindingMessages.VALUE_DELIMITER); |
35 String values = BindingMessages.getStringcast(BindingMessages.TRUE_STRING_VALUES); | 35 String values = BindingMessages.getString(BindingMessages.TRUE_STRING_VALUES); |
36 trueValues = valuesToSortedArray(delimiter, values); | 36 trueValues = valuesToSortedArray(delimiter, values); |
37 | 37 |
38 values = BindingMessages.getStringcast(BindingMessages.FALSE_STRING_VALUES); | 38 values = BindingMessages.getString(BindingMessages.FALSE_STRING_VALUES); |
39 falseValues = valuesToSortedArray(delimiter, values); | 39 falseValues = valuesToSortedArray(delimiter, values); |
40 } | 40 } |
41 | 41 |
42 /** | 42 /** |
43 * Returns a sorted array with all values converted to upper case. | 43 * Returns a sorted array with all values converted to upper case. |
63 * (non-Javadoc) | 63 * (non-Javadoc) |
64 * | 64 * |
65 * @see org.eclipse.jface.binding.converter.IConverter#convert(java.lang.Object) | 65 * @see org.eclipse.jface.binding.converter.IConverter#convert(java.lang.Object) |
66 */ | 66 */ |
67 public Object convert(Object source) { | 67 public Object convert(Object source) { |
68 String s = cast(String) source; | 68 String s = stringcast( source); |
69 s = s.toUpperCase(); | 69 s = s.toUpperCase(); |
70 | 70 |
71 if (Arrays.binarySearch(trueValues, s) > -1) { | 71 if (Arrays.binarySearch(trueValues, s) > -1) { |
72 return Boolean.TRUE; | 72 return Boolean.TRUE; |
73 } | 73 } |
78 | 78 |
79 throw new IllegalArgumentException(s ~ " is not a legal bool value"); //$NON-NLS-1$ | 79 throw new IllegalArgumentException(s ~ " is not a legal bool value"); //$NON-NLS-1$ |
80 } | 80 } |
81 | 81 |
82 public Object getFromType() { | 82 public Object getFromType() { |
83 return String.classinfo; | 83 return typeid(StringCls); |
84 } | 84 } |
85 | 85 |
86 public Object getToType() { | 86 public Object getToType() { |
87 return Boolean.TYPE; | 87 return Boolean.TYPE; |
88 } | 88 } |