当前位置: 首页>>代码示例>>Java>>正文


Java ScriptObject.hasOwnProperty方法代码示例

本文整理汇总了Java中jdk.nashorn.internal.runtime.ScriptObject.hasOwnProperty方法的典型用法代码示例。如果您正苦于以下问题:Java ScriptObject.hasOwnProperty方法的具体用法?Java ScriptObject.hasOwnProperty怎么用?Java ScriptObject.hasOwnProperty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在jdk.nashorn.internal.runtime.ScriptObject的用法示例。


在下文中一共展示了ScriptObject.hasOwnProperty方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getStack

import jdk.nashorn.internal.runtime.ScriptObject; //导入方法依赖的package包/类
/**
 * Nashorn extension: Error.prototype.stack
 * "stack" property is a string typed value containing JavaScript stack frames.
 * Each frame information is separated bv "\n" character.
 *
 * @param self  self reference
 *
 * @return      value of "stack" property
 */
public static Object getStack(final Object self) {
    final ScriptObject sobj = Global.checkObject(self);
    if (sobj.has(STACK)) {
        return sobj.get(STACK);
    }

    final Object exception = ECMAException.getException(sobj);
    if (exception instanceof Throwable) {
        final Object value = getScriptStackString(sobj, (Throwable)exception);
        if (sobj.hasOwnProperty(STACK)) {
            sobj.put(STACK, value, false);
        } else {
            sobj.addOwnProperty(STACK, Attribute.NOT_ENUMERABLE, value);
        }

        return value;
    }

    return UNDEFINED;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:30,代码来源:NativeError.java

示例2: getHandle

import jdk.nashorn.internal.runtime.ScriptObject; //导入方法依赖的package包/类
/**
 * Given a JS script object, retrieves a function from it by name, binds it to the script object as its "this", and
 * adapts its parameter types, return types, and arity to the specified type and arity. This method is public mainly
 * for implementation reasons, so the adapter classes can invoke it from their constructors that take a Object
 * in its first argument to obtain the method handles for their method implementations.
 * @param obj the script obj
 * @param name the name of the property that contains the function
 * @param type the method type it has to conform to
 * @return the appropriately adapted method handle for invoking the script function, or null if the value of the
 * property is either null or undefined, or "toString" was requested as the name, but the object doesn't directly
 * define it but just inherits it through prototype.
 */
public static MethodHandle getHandle(final Object obj, final String name, final MethodType type) {
    if (! (obj instanceof ScriptObject)) {
        throw typeError("not.an.object", ScriptRuntime.safeToString(obj));
    }

    final ScriptObject sobj = (ScriptObject)obj;
    // Since every JS Object has a toString, we only override "String toString()" it if it's explicitly specified
    if ("toString".equals(name) && !sobj.hasOwnProperty("toString")) {
        return null;
    }

    final Object fnObj = sobj.get(name);
    if (fnObj instanceof ScriptFunction) {
        return bindAndAdaptHandle((ScriptFunction)fnObj, sobj, type);
    } else if(fnObj == null || fnObj instanceof Undefined) {
        return null;
    } else {
        throw typeError("not.a.function", name);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:33,代码来源:JavaAdapterServices.java

示例3: setLineNumber

import jdk.nashorn.internal.runtime.ScriptObject; //导入方法依赖的package包/类
/**
 * Nashorn extension: Error.prototype.lineNumber
 *
 * @param self  self reference
 * @param value value of line number
 *
 * @return value that was set
 */
public static Object setLineNumber(final Object self, final Object value) {
    final ScriptObject sobj = Global.checkObject(self);
    if (sobj.hasOwnProperty(LINENUMBER)) {
        sobj.put(LINENUMBER, value, false);
    } else {
        sobj.addOwnProperty(LINENUMBER, Attribute.NOT_ENUMERABLE, value);
    }
    return value;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:18,代码来源:NativeError.java

示例4: setColumnNumber

import jdk.nashorn.internal.runtime.ScriptObject; //导入方法依赖的package包/类
/**
 * Nashorn extension: Error.prototype.columnNumber
 *
 * @param self  self reference
 * @param value value of column number
 *
 * @return value that was set
 */
public static Object setColumnNumber(final Object self, final Object value) {
    final ScriptObject sobj = Global.checkObject(self);
    if (sobj.hasOwnProperty(COLUMNNUMBER)) {
        sobj.put(COLUMNNUMBER, value, false);
    } else {
        sobj.addOwnProperty(COLUMNNUMBER, Attribute.NOT_ENUMERABLE, value);
    }
    return value;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:18,代码来源:NativeError.java

示例5: setFileName

import jdk.nashorn.internal.runtime.ScriptObject; //导入方法依赖的package包/类
/**
 * Nashorn extension: Error.prototype.fileName
 *
 * @param self  self reference
 * @param value value of file name
 *
 * @return value that was set
 */
public static Object setFileName(final Object self, final Object value) {
    final ScriptObject sobj = Global.checkObject(self);
    if (sobj.hasOwnProperty(FILENAME)) {
        sobj.put(FILENAME, value, false);
    } else {
        sobj.addOwnProperty(FILENAME, Attribute.NOT_ENUMERABLE, value);
    }
    return value;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:18,代码来源:NativeError.java

示例6: setStack

import jdk.nashorn.internal.runtime.ScriptObject; //导入方法依赖的package包/类
/**
 * Nashorn extension
 * Accessed from {@link Global} while setting up the Error.prototype
 *
 * @param self   self reference
 * @param value  value to set "stack" property to, must be {@code ScriptObject}
 *
 * @return value that was set
 */
public static Object setStack(final Object self, final Object value) {
    final ScriptObject sobj = Global.checkObject(self);
    if (sobj.hasOwnProperty(STACK)) {
        sobj.put(STACK, value, false);
    } else {
        sobj.addOwnProperty(STACK, Attribute.NOT_ENUMERABLE, value);
    }
    return value;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:19,代码来源:NativeError.java


注:本文中的jdk.nashorn.internal.runtime.ScriptObject.hasOwnProperty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。