KickJava   Java API By Example, From Geeks To Geeks.

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


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 Byte.
18  * <p>
19  * Class is thread safe.
20  * </p>
21  *
22  * @since 1.0
23  */

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

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

38     protected Number JavaDoc doConvert(Number JavaDoc number) {
39         if (StringToNumberParser.inByteRange(number)) {
40             return new Byte JavaDoc(number.byteValue());
41         }
42         
43         return null;
44     }
45 }
46
Popular Tags