Clover coverage report - Converter - 1.0
Coverage timestamp: Thu Jan 1 1970 10:00:00 EST
file stats: LOC: 68   Methods: 3
NCLOC: 28   Classes: 1
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover
 
 Source file Conditionals Statements Methods TOTAL
StringToLongConverter.java - 0% 0% 0%
coverage
 1   
 /*
 2   
  * Copyright (C) The Spice Group. All rights reserved.
 3   
  *
 4   
  * This software is published under the terms of the Spice
 5   
  * Software License version 1.1, a copy of which has been included
 6   
  * with this distribution in the LICENSE.txt file.
 7   
  */
 8   
 package org.codehaus.spice.converter.lib;
 9   
 
 10   
 import org.codehaus.spice.converter.AbstractConverter;
 11   
 import org.codehaus.spice.converter.ConverterException;
 12   
 
 13   
 /**
 14   
  * String to Long converter.
 15   
  *
 16   
  * <p>Hexadecimal numbers begin with 0x, Octal numbers begin with 0o and binary
 17   
  * numbers begin with 0b, all other values are assumed to be decimal.</p>
 18   
  *
 19   
  * @author Peter Donald
 20   
  * @version $Revision: 1.1 $ $Date: 2003/12/02 08:37:56 $
 21   
  */
 22   
 public class StringToLongConverter
 23   
     extends AbstractConverter
 24   
 {
 25   
     /**
 26   
      * Construct the converter.
 27   
      */
 28  0
     public StringToLongConverter()
 29   
     {
 30  0
         this( null );
 31   
     }
 32   
 
 33   
     /**
 34   
      * Construct the converter with a default value.
 35   
      * If the default value is non-null, it will be returned if unable
 36   
      * to convert object to correct type.
 37   
      *
 38   
      * @param defaultValue the default value
 39   
      */
 40  0
     public StringToLongConverter( final Long defaultValue )
 41   
     {
 42  0
         super( String.class, Long.class, defaultValue );
 43   
     }
 44   
 
 45   
     /**
 46   
      * Converts a String to a Long.
 47   
      *
 48   
      * @param object the original object to convert
 49   
      * @param context the context in which to convert object (unused)
 50   
      * @return the converted object
 51   
      * @throws ConverterException if error converting object
 52   
      */
 53  0
     public Object convert( final Object object, final Object context )
 54   
         throws ConverterException
 55   
     {
 56  0
         try
 57   
         {
 58  0
             final String value = (String)object;
 59  0
             return Long.decode( value );
 60   
         }
 61   
         catch( final NumberFormatException nfe )
 62   
         {
 63  0
             return noConvert( object, nfe );
 64   
         }
 65   
     }
 66   
 }
 67   
 
 68