KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jface > internal > databinding > provisional > conversion > ConvertString2BigDecimal


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

12 package org.eclipse.jface.internal.databinding.provisional.conversion;
13
14 import java.math.BigDecimal JavaDoc;
15
16
17
18 /**
19  * ConvertString2BigDecimal.
20  */

21 public class ConvertString2BigDecimal implements IConverter {
22
23     /* (non-Javadoc)
24      * @see org.eclipse.jface.binding.converter.IConverter#convert(java.lang.Object)
25      */

26     public Object JavaDoc convert(Object JavaDoc source) {
27         try {
28             return new BigDecimal JavaDoc((String JavaDoc)source);
29         } catch (Exception JavaDoc e) {
30             throw new IllegalArgumentException JavaDoc("String2BigDecimal: " + e.getMessage() + ": " + source); //$NON-NLS-1$ //$NON-NLS-2$
31
}
32     }
33
34     public Object JavaDoc getFromType() {
35         return String JavaDoc.class;
36     }
37
38     public Object JavaDoc getToType() {
39         return BigDecimal JavaDoc.class;
40     }
41
42 }
43
Popular Tags