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 */
|
85
|
33 public this(NumberFormat numberFormat, TypeInfo fromType,
|
78
|
34 bool primitive) {
|
85
|
35 super(numberFormat, fromType, (primitive) ? Long.TYPE : typeid(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 }
|