本文整理汇总了Java中jdk.nashorn.internal.runtime.ScriptObject.addOwnProperty方法的典型用法代码示例。如果您正苦于以下问题:Java ScriptObject.addOwnProperty方法的具体用法?Java ScriptObject.addOwnProperty怎么用?Java ScriptObject.addOwnProperty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jdk.nashorn.internal.runtime.ScriptObject
的用法示例。
在下文中一共展示了ScriptObject.addOwnProperty方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例2: captureStackTrace
import jdk.nashorn.internal.runtime.ScriptObject; //导入方法依赖的package包/类
/**
* Nashorn extension: Error.captureStackTrace. Capture stack trace at the point of call into the Error object provided.
*
* @param self self reference
* @param errorObj the error object
* @return undefined
*/
@Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
public static Object captureStackTrace(final Object self, final Object errorObj) {
final ScriptObject sobj = Global.checkObject(errorObj);
initException(sobj);
sobj.delete(STACK, false);
if (! sobj.has("stack")) {
final ScriptFunction getStack = ScriptFunctionImpl.makeFunction("getStack", GET_STACK);
final ScriptFunction setStack = ScriptFunctionImpl.makeFunction("setStack", SET_STACK);
sobj.addOwnProperty("stack", Attribute.NOT_ENUMERABLE, getStack, setStack);
}
return UNDEFINED;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例7: initErrorObjects
import jdk.nashorn.internal.runtime.ScriptObject; //导入方法依赖的package包/类
private void initErrorObjects() {
// Error objects
this.builtinError = initConstructor("Error", ScriptFunction.class);
final ScriptObject errorProto = getErrorPrototype();
// Nashorn specific accessors on Error.prototype - stack, lineNumber, columnNumber and fileName
final ScriptFunction getStack = ScriptFunctionImpl.makeFunction("getStack", NativeError.GET_STACK);
final ScriptFunction setStack = ScriptFunctionImpl.makeFunction("setStack", NativeError.SET_STACK);
errorProto.addOwnProperty("stack", Attribute.NOT_ENUMERABLE, getStack, setStack);
final ScriptFunction getLineNumber = ScriptFunctionImpl.makeFunction("getLineNumber", NativeError.GET_LINENUMBER);
final ScriptFunction setLineNumber = ScriptFunctionImpl.makeFunction("setLineNumber", NativeError.SET_LINENUMBER);
errorProto.addOwnProperty("lineNumber", Attribute.NOT_ENUMERABLE, getLineNumber, setLineNumber);
final ScriptFunction getColumnNumber = ScriptFunctionImpl.makeFunction("getColumnNumber", NativeError.GET_COLUMNNUMBER);
final ScriptFunction setColumnNumber = ScriptFunctionImpl.makeFunction("setColumnNumber", NativeError.SET_COLUMNNUMBER);
errorProto.addOwnProperty("columnNumber", Attribute.NOT_ENUMERABLE, getColumnNumber, setColumnNumber);
final ScriptFunction getFileName = ScriptFunctionImpl.makeFunction("getFileName", NativeError.GET_FILENAME);
final ScriptFunction setFileName = ScriptFunctionImpl.makeFunction("setFileName", NativeError.SET_FILENAME);
errorProto.addOwnProperty("fileName", Attribute.NOT_ENUMERABLE, getFileName, setFileName);
// ECMA 15.11.4.2 Error.prototype.name
// Error.prototype.name = "Error";
errorProto.set(NativeError.NAME, "Error", 0);
// ECMA 15.11.4.3 Error.prototype.message
// Error.prototype.message = "";
errorProto.set(NativeError.MESSAGE, "", 0);
tagBuiltinProperties("Error", builtinError);
this.builtinEvalError = initErrorSubtype("EvalError", errorProto);
this.builtinRangeError = initErrorSubtype("RangeError", errorProto);
this.builtinReferenceError = initErrorSubtype("ReferenceError", errorProto);
this.builtinSyntaxError = initErrorSubtype("SyntaxError", errorProto);
this.builtinTypeError = initErrorSubtype("TypeError", errorProto);
this.builtinURIError = initErrorSubtype("URIError", errorProto);
}
示例8: captureStackTrace
import jdk.nashorn.internal.runtime.ScriptObject; //导入方法依赖的package包/类
/**
* Nashorn extension: Error.captureStackTrace. Capture stack trace at the point of call into the Error object provided.
*
* @param self self reference
* @param errorObj the error object
* @return undefined
*/
@Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
public static Object captureStackTrace(final Object self, final Object errorObj) {
final ScriptObject sobj = Global.checkObject(errorObj);
initException(sobj);
sobj.delete(STACK, false);
if (! sobj.has("stack")) {
final ScriptFunction getStack = ScriptFunction.createBuiltin("getStack", GET_STACK);
final ScriptFunction setStack = ScriptFunction.createBuiltin("setStack", SET_STACK);
sobj.addOwnProperty("stack", Attribute.NOT_ENUMERABLE, getStack, setStack);
}
return UNDEFINED;
}
示例9: initErrorObjects
import jdk.nashorn.internal.runtime.ScriptObject; //导入方法依赖的package包/类
private void initErrorObjects() {
// Error objects
this.builtinError = initConstructor("Error", ScriptFunction.class);
final ScriptObject errorProto = getErrorPrototype();
// Nashorn specific accessors on Error.prototype - stack, lineNumber, columnNumber and fileName
final ScriptFunction getStack = ScriptFunction.createBuiltin("getStack", NativeError.GET_STACK);
final ScriptFunction setStack = ScriptFunction.createBuiltin("setStack", NativeError.SET_STACK);
errorProto.addOwnProperty("stack", Attribute.NOT_ENUMERABLE, getStack, setStack);
final ScriptFunction getLineNumber = ScriptFunction.createBuiltin("getLineNumber", NativeError.GET_LINENUMBER);
final ScriptFunction setLineNumber = ScriptFunction.createBuiltin("setLineNumber", NativeError.SET_LINENUMBER);
errorProto.addOwnProperty("lineNumber", Attribute.NOT_ENUMERABLE, getLineNumber, setLineNumber);
final ScriptFunction getColumnNumber = ScriptFunction.createBuiltin("getColumnNumber", NativeError.GET_COLUMNNUMBER);
final ScriptFunction setColumnNumber = ScriptFunction.createBuiltin("setColumnNumber", NativeError.SET_COLUMNNUMBER);
errorProto.addOwnProperty("columnNumber", Attribute.NOT_ENUMERABLE, getColumnNumber, setColumnNumber);
final ScriptFunction getFileName = ScriptFunction.createBuiltin("getFileName", NativeError.GET_FILENAME);
final ScriptFunction setFileName = ScriptFunction.createBuiltin("setFileName", NativeError.SET_FILENAME);
errorProto.addOwnProperty("fileName", Attribute.NOT_ENUMERABLE, getFileName, setFileName);
// ECMA 15.11.4.2 Error.prototype.name
// Error.prototype.name = "Error";
errorProto.set(NativeError.NAME, "Error", 0);
// ECMA 15.11.4.3 Error.prototype.message
// Error.prototype.message = "";
errorProto.set(NativeError.MESSAGE, "", 0);
tagBuiltinProperties("Error", builtinError);
this.builtinReferenceError = initErrorSubtype("ReferenceError", errorProto);
this.builtinSyntaxError = initErrorSubtype("SyntaxError", errorProto);
this.builtinTypeError = initErrorSubtype("TypeError", errorProto);
}