Humboldt Alignment Editor 2.5.0

eu.esdihumboldt.hale.common.convert
Class ConversionUtil

java.lang.Object
  extended by eu.esdihumboldt.hale.common.convert.ConversionUtil

public abstract class ConversionUtil
extends Object

Conversion utilities.

Author:
Simon Templer

Constructor Summary
ConversionUtil()
           
 
Method Summary
static
<T> T
getAs(Object value, Class<T> targetType)
          Convert a given value to the given target type.
static
<T> List<T>
getAsList(Object value, Class<T> targetType, boolean flatten)
          Convert a given value to a collection of target type values.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConversionUtil

public ConversionUtil()
Method Detail

getAs

public static <T> T getAs(Object value,
                          Class<T> targetType)
               throws org.springframework.core.convert.ConversionException
Convert a given value to the given target type.

Parameters:
value - the value to convert
targetType - the target type
Returns:
the converted value
Throws:
org.springframework.core.convert.ConversionException - if the conversion failed

getAsList

public static <T> List<T> getAsList(Object value,
                                    Class<T> targetType,
                                    boolean flatten)
                         throws org.springframework.core.convert.ConversionException
Convert a given value to a collection of target type values.

Parameters:
value - the value to convert
targetType - the target element type
flatten - if the collection shall be flattened, i.e. if it in turn contains a collection instead the converted values are added
Returns:
the collection of converted values, an empty list if the value was null or an empty collection
Throws:
org.springframework.core.convert.ConversionException - if the conversion fails

Humboldt Alignment Editor 2.5.0

Build 2012-12-03_12-30-59
Revision 9d2dd4b0318cda9f1393b1ddd390f7f792d70a2d