Class TypeConverter
java.lang.Object
org.jboss.resteasy.util.TypeConverter
A utility class that can convert a String value as a typed object.
- Version:
- $Revision: $
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic BooleangetBooleanValue(String source) Returns a Boolean value from a String.static <T> TA generic method that returns theStringas the specified Java type.private static <T> TgetTypeViaStringConstructor(String source, Class<T> targetType) 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.
-
Field Details
-
VALUE_OF_METHOD
- See Also:
-
PRIMITIVES
-
-
Constructor Details
-
TypeConverter
private TypeConverter()
-
-
Method Details
-
getType
-
isConvertable
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
Returns a Boolean value from a String. Unlike
}, this method takes more String options. The following String values will return true:invalid @link
{@link Boolean.#valueOf(String)- Yes
- Y
- T
- 1
While the following values will return false:
- No
- N
- F
- 0
- Parameters:
source-- Returns:
-
getTypeViaValueOfMethod
public static <T> T getTypeViaValueOfMethod(String source, Class<T> targetType) throws NoSuchMethodException - Type Parameters:
T-- Parameters:
source-targetType-- Returns:
- Throws:
NoSuchMethodException
-
getTypeViaStringConstructor
- Type Parameters:
T-- Parameters:
source-targetType-- Returns:
- Throws:
IllegalArgumentExceptionInstantiationExceptionIllegalAccessExceptionInvocationTargetException
-