org.apache.commons.beanutils.converters
Class ClassConverter

java.lang.Object
  |
  +--org.apache.commons.beanutils.converters.ClassConverter
All Implemented Interfaces:
Converter

public final class ClassConverter
extends java.lang.Object
implements Converter

Standard Converter implementation that converts an incoming String into a java.lang.Class object, optionally using a default value or throwing a ConversionException if a conversion error occurs. The class will be loaded from the thread context class loader (if it exists); otherwise the class loader that loaded this class will be used.

Since:
1.4
Version:
$Revision: 1.6 $ $Date: 2004/02/28 13:18:34 $
Author:
Tomas Viberg

Field Summary
private  java.lang.Object defaultValue
          The default value specified to our Constructor, if any.
private  boolean useDefault
          Should we return the default value on conversion errors?
 
Constructor Summary
ClassConverter()
          Create a Converter that will throw a ConversionException if a conversion error occurs.
ClassConverter(java.lang.Object defaultValue)
          Create a Converter that will return the specified default value if a conversion error occurs.
 
Method Summary
 java.lang.Object convert(java.lang.Class type, java.lang.Object value)
          Convert the specified input object into an output object of the specified type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

defaultValue

private java.lang.Object defaultValue
The default value specified to our Constructor, if any.


useDefault

private boolean useDefault
Should we return the default value on conversion errors?

Constructor Detail

ClassConverter

public ClassConverter()
Create a Converter that will throw a ConversionException if a conversion error occurs.


ClassConverter

public ClassConverter(java.lang.Object defaultValue)
Create a Converter that will return the specified default value if a conversion error occurs.

Parameters:
defaultValue - The default value to be returned
Method Detail

convert

public java.lang.Object convert(java.lang.Class type,
                                java.lang.Object value)
Convert the specified input object into an output object of the specified type.

Specified by:
convert in interface Converter
Parameters:
type - Data type to which this value should be converted
value - The input value to be converted
Throws:
ConversionException - if conversion cannot be performed successfully


Copyright (c) 2001-2004 - Apache Software Foundation