private Object getParameter ( String name , String value ) throws ParseException , NumberFormatException { Object result = null ; if ( name . length ( ) > 0 ) { switch ( name . charAt ( 0 ) ) { case ' ' : if ( null == value || value . length ( ) == 0 ) { value = "0" ; } result = new Integer ( value ) ; break ; case ' ' : if ( name . startsWith ( "form" ) ) { result = value ; } else { if ( null == value || value . length ( ) == 0 ) { value = "0.0" ; } result = new Double ( value ) ; } break ; case ' ' : if ( null == value || value . length ( ) == 0 ) { result = null ; } else { SimpleDateFormat dateParser = new SimpleDateFormat ( "yyyy-MM-dd" ) ; result = dateParser . parse ( value ) ; } break ; case ' ' : if ( null == value || value . length ( ) == 0 ) { result = null ; } else { SimpleDateFormat timeParser = new SimpleDateFormat ( "yyyy-MM-dd HH:mm:ss" ) ; result = timeParser . parse ( value ) ; } break ; case ' ' : result = "true" . equalsIgnoreCase ( value ) ? Boolean . TRUE : Boolean . FALSE ; break ; default : result = value ; } if ( log . isDebugEnabled ( ) ) { if ( result != null ) { log . debug ( "parameter " + name + " value " + result + " class " + result . getClass ( ) . getName ( ) ) ; } else { log . debug ( "parameter" + name + "is null" ) ; } } } return result ; }
Convert a query parameter to the correct object type based on the first letter of the name .