Coverage Report - org.apache.commons.convert.ConvertUtils
 
Classes in this File Line Coverage Branch Coverage Complexity
ConvertUtils
0%
0/7
N/A
1
 
 1  
 /*
 2  
  *  Copyright 2004 The Apache Software Foundation
 3  
  *
 4  
  *  Licensed under the Apache 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.apache.org/licenses/LICENSE-2.0
 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  
 package org.apache.commons.convert;
 17  
 
 18  
 /**
 19  
  * Simple public API for the conversion system consisting of static methods.
 20  
  * <p>
 21  
  * The methods on this class access the default range of converters. If you wish
 22  
  * to add to the default set of converters you cannot use this class. Instead,
 23  
  * you must create an instance of <code>Converter</code> and add the converters
 24  
  * there.
 25  
  *
 26  
  * @author Stephen Colebourne
 27  
  * @version $Id: ConvertUtils.java 155441 2005-02-26 13:19:22Z dirkv $
 28  
  * @since 1.0
 29  
  */
 30  
 public class ConvertUtils {
 31  
 
 32  
     /** The default Converter, private to prevent subclasses altering the default */
 33  0
     private static final Converter DEFAULT = new Converter(true);
 34  
 
 35  
     /**
 36  
      * Restricted constructor.
 37  
      * The main access to this class is via static methods, and it is not intended
 38  
      * to be subclassed.
 39  
      */
 40  
     protected ConvertUtils() {
 41  0
         super();
 42  0
     }
 43  
 
 44  
     //-----------------------------------------------------------------------
 45  
     /**
 46  
      * Convert the specified input object into an output object
 47  
      * of the another type.
 48  
      *
 49  
      * @param value  the input value to be converted
 50  
      * @param fromClass  the class to convert from, useful if null passed in
 51  
      * @param toClass  the class to convert to
 52  
      * @return the converted value
 53  
      * @throws ConversionException (runtime) if conversion fails
 54  
      */
 55  
     public static Object convert(Object value, Class fromClass, Class toClass) {
 56  0
         return DEFAULT.convert(value, fromClass, toClass);
 57  
     }
 58  
 
 59  
     /**
 60  
      * Convert the specified input object into an output object
 61  
      * of the another type.
 62  
      *
 63  
      * @param value  the input value to be converted
 64  
      * @param toClass  the class to convert to
 65  
      * @return the converted value
 66  
      * @throws ConversionException (runtime) if conversion fails
 67  
      */
 68  
     public static Object convert(Object value, Class toClass) {
 69  0
         return DEFAULT.convert(value, toClass);
 70  
     }
 71  
 
 72  
     /**
 73  
      * Convert the specified input object into a <code>String</code>.
 74  
      *
 75  
      * @param value  the input value to be converted
 76  
      * @param fromClass  the class to convert from, useful if null passed in
 77  
      * @return the converted value
 78  
      * @throws ConversionException (runtime) if conversion fails
 79  
      */
 80  
     public static String convertToString(Object value, Class fromClass) {
 81  0
         return DEFAULT.convertToString(value, fromClass);
 82  
     }
 83  
 
 84  
     /**
 85  
      * Convert the specified input object into a <code>String</code>.
 86  
      *
 87  
      * @param value  the input value to be converted
 88  
      * @return the converted value
 89  
      * @throws ConversionException (runtime) if conversion fails
 90  
      */
 91  
     public static String convertToString(Object value) {
 92  0
         return DEFAULT.convertToString(value);
 93  
     }
 94  
 
 95  
 }