public static BigDecimal jsToBigNumber( Object value, String classType ) {
    if ( classType.equalsIgnoreCase( JS_UNDEFINED ) ) {
      return null;
    } else if ( classType.equalsIgnoreCase( JS_NATIVE_NUM ) ) {
      Number nb = Context.toNumber( value );
      return BigDecimal.valueOf( nb.doubleValue() );
    } else if ( classType.equalsIgnoreCase( JS_NATIVE_JAVA_OBJ ) ) {
      // Is it a BigDecimal class ?
      return convertNativeJavaToBigDecimal( value );
    } else if ( classType.equalsIgnoreCase( "java.lang.Byte" ) ) {
      return BigDecimal.valueOf( ( (Byte) value ).longValue() );
    } else if ( classType.equalsIgnoreCase( "java.lang.Short" ) ) {
      return BigDecimal.valueOf( ( (Short) value ).longValue() );
    } else if ( classType.equalsIgnoreCase( "java.lang.Integer" ) ) {
      return BigDecimal.valueOf( ( (Integer) value ).longValue() );
    } else if ( classType.equalsIgnoreCase( "java.lang.Long" ) ) {
      return BigDecimal.valueOf( ( (Long) value ).longValue() );
    } else if ( classType.equalsIgnoreCase( "java.lang.Double" ) ) {
      return BigDecimal.valueOf( ( (Double) value ).doubleValue() );
    } else if ( classType.equalsIgnoreCase( "java.lang.String" ) ) {
      return BigDecimal.valueOf( ( new Long( (String) value ) ).longValue() );
    } else {
      throw new UnsupportedOperationException( "JavaScript conversion to BigNumber not implemented for " + classType );
    }
  }
@Test
  public void jsToBigNumber_NaturalNumbers() throws Exception {
    Number[] naturalNumbers = new Number[] { (byte) 1, (short) 1, 1, (long) 1 };

    for ( Number number : naturalNumbers ) {
      assertEquals( BigDecimal.ONE, JavaScriptUtils.jsToBigNumber( number, number.getClass().getName() ) );
    }
  }