01: /*
02: * Copyright 2006 The Kuali Foundation.
03: *
04: * Licensed under the Educational Community License, Version 1.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.opensource.org/licenses/ecl1.php
09: *
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.core.util;
17:
18: import java.math.BigInteger;
19:
20: import org.apache.ojb.broker.accesslayer.conversions.FieldConversion;
21:
22: public class OjbKualiIntegerFieldConversion implements FieldConversion {
23:
24: /**
25: * @see FieldConversion#javaToSql(Object)
26: */
27: public Object javaToSql(Object source) {
28: Object converted = source;
29:
30: if (source instanceof KualiInteger) {
31: converted = new Long(((KualiInteger) source).longValue());
32: }
33:
34: return converted;
35: }
36:
37: /**
38: * @see FieldConversion#sqlToJava(Object)
39: */
40: public Object sqlToJava(Object source) {
41: Object converted = source;
42:
43: if (source instanceof Long) {
44: converted = new KualiInteger(((Long) source).longValue());
45: } else if (source instanceof BigInteger) {
46: converted = new KualiInteger((BigInteger) source);
47: }
48:
49: return converted;
50: }
51: }
|