Coverage Report - org.kuali.rice.kns.util.OjbKualiIntegerPercentageFieldConversion
 
Classes in this File Line Coverage Branch Coverage Complexity
OjbKualiIntegerPercentageFieldConversion
0%
0/7
0%
0/8
4
 
 1  
 /*
 2  
  * Copyright 2006-2007 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.BigDecimal;
 19  
 
 20  
 import org.apache.ojb.broker.accesslayer.conversions.FieldConversion;
 21  
 
 22  
 
 23  0
 public class OjbKualiIntegerPercentageFieldConversion extends 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  0
         if (source != null && source instanceof KualiInteger) {
 32  0
             return super.javaToSql(((KualiInteger) source).bigDecimalValue());
 33  
         } else {
 34  0
             return null;
 35  
         }
 36  
     }
 37  
 
 38  
     /**
 39  
      * Convert database decimals to 'visual' percentages for use in our business objects.
 40  
      * 
 41  
      * @see FieldConversion#sqlToJava(Object)
 42  
      */
 43  
     public Object sqlToJava(Object source) {
 44  0
         if (source != null && source instanceof BigDecimal) {
 45  0
             return new KualiInteger(((KualiDecimal) (super.sqlToJava(source))).bigDecimalValue());
 46  
         } else {
 47  0
             return null;
 48  
         }
 49  
     }
 50  
 
 51  
 }