1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kns.util;
17
18 import org.apache.ojb.broker.accesslayer.conversions.FieldConversion;
19
20
21
22
23
24
25 public class OjbCharBooleanFieldAIConversion implements FieldConversion {
26 private static final String TRUE = "A";
27 private static final String FALSE = "I";
28
29
30
31
32 public Object javaToSql(Object source) {
33 if (source instanceof Boolean) {
34 if (source.equals(Boolean.TRUE)) {
35 return TRUE;
36 }
37 else {
38 return FALSE;
39 }
40 }
41 else if (source instanceof String) {
42 if ("Y".equalsIgnoreCase((String)source)) {
43 return TRUE;
44 }
45 else if ("N".equalsIgnoreCase((String)source)) {
46 return FALSE;
47 }
48 }
49 return source;
50 }
51
52
53
54
55 public Object sqlToJava(Object source) {
56 if (source instanceof String) {
57 if (TRUE.equals(source)) {
58 return Boolean.TRUE;
59 }
60 else {
61 return Boolean.FALSE;
62 }
63 }
64 else {
65 return source;
66 }
67 }
68
69 }