01: /*
02: * Copyright 2006-2007 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.BigDecimal;
19:
20: import org.apache.ojb.broker.accesslayer.conversions.FieldConversion;
21:
22: public class OjbKualiIntegerPercentageFieldConversion extends
23: OjbDecimalPercentageFieldConversion {
24:
25: /**
26: * Convert percentages to decimals for proper storage.
27: *
28: * @see FieldConversion#javaToSql(Object)
29: */
30: public Object javaToSql(Object source) {
31: if (source != null && source instanceof KualiInteger) {
32: return super .javaToSql(((KualiInteger) source)
33: .bigDecimalValue());
34: } else {
35: return null;
36: }
37: }
38:
39: /**
40: * Convert database decimals to 'visual' percentages for use in our business objects.
41: *
42: * @see FieldConversion#sqlToJava(Object)
43: */
44: public Object sqlToJava(Object source) {
45: if (source != null && source instanceof BigDecimal) {
46: return new KualiInteger(((KualiDecimal) (super
47: .sqlToJava(source))).bigDecimalValue());
48: } else {
49: return null;
50: }
51: }
52:
53: }
|