1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.kuali.rice.kew.web;
18
19 import java.math.BigDecimal;
20 import java.math.BigInteger;
21
22 import org.apache.commons.beanutils.ConvertUtils;
23 import org.apache.commons.beanutils.Converter;
24 import org.apache.commons.beanutils.converters.BigDecimalConverter;
25 import org.apache.commons.beanutils.converters.BigIntegerConverter;
26 import org.apache.commons.beanutils.converters.BooleanConverter;
27 import org.apache.commons.beanutils.converters.ByteConverter;
28 import org.apache.commons.beanutils.converters.CharacterConverter;
29 import org.apache.commons.beanutils.converters.DoubleConverter;
30 import org.apache.commons.beanutils.converters.FloatConverter;
31 import org.apache.commons.beanutils.converters.IntegerConverter;
32 import org.apache.commons.beanutils.converters.LongConverter;
33 import org.apache.commons.beanutils.converters.ShortConverter;
34
35
36
37
38
39
40
41
42 public class ConverterUtils {
43
44 public static synchronized void registerContextSensitiveConverters() {
45 registerBigDecimalConverter();
46 registerBigIntegerConverter();
47 registerBooleanConverter();
48 registerByteConverter();
49 registerCharacterConverter();
50 registerDoubleConverter();
51 registerFloatConverter();
52 registerIntegerConverter();
53 registerLongConverter();
54 registerShortConverter();
55 }
56
57 public static void registerBigDecimalConverter() {
58 Converter currentConverter = ConvertUtils.lookup(BigDecimal.class);
59 ConvertUtils.register(new ContextSensitiveConverter(currentConverter, new BigDecimalConverter(null)), BigDecimal.class);
60 }
61
62 public static void registerBigIntegerConverter() {
63 Converter currentConverter = ConvertUtils.lookup(BigInteger.class);
64 ConvertUtils.register(new ContextSensitiveConverter(currentConverter, new BigIntegerConverter(null)), BigInteger.class);
65 }
66
67 public static void registerBooleanConverter() {
68 Converter currentConverter = ConvertUtils.lookup(Boolean.class);
69 ConvertUtils.register(new ContextSensitiveConverter(currentConverter, new BooleanConverter(null)), Boolean.class);
70 }
71
72 public static void registerByteConverter() {
73 Converter currentConverter = ConvertUtils.lookup(Byte.class);
74 ConvertUtils.register(new ContextSensitiveConverter(currentConverter, new ByteConverter(null)), Byte.class);
75 }
76
77 public static void registerCharacterConverter() {
78 Converter currentConverter = ConvertUtils.lookup(Character.class);
79 ConvertUtils.register(new ContextSensitiveConverter(currentConverter, new CharacterConverter(null)), Character.class);
80 }
81
82 public static void registerDoubleConverter() {
83 Converter currentConverter = ConvertUtils.lookup(Double.class);
84 ConvertUtils.register(new ContextSensitiveConverter(currentConverter, new DoubleConverter(null)), Double.class);
85 }
86
87 public static void registerFloatConverter() {
88 Converter currentConverter = ConvertUtils.lookup(Float.class);
89 ConvertUtils.register(new ContextSensitiveConverter(currentConverter, new FloatConverter(null)), Float.class);
90 }
91
92 public static void registerIntegerConverter() {
93 Converter currentConverter = ConvertUtils.lookup(Integer.class);
94 ConvertUtils.register(new ContextSensitiveConverter(currentConverter, new IntegerConverter(null)), Integer.class);
95 }
96
97 public static void registerLongConverter() {
98 Converter currentConverter = ConvertUtils.lookup(Long.class);
99 ConvertUtils.register(new ContextSensitiveConverter(currentConverter, new LongConverter(null)), Long.class);
100 }
101
102 public static void registerShortConverter() {
103 Converter currentConverter = ConvertUtils.lookup(Short.class);
104 ConvertUtils.register(new ContextSensitiveConverter(currentConverter, new ShortConverter(null)), Short.class);
105 }
106
107 }