Clover coverage report - Ledge Container - SNAPSHOT
Coverage timestamp: Fri Nov 17 2006 05:16:03 CET
file stats: LOC: 97   Methods: 5
NCLOC: 57   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
LedgeStringToObjectConverter.java 12.5% 57.1% 60% 44.4%
coverage coverage
 1    //
 2    // Copyright (c) 2003, Caltha - Gajda, Krzewski, Mach, Potempski Sp.J.
 3    // All rights reserved.
 4    //
 5    // Redistribution and use in source and binary forms, with or without modification,
 6    // are permitted provided that the following conditions are met:
 7    //
 8    // * Redistributions of source code must retain the above copyright notice,
 9    // this list of conditions and the following disclaimer.
 10    // * Redistributions in binary form must reproduce the above copyright notice,
 11    // this list of conditions and the following disclaimer in the documentation
 12    // and/or other materials provided with the distribution.
 13    // * Neither the name of the Caltha - Gajda, Krzewski, Mach, Potempski Sp.J.
 14    // nor the names of its contributors may be used to endorse or promote products
 15    // derived from this software without specific prior written permission.
 16    //
 17    // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 18    // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 19    // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
 20    // IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
 21    // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
 22    // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
 23    // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 24    // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 25    // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 26    // POSSIBILITY OF SUCH DAMAGE.
 27    //
 28   
 29    package org.objectledge.pico;
 30   
 31    import org.nanocontainer.reflection.Converter;
 32    import org.nanocontainer.reflection.InvalidConversionException;
 33    import org.nanocontainer.reflection.StringToObjectConverter;
 34   
 35    /**
 36    * Converts strings to a number of predefined Java classes.
 37    *
 38    * <p>Created on Jan 8, 2004</p>
 39    * @author <a href="Rafal.Krzewski">rafal@caltha.pl</a>
 40    * @version $Id: LedgeStringToObjectConverter.java,v 1.5 2005/01/21 06:30:39 rafal Exp $
 41    */
 42    public class LedgeStringToObjectConverter extends StringToObjectConverter
 43    {
 44    /**
 45    * Creates a new converter instance.
 46    */
 47  516 public LedgeStringToObjectConverter()
 48    {
 49  516 super();
 50  516 register(Integer.TYPE,
 51    new Converter()
 52    {
 53  1032 public Object convert(String in)
 54    {
 55  1032 return in == null ? new Integer(0) : Integer.valueOf(in);
 56    }
 57    }
 58    );
 59  516 register(Long.TYPE,
 60    new Converter()
 61    {
 62  0 public Object convert(String in)
 63    {
 64  0 return in == null ? new Long(0) : Long.valueOf(in);
 65    }
 66    }
 67    );
 68  516 register(Boolean.TYPE,
 69    new Converter()
 70    {
 71  0 public Object convert(String in)
 72    {
 73  0 if (in == null || in.length() == 0) {
 74  0 return Boolean.FALSE;
 75    }
 76  0 char c = in.toLowerCase().charAt(0);
 77  0 return c == '1' || c == 'y' || c == 't' ? Boolean.TRUE : Boolean.FALSE;
 78    }
 79    });
 80  516 register(Class.class,
 81    new Converter()
 82    {
 83  688 public Object convert(String in)
 84    {
 85  688 try
 86    {
 87  688 return Class.forName(in);
 88    }
 89    catch(ClassNotFoundException e)
 90    {
 91  0 throw new InvalidConversionException("class "+in+" not found");
 92    }
 93    }
 94    }
 95    );
 96    }
 97    }