org.apache.click.util
Class RequestTypeConverter

java.lang.Object
  extended by org.apache.click.util.RequestTypeConverter
All Implemented Interfaces:
ognl.TypeConverter

public class RequestTypeConverter
extends Object
implements ognl.TypeConverter

Provides an request parameter OGNL TypeConverter class.

This class is adapted from the OGNL DefaultTypeConverter, by Luke Blanshard and Drew Davidson, and provides additional Date conversion capabilities.


Constructor Summary
RequestTypeConverter()
           
 
Method Summary
 Object convertValue(Map context, Object target, Member member, String propertyName, Object value, Class toType)
          Converts the given value to a given type.
protected  Object convertValue(Object value, Class<?> toType)
          Return the converted value for the given value object and target type.
protected  Date createDateFromSqlString(String value)
          Return a new date object from the give SQL format date string, or null if the value is invalid.
protected  long getTimeFromDateString(String value)
          Return the time value in milliseconds of the given date value string, or Long.MIN_VALUE if the date could not be determined.
protected  boolean isTimeValue(String value)
          Return true if the given string value is a long time value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RequestTypeConverter

public RequestTypeConverter()
Method Detail

convertValue

public Object convertValue(Map context,
                           Object target,
                           Member member,
                           String propertyName,
                           Object value,
                           Class toType)
Converts the given value to a given type. The OGNL context, target, member and name of property being set are given. This method should be able to handle conversion in general without any context, target, member or property name specified.

Specified by:
convertValue in interface ognl.TypeConverter
Parameters:
context - OGNL context under which the conversion is being done
target - target object in which the property is being set
member - member (Constructor, Method or Field) being set
propertyName - property name being set
value - value to be converted
toType - type to which value is converted
Returns:
Converted value of type toType or TypeConverter.NoConversionPossible to indicate that the conversion was not possible.

convertValue

protected Object convertValue(Object value,
                              Class<?> toType)
Return the converted value for the given value object and target type.

Parameters:
value - the value object to convert
toType - the target class type to convert the value to
Returns:
a converted value into the specified type

getTimeFromDateString

protected long getTimeFromDateString(String value)
Return the time value in milliseconds of the given date value string, or Long.MIN_VALUE if the date could not be determined.

Parameters:
value - the date value string
Returns:
the time value in milliseconds or Long.MIN_VALUE if not determined

isTimeValue

protected boolean isTimeValue(String value)
Return true if the given string value is a long time value.

Parameters:
value - the string value to test
Returns:
true if the given string value is a long time value.

createDateFromSqlString

protected Date createDateFromSqlString(String value)
Return a new date object from the give SQL format date string, or null if the value is invalid.

Parameters:
value - the SQL format date string
Returns:
a new date object from the give SQL format date string