| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| IntegerFormatter | 
  | 
  | 4.0;4 | 
| 1 |  /* | |
| 2 |   * Copyright 2004 Jonathan M. Lehr | |
| 3 |   * | |
| 4 |   * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. | |
| 5 |   * You may obtain a copy of the License at | |
| 6 |   * | |
| 7 |   * http://www.apache.org/licenses/LICENSE-2.0 | |
| 8 |   * | |
| 9 |   * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" | |
| 10 |   * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language | |
| 11 |   * governing permissions and limitations under the License. | |
| 12 |   *  | |
| 13 |   * MODIFIED BY THE KUALI FOUNDATION | |
| 14 |   */ | |
| 15 |  // begin Kuali Foundation modification | |
| 16 |  package org.kuali.rice.core.web.format; | |
| 17 |  // end Kuali Foundation modification | |
| 18 | ||
| 19 |  // begin Kuali Foundation modification | |
| 20 |  import org.apache.commons.lang.StringUtils; | |
| 21 |  import org.kuali.rice.core.util.RiceKeyConstants; | |
| 22 | ||
| 23 |  /** | |
| 24 |   * This class is used to format Integer objects. | |
| 25 |   */ | |
| 26 | 0 |  public class IntegerFormatter extends Formatter { | 
| 27 |          // begin Kuali Foundation modification | |
| 28 | private static final long serialVersionUID = 226069363610021292L;  | |
| 29 | ||
| 30 |      // removed INTEGER_ERROR_KEY, PARSE_MSG, getErrorKey() | |
| 31 |      // end Kuali Foundation modification | |
| 32 | ||
| 33 |      /** | |
| 34 |       * begin Kuali Foundation modification | |
| 35 |       * Returns an object representation of the provided string. | |
| 36 |       * end Kuali Foundation modification | |
| 37 |       */ | |
| 38 |      protected Object convertToObject(String string) { | |
| 39 |              // begin Kuali Foundation modification | |
| 40 | 0 |          if (StringUtils.isEmpty(string)) | 
| 41 | 0 |              return null; | 
| 42 | ||
| 43 |          try { | |
| 44 | 0 |              return new Integer(string); | 
| 45 | }  | |
| 46 | 0 |          catch (NumberFormatException e) { | 
| 47 | 0 |              throw new FormatException("parsing", RiceKeyConstants.ERROR_INTEGER, string, e); | 
| 48 | }  | |
| 49 |          // end Kuali Foundation modification | |
| 50 | }  | |
| 51 | ||
| 52 |          // begin Kuali Foundation modification | |
| 53 |      /** | |
| 54 |       * Returns the provided value as a formatted string | |
| 55 |       */ | |
| 56 |      public Object format(Object value) { | |
| 57 | 0 |          return (value == null ? null : value.toString()); | 
| 58 | }  | |
| 59 |      // end Kuali Foundation modification | |
| 60 | }  |