本文整理了Java中org.mozilla.javascript.tools.shell.Global.reportRuntimeError()
方法的一些代码示例,展示了Global.reportRuntimeError()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Global.reportRuntimeError()
方法的具体详情如下:
包路径:org.mozilla.javascript.tools.shell.Global
类名称:Global
方法名:reportRuntimeError
暂无
代码示例来源:origin: ro.isdc.wro4j/rhino
/**
* The seal function seals all supplied arguments.
*/
public static void seal(Context cx, Scriptable thisObj, Object[] args,
Function funObj)
{
for (int i = 0; i != args.length; ++i) {
Object arg = args[i];
if (!(arg instanceof ScriptableObject) || arg == Undefined.instance)
{
if (!(arg instanceof Scriptable) || arg == Undefined.instance)
{
throw reportRuntimeError("msg.shell.seal.not.object");
} else {
throw reportRuntimeError("msg.shell.seal.not.scriptable");
}
}
}
for (int i = 0; i != args.length; ++i) {
Object arg = args[i];
((ScriptableObject)arg).sealObject();
}
}
代码示例来源:origin: ro.isdc.wro4j/rhino
private static Global getInstance(Function function)
{
Scriptable scope = function.getParentScope();
if (!(scope instanceof Global))
throw reportRuntimeError("msg.bad.shell.function.scope",
String.valueOf(scope));
return (Global)scope;
}
代码示例来源:origin: org.jvnet.hudson/embedded-rhino-debugger
/**
* The seal function seals all supplied arguments.
*/
public static void seal(Context cx, Scriptable thisObj, Object[] args,
Function funObj)
{
for (int i = 0; i != args.length; ++i) {
Object arg = args[i];
if (!(arg instanceof ScriptableObject) || arg == Undefined.instance)
{
if (!(arg instanceof Scriptable) || arg == Undefined.instance)
{
throw reportRuntimeError("msg.shell.seal.not.object");
} else {
throw reportRuntimeError("msg.shell.seal.not.scriptable");
}
}
}
for (int i = 0; i != args.length; ++i) {
Object arg = args[i];
((ScriptableObject)arg).sealObject();
}
}
代码示例来源:origin: com.github.tntim96/rhino
/**
* The seal function seals all supplied arguments.
*/
public static void seal(Context cx, Scriptable thisObj, Object[] args,
Function funObj)
{
for (int i = 0; i != args.length; ++i) {
Object arg = args[i];
if (!(arg instanceof ScriptableObject) || arg == Undefined.instance)
{
if (!(arg instanceof Scriptable) || arg == Undefined.instance)
{
throw reportRuntimeError("msg.shell.seal.not.object");
} else {
throw reportRuntimeError("msg.shell.seal.not.scriptable");
}
}
}
for (int i = 0; i != args.length; ++i) {
Object arg = args[i];
((ScriptableObject)arg).sealObject();
}
}
代码示例来源:origin: org.jvnet.hudson/embedded-rhino-debugger
private static Global getInstance(Function function)
{
Scriptable scope = function.getParentScope();
if (!(scope instanceof Global))
throw reportRuntimeError("msg.bad.shell.function.scope",
String.valueOf(scope));
return (Global)scope;
}
代码示例来源:origin: com.github.tntim96/rhino
private static Global getInstance(Function function)
{
Scriptable scope = function.getParentScope();
if (!(scope instanceof Global))
throw reportRuntimeError("msg.bad.shell.function.scope",
String.valueOf(scope));
return (Global)scope;
}
代码示例来源:origin: ro.isdc.wro4j/rhino
private static Class<?> getClass(Object[] args) {
if (args.length == 0) {
throw reportRuntimeError("msg.expected.string.arg");
}
Object arg0 = args[0];
if (arg0 instanceof Wrapper) {
Object wrapped = ((Wrapper)arg0).unwrap();
if (wrapped instanceof Class)
return (Class<?>)wrapped;
}
String className = Context.toString(args[0]);
try {
return Class.forName(className);
}
catch (ClassNotFoundException cnfe) {
throw reportRuntimeError("msg.class.not.found", className);
}
}
代码示例来源:origin: org.jvnet.hudson/embedded-rhino-debugger
private static Class<?> getClass(Object[] args) {
if (args.length == 0) {
throw reportRuntimeError("msg.expected.string.arg");
}
Object arg0 = args[0];
if (arg0 instanceof Wrapper) {
Object wrapped = ((Wrapper)arg0).unwrap();
if (wrapped instanceof Class)
return (Class<?>)wrapped;
}
String className = Context.toString(args[0]);
try {
return Class.forName(className);
}
catch (ClassNotFoundException cnfe) {
throw reportRuntimeError("msg.class.not.found", className);
}
}
代码示例来源:origin: com.github.tntim96/rhino
private static Class<?> getClass(Object[] args) {
if (args.length == 0) {
throw reportRuntimeError("msg.expected.string.arg");
}
Object arg0 = args[0];
if (arg0 instanceof Wrapper) {
Object wrapped = ((Wrapper)arg0).unwrap();
if (wrapped instanceof Class)
return (Class<?>)wrapped;
}
String className = Context.toString(args[0]);
try {
return Class.forName(className);
}
catch (ClassNotFoundException cnfe) {
throw reportRuntimeError("msg.class.not.found", className);
}
}
代码示例来源:origin: ro.isdc.wro4j/rhino
/**
* Load and execute a script compiled to a class file.
* <p>
* This method is defined as a JavaScript function.
* When called as a JavaScript function, a single argument is
* expected. This argument should be the name of a class that
* implements the Script interface, as will any script
* compiled by jsc.
*
* @exception IllegalAccessException if access is not available
* to the class
* @exception InstantiationException if unable to instantiate
* the named class
*/
public static void loadClass(Context cx, Scriptable thisObj,
Object[] args, Function funObj)
throws IllegalAccessException, InstantiationException
{
Class<?> clazz = getClass(args);
if (!Script.class.isAssignableFrom(clazz)) {
throw reportRuntimeError("msg.must.implement.Script");
}
Script script = (Script) clazz.newInstance();
script.exec(cx, thisObj);
}
代码示例来源:origin: org.jvnet.hudson/embedded-rhino-debugger
/**
* Load and execute a script compiled to a class file.
* <p>
* This method is defined as a JavaScript function.
* When called as a JavaScript function, a single argument is
* expected. This argument should be the name of a class that
* implements the Script interface, as will any script
* compiled by jsc.
*
* @exception IllegalAccessException if access is not available
* to the class
* @exception InstantiationException if unable to instantiate
* the named class
*/
public static void loadClass(Context cx, Scriptable thisObj,
Object[] args, Function funObj)
throws IllegalAccessException, InstantiationException
{
Class<?> clazz = getClass(args);
if (!Script.class.isAssignableFrom(clazz)) {
throw reportRuntimeError("msg.must.implement.Script");
}
Script script = (Script) clazz.newInstance();
script.exec(cx, thisObj);
}
代码示例来源:origin: com.github.tntim96/rhino
/**
* Load and execute a script compiled to a class file.
* <p>
* This method is defined as a JavaScript function.
* When called as a JavaScript function, a single argument is
* expected. This argument should be the name of a class that
* implements the Script interface, as will any script
* compiled by jsc.
*
* @exception IllegalAccessException if access is not available
* to the class
* @exception InstantiationException if unable to instantiate
* the named class
*/
public static void loadClass(Context cx, Scriptable thisObj,
Object[] args, Function funObj)
throws IllegalAccessException, InstantiationException
{
Class<?> clazz = getClass(args);
if (!Script.class.isAssignableFrom(clazz)) {
throw reportRuntimeError("msg.must.implement.Script");
}
Script script = (Script) clazz.newInstance();
script.exec(cx, thisObj);
}
代码示例来源:origin: ro.isdc.wro4j/rhino
/**
* Load a Java class that defines a JavaScript object using the
* conventions outlined in ScriptableObject.defineClass.
* <p>
* This method is defined as a JavaScript function.
* @exception IllegalAccessException if access is not available
* to a reflected class member
* @exception InstantiationException if unable to instantiate
* the named class
* @exception InvocationTargetException if an exception is thrown
* during execution of methods of the named class
* @see org.mozilla.javascript.ScriptableObject#defineClass(Scriptable,Class)
*/
@SuppressWarnings({"unchecked"})
public static void defineClass(Context cx, Scriptable thisObj,
Object[] args, Function funObj)
throws IllegalAccessException, InstantiationException,
InvocationTargetException
{
Class<?> clazz = getClass(args);
if (!Scriptable.class.isAssignableFrom(clazz)) {
throw reportRuntimeError("msg.must.implement.Scriptable");
}
ScriptableObject.defineClass(thisObj, (Class<? extends Scriptable>)clazz);
}
代码示例来源:origin: org.jvnet.hudson/embedded-rhino-debugger
/**
* Load a Java class that defines a JavaScript object using the
* conventions outlined in ScriptableObject.defineClass.
* <p>
* This method is defined as a JavaScript function.
* @exception IllegalAccessException if access is not available
* to a reflected class member
* @exception InstantiationException if unable to instantiate
* the named class
* @exception InvocationTargetException if an exception is thrown
* during execution of methods of the named class
* @see org.mozilla.javascript.ScriptableObject#defineClass(Scriptable,Class)
*/
@SuppressWarnings({"unchecked"})
public static void defineClass(Context cx, Scriptable thisObj,
Object[] args, Function funObj)
throws IllegalAccessException, InstantiationException,
InvocationTargetException
{
Class<?> clazz = getClass(args);
if (!Scriptable.class.isAssignableFrom(clazz)) {
throw reportRuntimeError("msg.must.implement.Scriptable");
}
ScriptableObject.defineClass(thisObj, (Class<? extends Scriptable>)clazz);
}
代码示例来源:origin: com.github.tntim96/rhino
/**
* Load a Java class that defines a JavaScript object using the
* conventions outlined in ScriptableObject.defineClass.
* <p>
* This method is defined as a JavaScript function.
* @exception IllegalAccessException if access is not available
* to a reflected class member
* @exception InstantiationException if unable to instantiate
* the named class
* @exception InvocationTargetException if an exception is thrown
* during execution of methods of the named class
* @see org.mozilla.javascript.ScriptableObject#defineClass(Scriptable,Class)
*/
@SuppressWarnings({"unchecked"})
public static void defineClass(Context cx, Scriptable thisObj,
Object[] args, Function funObj)
throws IllegalAccessException, InstantiationException,
InvocationTargetException
{
Class<?> clazz = getClass(args);
if (!Scriptable.class.isAssignableFrom(clazz)) {
throw reportRuntimeError("msg.must.implement.Scriptable");
}
ScriptableObject.defineClass(thisObj, (Class<? extends Scriptable>)clazz);
}
代码示例来源:origin: org.jvnet.hudson/embedded-rhino-debugger
/**
* The readFile reads the given file content and convert it to a string
* using the specified character coding or default character coding if
* explicit coding argument is not given.
* <p>
* Usage:
* <pre>
* readFile(filePath)
* readFile(filePath, charCoding)
* </pre>
* The first form converts file's context to string using the default
* character coding.
*/
public static Object readFile(Context cx, Scriptable thisObj, Object[] args,
Function funObj)
throws IOException
{
if (args.length == 0) {
throw reportRuntimeError("msg.shell.readFile.bad.args");
}
String path = ScriptRuntime.toString(args[0]);
String charCoding = null;
if (args.length >= 2) {
charCoding = ScriptRuntime.toString(args[1]);
}
return readUrl(path, charCoding, true);
}
代码示例来源:origin: com.github.tntim96/rhino
/**
* The readFile reads the given file content and convert it to a string
* using the specified character coding or default character coding if
* explicit coding argument is not given.
* <p>
* Usage:
* <pre>
* readFile(filePath)
* readFile(filePath, charCoding)
* </pre>
* The first form converts file's context to string using the default
* character coding.
*/
public static Object readFile(Context cx, Scriptable thisObj, Object[] args,
Function funObj)
throws IOException
{
if (args.length == 0) {
throw reportRuntimeError("msg.shell.readFile.bad.args");
}
String path = ScriptRuntime.toString(args[0]);
String charCoding = null;
if (args.length >= 2) {
charCoding = ScriptRuntime.toString(args[1]);
}
return readUrl(path, charCoding, true);
}
代码示例来源:origin: ro.isdc.wro4j/rhino
/**
* The readFile reads the given file content and convert it to a string
* using the specified character coding or default character coding if
* explicit coding argument is not given.
* <p>
* Usage:
* <pre>
* readFile(filePath)
* readFile(filePath, charCoding)
* </pre>
* The first form converts file's context to string using the default
* character coding.
*/
public static Object readFile(Context cx, Scriptable thisObj, Object[] args,
Function funObj)
throws IOException
{
if (args.length == 0) {
throw reportRuntimeError("msg.shell.readFile.bad.args");
}
String path = ScriptRuntime.toString(args[0]);
String charCoding = null;
if (args.length >= 2) {
charCoding = ScriptRuntime.toString(args[1]);
}
return readUrl(path, charCoding, true);
}
代码示例来源:origin: ro.isdc.wro4j/rhino
/**
* The readUrl opens connection to the given URL, read all its data
* and converts them to a string
* using the specified character coding or default character coding if
* explicit coding argument is not given.
* <p>
* Usage:
* <pre>
* readUrl(url)
* readUrl(url, charCoding)
* </pre>
* The first form converts file's context to string using the default
* charCoding.
*/
public static Object readUrl(Context cx, Scriptable thisObj, Object[] args,
Function funObj)
throws IOException
{
if (args.length == 0) {
throw reportRuntimeError("msg.shell.readUrl.bad.args");
}
String url = ScriptRuntime.toString(args[0]);
String charCoding = null;
if (args.length >= 2) {
charCoding = ScriptRuntime.toString(args[1]);
}
return readUrl(url, charCoding, false);
}
代码示例来源:origin: com.github.tntim96/rhino
/**
* The readUrl opens connection to the given URL, read all its data
* and converts them to a string
* using the specified character coding or default character coding if
* explicit coding argument is not given.
* <p>
* Usage:
* <pre>
* readUrl(url)
* readUrl(url, charCoding)
* </pre>
* The first form converts file's context to string using the default
* charCoding.
*/
public static Object readUrl(Context cx, Scriptable thisObj, Object[] args,
Function funObj)
throws IOException
{
if (args.length == 0) {
throw reportRuntimeError("msg.shell.readUrl.bad.args");
}
String url = ScriptRuntime.toString(args[0]);
String charCoding = null;
if (args.length >= 2) {
charCoding = ScriptRuntime.toString(args[1]);
}
return readUrl(url, charCoding, false);
}
内容来源于网络,如有侵权,请联系作者删除!