org.apache.commons.convert
Class ConvertUtils

java.lang.Object
  extended by org.apache.commons.convert.ConvertUtils

public class ConvertUtils
extends Object

Simple public API for the conversion system consisting of static methods.

The methods on this class access the default range of converters. If you wish to add to the default set of converters you cannot use this class. Instead, you must create an instance of Converter and add the converters there.

Since:
1.0
Version:
$Id: ConvertUtils.java 155441 2005-02-26 13:19:22Z dirkv $
Author:
Stephen Colebourne

Constructor Summary
protected ConvertUtils()
          Restricted constructor.
 
Method Summary
static Object convert(Object value, Class toClass)
          Convert the specified input object into an output object of the another type.
static Object convert(Object value, Class fromClass, Class toClass)
          Convert the specified input object into an output object of the another type.
static String convertToString(Object value)
          Convert the specified input object into a String.
static String convertToString(Object value, Class fromClass)
          Convert the specified input object into a String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConvertUtils

protected ConvertUtils()
Restricted constructor. The main access to this class is via static methods, and it is not intended to be subclassed.

Method Detail

convert

public static Object convert(Object value,
                             Class fromClass,
                             Class toClass)
Convert the specified input object into an output object of the another type.

Parameters:
value - the input value to be converted
fromClass - the class to convert from, useful if null passed in
toClass - the class to convert to
Returns:
the converted value
Throws:
ConversionException - (runtime) if conversion fails

convert

public static Object convert(Object value,
                             Class toClass)
Convert the specified input object into an output object of the another type.

Parameters:
value - the input value to be converted
toClass - the class to convert to
Returns:
the converted value
Throws:
ConversionException - (runtime) if conversion fails

convertToString

public static String convertToString(Object value,
                                     Class fromClass)
Convert the specified input object into a String.

Parameters:
value - the input value to be converted
fromClass - the class to convert from, useful if null passed in
Returns:
the converted value
Throws:
ConversionException - (runtime) if conversion fails

convertToString

public static String convertToString(Object value)
Convert the specified input object into a String.

Parameters:
value - the input value to be converted
Returns:
the converted value
Throws:
ConversionException - (runtime) if conversion fails


Copyright © 2003-2010 The Apache Software Foundation. All Rights Reserved.