class JavaScriptUtils {

  public static Object convertFromJs( Object value, int type, String fieldName ) throws HopValueException {
    String classType = value.getClass().getName();
    switch ( type ) {
      case IValueMeta.TYPE_NUMBER:
        return jsToNumber( value, classType );

      case IValueMeta.TYPE_INTEGER:
        return jsToInteger( value, value.getClass() );

      case IValueMeta.TYPE_STRING:
        return jsToString( value, classType );

      case IValueMeta.TYPE_DATE:
        return jsToDate( value, classType );

      case IValueMeta.TYPE_BOOLEAN:
        return value;

      case IValueMeta.TYPE_BIGNUMBER:
        return jsToBigNumber( value, classType );

      case IValueMeta.TYPE_BINARY: {
        return Context.jsToJava( value, byte[].class );
      }
      case IValueMeta.TYPE_NONE: {
        throw new RuntimeException( "No data output data type was specified for new field ["
          + fieldName + "]" );
      }
      default:
        return Context.jsToJava( value, Object.class );
    }
  }

}