Package org.jboss.resteasy.util
Class TypeConverter
- java.lang.Object
 - 
- org.jboss.resteasy.util.TypeConverter
 
 
- 
public final class TypeConverter extends Object
A utility class that can convert a String value as a typed object.- Version:
 - $Revision: $
 - Author:
 - Ryan J. McDonough
 
 
- 
- 
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static BooleangetBooleanValue(String source)Returns a Boolean value from a String.static <T> TgetType(Class<T> targetType, String source)A generic method that returns theStringas the specified Java type.static <T> TgetTypeViaValueOfMethod(String source, Class<T> targetType)static booleanisConvertable(Class<?> targetType)Tests if the class can safely be converted from a String to the specified type. 
 - 
 
- 
- 
Method Detail
- 
getType
public static <T> T getType(Class<T> targetType, String source)
A generic method that returns theStringas the specified Java type.- Type Parameters:
 T- the type to return- Parameters:
 source- the string value to converttargetType- target type- Returns:
 - the object instance
 
 
- 
isConvertable
public static boolean isConvertable(Class<?> targetType)
Tests if the class can safely be converted from a String to the specified type.- Parameters:
 targetType- the type to convert to- Returns:
 - true if the class possesses either a "valueOf()" method or a constructor with a String parameter.
 
 
- 
getBooleanValue
public static Boolean getBooleanValue(String source)
Returns a Boolean value from a String. Unlike
Boolean.valueOf(String), this method takes more String options. The following String values will return true:- Yes
 - Y
 - T
 - 1
 
While the following values will return false:
- No
 - N
 - F
 - 0
 
- Parameters:
 source- source string- Returns:
 - boolean value from string
 
 
- 
getTypeViaValueOfMethod
public static <T> T getTypeViaValueOfMethod(String source, Class<T> targetType) throws NoSuchMethodException
- Type Parameters:
 T- type- Parameters:
 source- source stringtargetType- target type- Returns:
 - object instance of type T
 - Throws:
 NoSuchMethodException- if method was not found
 
 - 
 
 -