org.mozilla.javascript.Context.getElements()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 JavaScript  
字(3.3k)|赞(0)|评价(0)|浏览(123)

本文整理了Java中org.mozilla.javascript.Context.getElements()方法的一些代码示例,展示了Context.getElements()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Context.getElements()方法的具体详情如下:
包路径:org.mozilla.javascript.Context
类名称:Context
方法名:getElements

Context.getElements介绍

[英]Get the elements of a JavaScript array.

If the object defines a length property convertible to double number, then the number is converted Uint32 value as defined in Ecma 9.6 and Java array of that size is allocated. The array is initialized with the values obtained by calling get() on object for each value of i in [0,length-1]. If there is not a defined value for a property the Undefined value is used to initialize the corresponding element in the array. The Java array is then returned. If the object doesn't define a length property or it is not a number, empty array is returned.
[中]获取JavaScript数组的元素。
如果对象定义了一个可转换为双倍数字的长度属性,则该数字将转换为Ecma 9.6中定义的Uint32值,并分配该大小的Java数组。对于[0,length-1]中i的每个值,使用通过调用对象上的get()获得的值初始化数组。如果属性没有定义值,则使用未定义的值初始化数组中的相应元素。然后返回Java数组。如果对象未定义长度属性或不是数字,则返回空数组。

代码示例

代码示例来源:origin: rhino/js

static Object[] getApplyArguments(Context cx, Object arg1)
{
  if (arg1 == null || arg1 == Undefined.instance) {
    return ScriptRuntime.emptyArgs;
  } else if (arg1 instanceof NativeArray || arg1 instanceof Arguments) {
    return cx.getElements((Scriptable) arg1);
  } else {
    throw ScriptRuntime.typeError0("msg.arg.isnt.array");
  }
}

代码示例来源:origin: geogebra/geogebra

static Object[] getApplyArguments(Context cx, Object arg1)
{
  if (arg1 == null || arg1 == Undefined.instance) {
    return ScriptRuntime.emptyArgs;
  } else if (arg1 instanceof NativeArray || arg1 instanceof Arguments) {
    return cx.getElements((Scriptable) arg1);
  } else {
    throw ScriptRuntime.typeError0("msg.arg.isnt.array");
  }
}

代码示例来源:origin: com.github.tntim96/rhino

static Object[] getApplyArguments(Context cx, Object arg1)
{
  if (arg1 == null || arg1 == Undefined.instance) {
    return ScriptRuntime.emptyArgs;
  } else if (arg1 instanceof NativeArray || arg1 instanceof Arguments) {
    return cx.getElements((Scriptable) arg1);
  } else {
    throw ScriptRuntime.typeError0("msg.arg.isnt.array");
  }
}

代码示例来源:origin: ro.isdc.wro4j/rhino

static Object[] getApplyArguments(Context cx, Object arg1)
{
  if (arg1 == null || arg1 == Undefined.instance) {
    return ScriptRuntime.emptyArgs;
  } else if (arg1 instanceof NativeArray || arg1 instanceof Arguments) {
    return cx.getElements((Scriptable) arg1);
  } else {
    throw ScriptRuntime.typeError0("msg.arg.isnt.array");
  }
}

代码示例来源:origin: io.apigee/rhino

static Object[] getApplyArguments(Context cx, Object arg1)
{
  if (arg1 == null || arg1 == Undefined.instance) {
    return ScriptRuntime.emptyArgs;
  } else if (arg1 instanceof NativeArray || arg1 instanceof Arguments) {
    return cx.getElements((Scriptable) arg1);
  } else {
    throw ScriptRuntime.typeError0("msg.arg.isnt.array");
  }
}

代码示例来源:origin: com.github.tntim96/rhino

Object[] newArgs = null;
if (args.length > 1 && args[1] instanceof Scriptable) {
  newArgs = cx.getElements((Scriptable) args[1]);

代码示例来源:origin: ro.isdc.wro4j/rhino

Object[] newArgs = null;
if (args.length > 1 && args[1] instanceof Scriptable) {
  newArgs = cx.getElements((Scriptable) args[1]);

代码示例来源:origin: com.sun.phobos/phobos-rhino

|| arg1 instanceof Arguments)
  callArgs = cx.getElements((Scriptable) arg1);
} else {
  throw ScriptRuntime.typeError0("msg.arg.isnt.array");

代码示例来源:origin: com.github.tntim96/rhino

Scriptable s = Context.toObject(addArgsObj,
                getTopLevelScope(thisObj));
addArgs = cx.getElements(s);

代码示例来源:origin: ro.isdc.wro4j/rhino

Scriptable s = Context.toObject(addArgsObj,
                getTopLevelScope(thisObj));
addArgs = cx.getElements(s);

相关文章

微信公众号

Context类方法