diff org.eclipse.core.databinding/src/org/eclipse/core/internal/databinding/conversion/StringToNumberParser.d @ 85:6be48cf9f95c

Work on databinding
author Frank Benoit <benoit@tionex.de>
date Sat, 18 Apr 2009 13:54:50 +0200
parents 0a55d2d5a946
children
line wrap: on
line diff
--- a/org.eclipse.core.databinding/src/org/eclipse/core/internal/databinding/conversion/StringToNumberParser.d	Sat Apr 18 09:25:29 2009 +0200
+++ b/org.eclipse.core.databinding/src/org/eclipse/core/internal/databinding/conversion/StringToNumberParser.d	Sat Apr 18 13:54:50 2009 +0200
@@ -27,15 +27,21 @@
  * @since 1.0
  */
 public class StringToNumberParser {
-    private static final BigDecimal FLOAT_MAX_BIG_DECIMAL = new BigDecimal(
-            Float.MAX_VALUE);
-    private static final BigDecimal FLOAT_MIN_BIG_DECIMAL = new BigDecimal(
-            -Float.MAX_VALUE);
+    private static BigDecimal FLOAT_MAX_BIG_DECIMAL;
+    private static BigDecimal FLOAT_MIN_BIG_DECIMAL;
+    private static BigDecimal DOUBLE_MAX_BIG_DECIMAL;
+    private static BigDecimal DOUBLE_MIN_BIG_DECIMAL;
+    static this(){
+        FLOAT_MAX_BIG_DECIMAL = new BigDecimal(
+                Float.MAX_VALUE);
+        FLOAT_MIN_BIG_DECIMAL = new BigDecimal(
+                -Float.MAX_VALUE);
 
-    private static final BigDecimal DOUBLE_MAX_BIG_DECIMAL = new BigDecimal(
-            Double.MAX_VALUE);
-    private static final BigDecimal DOUBLE_MIN_BIG_DECIMAL = new BigDecimal(
-            -Double.MAX_VALUE);
+        DOUBLE_MAX_BIG_DECIMAL = new BigDecimal(
+                Double.MAX_VALUE);
+        DOUBLE_MIN_BIG_DECIMAL = new BigDecimal(
+                -Double.MAX_VALUE);
+    }
 
     /**
      * @param value
@@ -45,12 +51,12 @@
      */
     public static ParseResult parse(Object value, NumberFormat numberFormat,
             bool primitive) {
-        if (!( null !is cast(String)value )) {
+        if (!( null !is cast(ArrayWrapperString)value )) {
             throw new IllegalArgumentException(
                     "Value to convert is not a String"); //$NON-NLS-1$
         }
 
-        String source = cast(String) value;
+        String source = stringcast( value );
         ParseResult result = new ParseResult();
         if (!primitive && source.trim().length() is 0) {
             return result;
@@ -144,7 +150,7 @@
         }
 
         return BindingMessages.formatString(
-                "Validate_NumberOutOfRangeError", [ cast(Object)min, max ]); //$NON-NLS-1$
+                "Validate_NumberOutOfRangeError", [ cast(Object)stringcast(min), stringcast(max) ]); //$NON-NLS-1$
     }
 
     /**
@@ -205,7 +211,7 @@
         }
 
         throw new IllegalArgumentException(
-                "Number of type [" + number.getClass().getName() + "] is not supported."); //$NON-NLS-1$ //$NON-NLS-2$
+                Format("Number of type [{}] is not supported.", number.classinfo.name )); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
     /**
@@ -273,7 +279,7 @@
         }
 
         throw new IllegalArgumentException(
-                "Number of type [" + number.getClass().getName() + "] is not supported."); //$NON-NLS-1$ //$NON-NLS-2$
+                Format("Number of type [{}] is not supported.", number.classinfo.name)); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
     /**