Mercurial > projects > dwt2
annotate org.eclipse.core.databinding/src/org/eclipse/core/internal/databinding/conversion/NumberToLongConverter.d @ 125:c43718956f21 default tip
Updated the snippets status.
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Thu, 11 Aug 2011 19:55:14 +0200 |
parents | 9e0ab372d5d8 |
children |
rev | line source |
---|---|
78 | 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 module org.eclipse.core.internal.databinding.conversion.NumberToLongConverter; | |
81 | 13 import org.eclipse.core.internal.databinding.conversion.NumberToNumberConverter; |
14 import org.eclipse.core.internal.databinding.conversion.StringToNumberParser; | |
78 | 15 |
16 import java.lang.all; | |
17 | |
18 import com.ibm.icu.text.NumberFormat; | |
19 | |
20 /** | |
21 * Converts from a Number to a Long. | |
22 * <p> | |
23 * Class is thread safe. | |
24 * </p> | |
25 * @since 1.0 | |
26 */ | |
27 public class NumberToLongConverter : NumberToNumberConverter { | |
28 /** | |
29 * @param numberFormat | |
30 * @param fromType | |
31 * @param primitive | |
32 */ | |
88
9e0ab372d5d8
Revert from TypeInfo/ClassInfo to java.lang.Class
Frank Benoit <benoit@tionex.de>
parents:
85
diff
changeset
|
33 public this(NumberFormat numberFormat, Class fromType, |
78 | 34 bool primitive) { |
88
9e0ab372d5d8
Revert from TypeInfo/ClassInfo to java.lang.Class
Frank Benoit <benoit@tionex.de>
parents:
85
diff
changeset
|
35 super(numberFormat, fromType, (primitive) ? Long.TYPE : Class.fromType!(Long)); |
78 | 36 } |
37 | |
38 /* (non-Javadoc) | |
39 * @see org.eclipse.core.internal.databinding.conversion.NumberToNumberConverter#doConvert(java.lang.Number) | |
40 */ | |
41 protected Number doConvert(Number number) { | |
42 if (StringToNumberParser.inLongRange(number)) { | |
43 return new Long(number.longValue()); | |
44 } | |
45 | |
46 return null; | |
47 } | |
48 } |