Coverage Report - org.kuali.rice.core.web.format.IntegerFormatter
 
Classes in this File Line Coverage Branch Coverage Complexity
IntegerFormatter
0%
0/7
0%
0/4
4
 
 1  
 /**
 2  
  * Copyright 2005-2011 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  
 // begin Kuali Foundation modification
 17  
 package org.kuali.rice.core.web.format;
 18  
 // end Kuali Foundation modification
 19  
 
 20  
 // begin Kuali Foundation modification
 21  
 import org.apache.commons.lang.StringUtils;
 22  
 import org.kuali.rice.core.api.util.RiceKeyConstants;
 23  
 
 24  
 /**
 25  
  * This class is used to format Integer objects.
 26  
  */
 27  0
 public class IntegerFormatter extends Formatter {
 28  
         // begin Kuali Foundation modification
 29  
     private static final long serialVersionUID = 226069363610021292L;
 30  
 
 31  
     // removed INTEGER_ERROR_KEY, PARSE_MSG, getErrorKey()
 32  
     // end Kuali Foundation modification
 33  
 
 34  
     /**
 35  
      * begin Kuali Foundation modification
 36  
      * Returns an object representation of the provided string.
 37  
      * end Kuali Foundation modification
 38  
      */
 39  
     protected Object convertToObject(String string) {
 40  
             // begin Kuali Foundation modification
 41  0
         if (StringUtils.isEmpty(string))
 42  0
             return null;
 43  
 
 44  
         try {
 45  0
             return new Integer(string);
 46  
         }
 47  0
         catch (NumberFormatException e) {
 48  0
             throw new FormatException("parsing", RiceKeyConstants.ERROR_INTEGER, string, e);
 49  
         }
 50  
         // end Kuali Foundation modification
 51  
     }
 52  
 
 53  
         // begin Kuali Foundation modification
 54  
     /**
 55  
      * Returns the provided value as a formatted string
 56  
      */
 57  
     public Object format(Object value) {
 58  0
         return (value == null ? null : value.toString());
 59  
     }
 60  
     // end Kuali Foundation modification
 61  
 }