KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > core > internal > databinding > conversion > NumberToDoubleConverter


1 /*******************************************************************************
2  * Copyright (c) 2007 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  ******************************************************************************/

11
12 package org.eclipse.core.internal.databinding.conversion;
13
14 import com.ibm.icu.text.NumberFormat;
15
16 /**
17  * Converts from a Number to a Double.
18  * <p>
19  * Class is thread safe.
20  * </p>
21  *
22  * @since 1.0
23  */

24 public class NumberToDoubleConverter extends NumberToNumberConverter {
25
26     /**
27      * @param numberFormat
28      * @param fromType
29      * @param primitive
30      */

31     public NumberToDoubleConverter(NumberFormat numberFormat, Class JavaDoc fromType,
32             boolean primitive) {
33         super(numberFormat, fromType, (primitive) ? Double.TYPE : Double JavaDoc.class);
34     }
35
36     /* (non-Javadoc)
37      * @see org.eclipse.core.internal.databinding.conversion.NumberToNumberConverter#doConvert(java.lang.Number)
38      */

39     protected Number JavaDoc doConvert(Number JavaDoc number) {
40         if (StringToNumberParser.inDoubleRange(number)) {
41             return new Double JavaDoc(number.doubleValue());
42         }
43         
44         return null;
45     }
46 }
47
Popular Tags