Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
OjbKualiIntegerFieldConversion |
|
| 2.5;2.5 |
1 | /* | |
2 | * Copyright 2006-2008 The Kuali Foundation | |
3 | * | |
4 | * Licensed under the Educational Community License, Version 2.0 (the "License"); | |
5 | * you may not use this file except in compliance with the License. | |
6 | * You may obtain a copy of the License at | |
7 | * | |
8 | * http://www.opensource.org/licenses/ecl2.php | |
9 | * | |
10 | * Unless required by applicable law or agreed to in writing, software | |
11 | * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | * See the License for the specific language governing permissions and | |
14 | * limitations under the License. | |
15 | */ | |
16 | package org.kuali.rice.kns.util; | |
17 | ||
18 | import java.math.BigInteger; | |
19 | ||
20 | import org.apache.ojb.broker.accesslayer.conversions.FieldConversion; | |
21 | ||
22 | 0 | public class OjbKualiIntegerFieldConversion implements FieldConversion { |
23 | ||
24 | /** | |
25 | * @see FieldConversion#javaToSql(Object) | |
26 | */ | |
27 | public Object javaToSql(Object source) { | |
28 | 0 | Object converted = source; |
29 | ||
30 | 0 | if (source instanceof KualiInteger) { |
31 | 0 | converted = new Long(((KualiInteger) source).longValue()); |
32 | } | |
33 | ||
34 | 0 | return converted; |
35 | } | |
36 | ||
37 | /** | |
38 | * @see FieldConversion#sqlToJava(Object) | |
39 | */ | |
40 | public Object sqlToJava(Object source) { | |
41 | 0 | Object converted = source; |
42 | ||
43 | 0 | if (source instanceof Long) { |
44 | 0 | converted = new KualiInteger(((Long) source).longValue()); |
45 | } | |
46 | 0 | else if (source instanceof BigInteger) { |
47 | 0 | converted = new KualiInteger((BigInteger) source); |
48 | } | |
49 | ||
50 | 0 | return converted; |
51 | } | |
52 | } |