Coverage Report - org.kuali.rice.kns.util.OjbKualiPercentFieldConversion
 
Classes in this File Line Coverage Branch Coverage Complexity
OjbKualiPercentFieldConversion
0%
0/10
0%
0/6
3
 
 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.BigDecimal;
 19  
 
 20  
 import org.apache.ojb.broker.accesslayer.conversions.FieldConversion;
 21  
 
 22  
 /**
 23  
  * Creates a KualiPercent object from the data field. Field is stored as a percentage.
 24  
  * 
 25  
  * 
 26  
  */
 27  0
 public class OjbKualiPercentFieldConversion implements FieldConversion {
 28  
 
 29  
     /**
 30  
      * @see FieldConversion#javaToSql(Object)
 31  
      */
 32  
     public Object javaToSql(Object source) {
 33  0
         Object converted = source;
 34  
 
 35  0
         if (source instanceof KualiPercent) {
 36  0
             converted = ((KualiPercent) source).bigDecimalValue();
 37  
         }
 38  
 
 39  0
         return converted;
 40  
     }
 41  
 
 42  
     /**
 43  
      * @see FieldConversion#sqlToJava(Object)
 44  
      */
 45  
     public Object sqlToJava(Object source) {
 46  
 
 47  
         // Check for null, and verify object type.
 48  
         // Do conversion if our type is correct (BigDecimal).
 49  0
         if (source != null && source instanceof BigDecimal) {
 50  0
             BigDecimal converted = (BigDecimal) source;
 51  
 
 52  
             // Once we have converted, we need to convert again to KualiPercent.
 53  0
             KualiPercent percentConverted = new KualiPercent((BigDecimal) converted);
 54  
 
 55  0
             return percentConverted;
 56  
 
 57  
         }
 58  
         else {
 59  0
             return null;
 60  
         }
 61  
     }
 62  
 }