public static Long jsToInteger( Object value, Class<?> clazz ) {
    if ( Number.class.isAssignableFrom( clazz ) ) {
      return ( (Number) value ).longValue();
    } else {
      String classType = clazz.getName();
      if ( classType.equalsIgnoreCase( "java.lang.String" ) ) {
        return ( new Long( (String) value ) );
      } else if ( classType.equalsIgnoreCase( JS_UNDEFINED ) ) {
        return null;
      } else if ( classType.equalsIgnoreCase( JS_NATIVE_NUM ) ) {
        Number nb = Context.toNumber( value );
        return nb.longValue();
      } else if ( classType.equalsIgnoreCase( JS_NATIVE_JAVA_OBJ ) ) {
        // Is it a Value?
        //
        try {
          Value v = (Value) Context.jsToJava( value, Value.class );
          return v.getInteger();
        } catch ( Exception e2 ) {
          String string = Context.toString( value );
          return Long.parseLong( Const.trim( string ) );
        }
      } else {
        return Long.parseLong( value.toString() );
      }
    }
  }
@Test
  public void jsToInteger_String() throws Exception {
    assertEquals( LONG_ONE, JavaScriptUtils.jsToInteger( "1", String.class ) );
  }