Coverage Report - org.mule.util.NumberUtils
 
Classes in this File Line Coverage Branch Coverage Complexity
NumberUtils
0%
0/15
0%
0/6
8
 
 1  
 /*
 2  
  * $Id: NumberUtils.java 7976 2007-08-21 14:26:13Z dirk.olmes $
 3  
  * --------------------------------------------------------------------------------------
 4  
  * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.com
 5  
  *
 6  
  * The software in this package is published under the terms of the CPAL v1.0
 7  
  * license, a copy of which has been included with this distribution in the
 8  
  * LICENSE.txt file.
 9  
  */
 10  
 
 11  
 package org.mule.util;
 12  
 
 13  
 /**
 14  
  * <code>NumberUtils</code> contains useful methods for manipulating numbers.
 15  
  */
 16  
 // @ThreadSafe
 17  0
 public class NumberUtils extends org.apache.commons.lang.math.NumberUtils
 18  
 {
 19  
 
 20  
     public static long toLong(Object obj)
 21  
     {
 22  0
         if (obj == null)
 23  
         {
 24  0
             throw new IllegalArgumentException("Unable to convert null object to long");
 25  
         }
 26  0
         else if (obj instanceof String)
 27  
         {
 28  0
             return toLong((String) obj);
 29  
         }
 30  0
         else if (obj instanceof Number)
 31  
         {
 32  0
             return ((Number) obj).longValue();
 33  
         }
 34  
         else
 35  
         {
 36  0
             throw new IllegalArgumentException("Unable to convert object of type: "
 37  
                                                + obj.getClass().getName() + " to long.");
 38  
         }
 39  
     }
 40  
 
 41  
     public static int toInt(Object obj)
 42  
     {
 43  0
         if (obj == null)
 44  
         {
 45  0
             throw new IllegalArgumentException("Unable to convert null object to int");
 46  
         }
 47  0
         else if (obj instanceof String)
 48  
         {
 49  0
             return toInt((String) obj);
 50  
         }
 51  0
         else if (obj instanceof Number)
 52  
         {
 53  0
             return ((Number) obj).intValue();
 54  
         }
 55  
         else
 56  
         {
 57  0
             throw new IllegalArgumentException("Unable to convert object of type: "
 58  
                                                + obj.getClass().getName() + " to int.");
 59  
         }
 60  
     }
 61  
 
 62  
 }