KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jodd > bean > converters > BigIntegerConverter


1 package jodd.bean.converters;
2
3 import java.math.BigInteger;
4
5 /**
6  * Converts given object to BigInteger.
7  */

8
9 public final class BigIntegerConverter implements jodd.bean.Converter {
10
11     public Object convert(Object value) {
12
13         if (value == null) {
14             return (BigInteger) null;
15         }
16     
17         if (value instanceof BigInteger) {
18             return value;
19         }
20     
21         try {
22             return (new BigInteger(value.toString()));
23         } catch (Exception e) {
24             throw new IllegalArgumentException("BigInteger conversion for " + value + " failed.");
25         }
26     }
27 }
28
Popular Tags