public Object getAsObject(FacesContext context, UIComponent component,
                              String value) {

        if (context == null || component == null) {
            throw new NullPointerException();
        }

        Object returnValue = null;
        NumberFormat parser = null;

        try {

            // If the specified value is null or zero-length, return null
            if (value == null) {
                return (null);
            }
            value = value.trim();
            if (value.length() < 1) {
                return (null);
            }

            // Identify the Locale to use for parsing
            Locale locale = getLocale(context);

            // Create and configure the parser to be used
            parser = getNumberFormat(locale);
            if (((pattern != null) && pattern.length() != 0)
                 || "currency".equals(type)) {
                configureCurrency(parser);
            }
            parser.setParseIntegerOnly(isIntegerOnly());
            boolean groupSepChanged = false;
            // BEGIN HACK 4510618
            // This lovely bit of code is for a workaround in some
            // oddities in the JDK's parsing code.
            // See:  http://bugs.sun.com/view_bug.do?bug_id=4510618
            if (parser instanceof DecimalFormat) {
                DecimalFormat dParser = (DecimalFormat) parser;

                // Take a small hit in performance to avoid a loss in
                // precision due to DecimalFormat.parse() returning Double
                ValueExpression ve = component.getValueExpression("value");
                if (ve != null) {
                    Class<?> expectedType = ve.getType(context.getELContext());
                    if (expectedType != null && expectedType.isAssignableFrom(BigDecimal.class)) {
                        dParser.setParseBigDecimal(true);
                    }
                }
                DecimalFormatSymbols symbols =
                      dParser.getDecimalFormatSymbols();
                if (symbols.getGroupingSeparator() == '\u00a0') {
                    groupSepChanged = true;
                    String tValue;
                    if (value.contains(NBSP)) {
                        tValue = value.replace('\u00a0', ' ');
                    } else {
                        tValue = value;
                    }
                    symbols.setGroupingSeparator(' ');
                    dParser.setDecimalFormatSymbols(symbols);
                    try {
                        return dParser.parse(tValue);
                    } catch (ParseException pe) {
                        if (groupSepChanged) {
                            symbols.setGroupingSeparator('\u00a0');
                            dParser.setDecimalFormatSymbols(symbols);
                        }
                    }
                }
            }
            // END HACK 4510618

            // Perform the requested parsing
            returnValue = parser.parse(value);
        } catch (ParseException e) {
            if (pattern != null) {
                throw new ConverterException(MessageFactory.getMessage(
                     context, PATTERN_ID, value, "#,##0.0#",
                     MessageFactory.getLabel(context, component)), e);
            } else if (type.equals("currency")) {
                throw new ConverterException(MessageFactory.getMessage(
                     context, CURRENCY_ID, value,
                     parser.format(99.99),
                     MessageFactory.getLabel(context, component)), e);
            } else if (type.equals("number")) {
                throw new ConverterException(MessageFactory.getMessage(
                     context, NUMBER_ID, value,
                     parser.format(99),
                     MessageFactory.getLabel(context, component)), e);
            } else if (type.equals("percent")) {
                throw new ConverterException(MessageFactory.getMessage(
                     context, PERCENT_ID, value,
                     parser.format(.75),
                     MessageFactory.getLabel(context, component)), e);
            }
        } catch (Exception e) {
            throw new ConverterException(e);
        }
        return returnValue;
    }
public Object getAsObject ( FacesContext context , UIComponent component , String value ) { if ( context == null || component == null ) { throw new NullPointerException ( ) ; } Object returnValue = null ; NumberFormat parser = null ; try { if ( value == null ) { return ( null ) ; } value = value . trim ( ) ; if ( value . length ( ) < 1 ) { return ( null ) ; } Locale locale = getLocale ( context ) ; parser = getNumberFormat ( locale ) ; if ( ( ( pattern != null ) && pattern . length ( ) != 0 ) || "currency" . equals ( type ) ) { configureCurrency ( parser ) ; } parser . setParseIntegerOnly ( isIntegerOnly ( ) ) ; boolean groupSepChanged = false ; if ( parser instanceof DecimalFormat ) { DecimalFormat dParser = ( DecimalFormat ) parser ; ValueExpression ve = component . getValueExpression ( "value" ) ; if ( ve != null ) { Class < ? > expectedType = ve . getType ( context . getELContext ( ) ) ; if ( expectedType != null && expectedType . isAssignableFrom ( BigDecimal . class ) ) { dParser . setParseBigDecimal ( true ) ; } } DecimalFormatSymbols symbols = dParser . getDecimalFormatSymbols ( ) ; if ( symbols . getGroupingSeparator ( ) == ' ' ) { groupSepChanged = true ; String tValue ; if ( value . contains ( NBSP ) ) { tValue = value . replace ( ' ' , ' ' ) ; } else { tValue = value ; } symbols . setGroupingSeparator ( ' ' ) ; dParser . setDecimalFormatSymbols ( symbols ) ; try { return dParser . parse ( tValue ) ; } catch ( ParseException pe ) { if ( groupSepChanged ) { symbols . setGroupingSeparator ( ' ' ) ; dParser . setDecimalFormatSymbols ( symbols ) ; } } } } returnValue = parser . parse ( value ) ; } catch ( ParseException e ) { if ( pattern != null ) { throw new ConverterException ( MessageFactory . getMessage ( context , PATTERN_ID , value , "#,##0.0#" , MessageFactory . getLabel ( context , component ) ) , e ) ; } else if ( type . equals ( "currency" ) ) { throw new ConverterException ( MessageFactory . getMessage ( context , CURRENCY_ID , value , parser . format ( 99.99 ) , MessageFactory . getLabel ( context , component ) ) , e ) ; } else if ( type . equals ( "number" ) ) { throw new ConverterException ( MessageFactory . getMessage ( context , NUMBER_ID , value , parser . format ( 99 ) , MessageFactory . getLabel ( context , component ) ) , e ) ; } else if ( type . equals ( "percent" ) ) { throw new ConverterException ( MessageFactory . getMessage ( context , PERCENT_ID , value , parser . format ( .75 ) , MessageFactory . getLabel ( context , component ) ) , e ) ; } } catch ( Exception e ) { throw new ConverterException ( e ) ; } return returnValue ; }
@throws ConverterException   {@inheritDoc}
@throws NullPointerException {@inheritDoc}