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

x33g5p2x  于2022-01-30 转载在 JavaScript  
字(6.6k)|赞(0)|评价(0)|浏览(174)

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

ScriptableObject.getProperty介绍

[英]Gets an indexed property from an object or any object in its prototype chain.

Searches the prototype chain for a property with integral index index. Note that if you wish to look for properties with numerical but non-integral indicies, you should use getProperty(Scriptable,String) with the string value of the index.
[中]从对象或其原型链中的任何对象获取索引属性。
在原型链中搜索整型索引为index的属性。请注意,如果希望查找带有数字但非整数标记的属性,则应使用带有索引字符串值的getProperty(可编写脚本,字符串)。

代码示例

代码示例来源:origin: org.freemarker/freemarker

public TemplateCollectionModel values() throws TemplateModelException {
  Object[] ids = scriptable.getIds();
  Object[] values = new Object[ids.length];
  for (int i = 0; i < values.length; i++) {
    Object id = ids[i];
    if (id instanceof Number) {
      values[i] = ScriptableObject.getProperty(scriptable, 
          ((Number) id).intValue());
    } else {
      values[i] = ScriptableObject.getProperty(scriptable, 
          String.valueOf(id)); 
    }
  }
  return (TemplateCollectionModel) wrapper.wrap(values);
}

代码示例来源:origin: org.freemarker/freemarker

public TemplateModel get(int index) throws TemplateModelException {
  Object retval = ScriptableObject.getProperty(scriptable, index);
  if (retval instanceof Function) {
    return new RhinoFunctionModel((Function) retval, scriptable, wrapper);
  } else {
    return wrapper.wrap(retval);
  }
}

代码示例来源:origin: org.freemarker/freemarker

public TemplateModel get(String key) throws TemplateModelException {
  Object retval = ScriptableObject.getProperty(scriptable, key);
  if (retval instanceof Function) {
    return new RhinoFunctionModel((Function) retval, scriptable, wrapper);
  } else {
    return wrapper.wrap(retval);
  }
}

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

public static Object getObjectIndex(Scriptable obj, int index,
                  Context cx)
{
  Object result = ScriptableObject.getProperty(obj, index);
  if (result == Scriptable.NOT_FOUND) {
    result = Undefined.instance;
  }
  return result;
}

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

public static Object getObjectIndex(Scriptable obj, int index,
                  Context cx)
{
  Object result = ScriptableObject.getProperty(obj, index);
  if (result == Scriptable.NOT_FOUND) {
    result = Undefined.instance;
  }
  return result;
}

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

private static Object getRawElem(Scriptable target, long index) {
  if (index > Integer.MAX_VALUE) {
    return ScriptableObject.getProperty(target, Long.toString(index));
  } else {
    return ScriptableObject.getProperty(target, (int)index);
  }
}

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

private static Object getRawElem(Scriptable target, long index) {
  if (index > Integer.MAX_VALUE) {
    return ScriptableObject.getProperty(target, Long.toString(index));
  } else {
    return ScriptableObject.getProperty(target, (int)index);
  }
}

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

private static Object topScopeName(Context cx, Scriptable scope,
                  String name)
{
  if (cx.useDynamicScope) {
    scope = checkDynamicScope(cx.topCallScope, scope);
  }
  return ScriptableObject.getProperty(scope, name);
}

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

private static String getString(Scriptable obj, String id)
{
  Object value = ScriptableObject.getProperty(obj, id);
  if (value == NOT_FOUND) return "";
  return ScriptRuntime.toString(value);
}

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

private static Object topScopeName(Context cx, Scriptable scope,
                  String name)
{
  if (cx.useDynamicScope) {
    scope = checkDynamicScope(cx.topCallScope, scope);
  }
  return ScriptableObject.getProperty(scope, name);
}

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

private static Object topScopeName(Context cx, Scriptable scope,
                  String name)
{
  if (cx.useDynamicScope) {
    scope = checkDynamicScope(cx.topCallScope, scope);
  }
  return ScriptableObject.getProperty(scope, name);
}

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

public static Object getObjectIndex(Scriptable obj, int index,
                  Context cx)
{
  if (obj instanceof XMLObject) {
    XMLObject xmlObject = (XMLObject)obj;
    return xmlObject.ecmaGet(cx, new Integer(index));
  }
  Object result = ScriptableObject.getProperty(obj, index);
  if (result == Scriptable.NOT_FOUND) {
    result = Undefined.instance;
  }
  return result;
}

代码示例来源:origin: org.apache.cocoon/cocoon-expression-language-impl

public Object next() {
  Context.enter();
  try {
    Object result = ScriptableObject.getProperty(scope, ids[index++].toString());
    return unwrap(result);
  } finally {
    Context.exit();
  }
}

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

public static XMLLib extractFromScopeOrNull(Scriptable scope)
{
  ScriptableObject so = ScriptRuntime.getLibraryScopeOrNull(scope);
  if (so == null) {
    // If library is not yet initialized, return null
    return null;
  }
  // Ensure lazily initialization of real XML library instance
  // which is done on first access to XML property
  ScriptableObject.getProperty(so, "XML");
  return (XMLLib)so.getAssociatedValue(XML_LIB_KEY);
}

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

public static XMLLib extractFromScopeOrNull(Scriptable scope)
{
  ScriptableObject so = ScriptRuntime.getLibraryScopeOrNull(scope);
  if (so == null) {
    // If library is not yet initialized, return null
    return null;
  }
  // Ensure lazily initialization of real XML library instance
  // which is done on first access to XML property
  ScriptableObject.getProperty(so, "XML");
  return (XMLLib)so.getAssociatedValue(XML_LIB_KEY);
}

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

public static XMLLib extractFromScopeOrNull(Scriptable scope)
{
  ScriptableObject so = ScriptRuntime.getLibraryScopeOrNull(scope);
  if (so == null) {
    // If library is not yet initialized, return null
    return null;
  }
  // Ensure lazily initialization of real XML library instance
  // which is done on first access to XML property
  ScriptableObject.getProperty(so, "XML");
  return (XMLLib)so.getAssociatedValue(XML_LIB_KEY);
}

代码示例来源:origin: org.freemarker/freemarker-gae

public TemplateModel get(String key) throws TemplateModelException {
  Object retval = ScriptableObject.getProperty(scriptable, key);
  if (retval instanceof Function) {
    return new RhinoFunctionModel((Function) retval, scriptable, wrapper);
  } else {
    return wrapper.wrap(retval);
  }
}

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

public static XMLLib extractFromScopeOrNull(Scriptable scope)
{
  ScriptableObject so = ScriptRuntime.getLibraryScopeOrNull(scope);
  if (so == null) {
    // If library is not yet initialized, return null
    return null;
  }
  // Ensure lazily initialization of real XML library instance
  // which is done on first access to XML property
  ScriptableObject.getProperty(so, "XML");
  return (XMLLib)so.getAssociatedValue(XML_LIB_KEY);
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.freemarker

public TemplateModel get(String key) throws TemplateModelException {
  Object retval = ScriptableObject.getProperty(scriptable, key);
  if (retval instanceof Function) {
    return new RhinoFunctionModel((Function) retval, scriptable, wrapper);
  } else {
    return wrapper.wrap(retval);
  }
}

代码示例来源:origin: org.apache.cocoon/cocoon-expression-language-impl

public Object getObject() {
  Object javaPackage;
  Context.enter();
  try {
    javaPackage = ScriptableObject.getProperty( getScope(), "java" );
  } finally {
    Context.exit();
  }
  return javaPackage;
}

相关文章

微信公众号

ScriptableObject类方法