1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.sys;
17
18 import org.directwebremoting.ConversionException;
19 import org.directwebremoting.extend.Converter;
20 import org.directwebremoting.extend.ConverterManager;
21 import org.directwebremoting.extend.InboundVariable;
22 import org.directwebremoting.extend.OutboundContext;
23 import org.kuali.rice.core.api.util.type.KualiDecimal;
24 import org.kuali.rice.core.api.util.type.KualiInteger;
25
26 import uk.ltd.getahead.dwr.compat.BaseV10Converter;
27
28
29
30
31
32
33
34 public class KualiNumberConverter extends BaseV10Converter implements Converter {
35
36
37
38 public void setConverterManager(ConverterManager config) {
39 }
40
41
42
43
44
45 public Object convertInbound(Class paramType, InboundVariable iv) throws ConversionException {
46 String value = iv.getValue();
47 try {
48 if (paramType == KualiDecimal.class) {
49 return new KualiDecimal(value.trim());
50 }
51
52 if (paramType == KualiInteger.class) {
53 return new KualiInteger(value.trim());
54 }
55 String message = MessageBuilder.buildMessage("BigNumberConverter.NonPrimitive", paramType.getName()).getMessage();
56 throw new ConversionException(paramType,message);
57 }
58 catch (NumberFormatException ex) {
59 String message = MessageBuilder.buildMessage("BigNumberConverter.FormatError", paramType.getName()).getMessage();
60 throw new ConversionException(paramType, message, ex);
61 }
62 }
63
64
65
66
67
68
69 public String convertOutbound(Object object, String varname, OutboundContext outctx) {
70 return "var " + varname + "=" + object.toString() + ';';
71 }
72 }