Source:
<code>public static BigDecimal toBigDecimal( Object source ) throws BirtException { if ( source == null ) return null; if ( source instanceof BigDecimal ) { return (BigDecimal) source; } else if ( source instanceof Number ) { if ( source instanceof Double && ( ( (Double) source ).isInfinite( ) || ( (Double) source ).isNaN( ) ) ) return null; else if ( source instanceof Float && ( ( (Float) source ).isInfinite( ) || ( (Float) source ).isNaN( ) ) ) return null; String str = ( (Number) source ).toString( ); try { return new BigDecimal( str ); } catch ( NumberFormatException e ) { throw new CoreException( ResourceConstants.CONVERT_FAILS, new Object[]{ str, "BigDecimal" } ); } } else if ( source instanceof Boolean ) { if ( true == ( (Boolean) source ).booleanValue( ) ) return BigDecimal.ONE; return BigDecimal.ZERO; } else if ( source instanceof Date ) { long longValue = ( (Date) source ).getTime( ); return new BigDecimal( longValue ); } <START> else if ( source instanceof String || source instanceof ConsString ) <END> { source = ( source instanceof ConsString )?source.toString( ):source; if( ( (String) source ).length( )==0 ) { return null; } try { return new BigDecimal( (String) source ); } catch ( NumberFormatException e ) { try { Number number = NumberFormat.getInstance( JRE_DEFAULT_LOCALE ) .parse( (String) source ); if( number != null ) return new BigDecimal( number.toString( ) ); throw new CoreException( ResourceConstants.CONVERT_FAILS, new Object[]{ source.toString( ), "BigDecimal" } ); } catch ( ParseException e1 ) { throw new CoreException( ResourceConstants.CONVERT_FAILS, new Object[]{ source.toString( ), "BigDecimal" } ); } } } else { throw new CoreException( ResourceConstants.CONVERT_FAILS, new Object[]{ source.toString( ), "BigDecimal" } ); } }</code><technical_language>Instead of checking a concrete class ConsString tied Rhino implementation, check a common class instead: if ( source instanceof CharSequence)</technical_language>

Target:
public static BigDecimal toBigDecimal( Object source ) throws BirtException { if ( source == null ) return null; if ( source instanceof BigDecimal ) { return (BigDecimal) source; } else if ( source instanceof Number ) { if ( source instanceof Double && ( ( (Double) source ).isInfinite( ) || ( (Double) source ).isNaN( ) ) ) return null; else if ( source instanceof Float && ( ( (Float) source ).isInfinite( ) || ( (Float) source ).isNaN( ) ) ) return null; String str = ( (Number) source ).toString( ); try { return new BigDecimal( str ); } catch ( NumberFormatException e ) { throw new CoreException( ResourceConstants.CONVERT_FAILS, new Object[]{ str, "BigDecimal" } ); } } else if ( source instanceof Boolean ) { if ( true == ( (Boolean) source ).booleanValue( ) ) return BigDecimal.ONE; return BigDecimal.ZERO; } else if ( source instanceof Date ) { long longValue = ( (Date) source ).getTime( ); return new BigDecimal( longValue ); } else if ( source instanceof CharSequence ) { source = source.toString( ); if( ( (String) source ).length( )==0 ) { return null; } try { return new BigDecimal( (String) source ); } catch ( NumberFormatException e ) { try { Number number = NumberFormat.getInstance( JRE_DEFAULT_LOCALE ) .parse( (String) source ); if( number != null ) return new BigDecimal( number.toString( ) ); throw new CoreException( ResourceConstants.CONVERT_FAILS, new Object[]{ source.toString( ), "BigDecimal" } ); } catch ( ParseException e1 ) { throw new CoreException( ResourceConstants.CONVERT_FAILS, new Object[]{ source.toString( ), "BigDecimal" } ); } } } else { throw new CoreException( ResourceConstants.CONVERT_FAILS, new Object[]{ source.toString( ), "BigDecimal" } ); } }