public static Number coerceToPrimitiveNumber ( Object pValue , Class pClass , Logger pLogger ) throws ELException { if ( pValue == null || "" . equals ( pValue ) ) { return coerceToPrimitiveNumber ( 0 , pClass ) ; } else if ( pValue instanceof Character ) { char val = ( ( Character ) pValue ) . charValue ( ) ; return coerceToPrimitiveNumber ( ( short ) val , pClass ) ; } else if ( pValue instanceof Boolean ) { if ( pLogger . isLoggingError ( ) ) { pLogger . logError ( Constants . BOOLEAN_TO_NUMBER , pValue , pClass . getName ( ) ) ; } return coerceToPrimitiveNumber ( 0 , pClass ) ; } else if ( pValue . getClass ( ) == pClass ) { return ( Number ) pValue ; } else if ( pValue instanceof Number ) { return coerceToPrimitiveNumber ( ( Number ) pValue , pClass ) ; } else if ( pValue instanceof String ) { try { return coerceToPrimitiveNumber ( ( String ) pValue , pClass ) ; } catch ( Exception exc ) { if ( pLogger . isLoggingError ( ) ) { pLogger . logError ( Constants . STRING_TO_NUMBER_EXCEPTION , ( String ) pValue , pClass . getName ( ) ) ; } return coerceToPrimitiveNumber ( 0 , pClass ) ; } } else { if ( pLogger . isLoggingError ( ) ) { pLogger . logError ( Constants . COERCE_TO_NUMBER , pValue . getClass ( ) . getName ( ) , pClass . getName ( ) ) ; } return coerceToPrimitiveNumber ( 0 , pClass ) ; } }
Coerces a value to the given primitive number class