本文整理汇总了Java中org.mozilla.javascript.ScriptRuntime.throwError方法的典型用法代码示例。如果您正苦于以下问题:Java ScriptRuntime.throwError方法的具体用法?Java ScriptRuntime.throwError怎么用?Java ScriptRuntime.throwError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.mozilla.javascript.ScriptRuntime
的用法示例。
在下文中一共展示了ScriptRuntime.throwError方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: call
import org.mozilla.javascript.ScriptRuntime; //导入方法依赖的package包/类
@Override
public Object call(Context cx, Scriptable scope, Scriptable thisObj,
Object[] args)
{
if(args == null || args.length < 1) {
throw ScriptRuntime.throwError(cx, scope,
"require() needs one argument");
}
String id = (String)Context.jsToJava(args[0], String.class);
URI uri = null;
URI base = null;
if (id.startsWith("./") || id.startsWith("../")) {
if (!(thisObj instanceof ModuleScope)) {
throw ScriptRuntime.throwError(cx, scope,
"Can't resolve relative module ID \"" + id +
"\" when require() is used outside of a module");
}
ModuleScope moduleScope = (ModuleScope) thisObj;
base = moduleScope.getBase();
URI current = moduleScope.getUri();
uri = current.resolve(id);
if (base == null) {
// calling module is absolute, resolve to absolute URI
// (but without file extension)
id = uri.toString();
} else {
// try to convert to a relative URI rooted on base
id = base.relativize(current).resolve(id).toString();
if (id.charAt(0) == '.') {
// resulting URI is not contained in base,
// throw error or make absolute depending on sandbox flag.
if (sandboxed) {
throw ScriptRuntime.throwError(cx, scope,
"Module \"" + id + "\" is not contained in sandbox.");
} else {
id = uri.toString();
}
}
}
}
return getExportedModuleInterface(cx, id, uri, base, false);
}
示例2: construct
import org.mozilla.javascript.ScriptRuntime; //导入方法依赖的package包/类
@Override
public Scriptable construct(Context cx, Scriptable scope, Object[] args) {
throw ScriptRuntime.throwError(cx, scope,
"require() can not be invoked as a constructor");
}
示例3: call
import org.mozilla.javascript.ScriptRuntime; //导入方法依赖的package包/类
public Object call(Context cx, Scriptable scope, Scriptable thisObj,
Object[] args)
{
if(args == null || args.length < 1) {
throw ScriptRuntime.throwError(cx, scope,
"require() needs one argument");
}
String id = (String)Context.jsToJava(args[0], String.class);
URI uri = null;
if (id.startsWith("./") || id.startsWith("../")) {
if (!(thisObj instanceof ModuleScope)) {
throw ScriptRuntime.throwError(cx, scope,
"Can't resolve relative module ID \"" + id +
"\" when require() is used outside of a module");
}
ModuleScope moduleScope = (ModuleScope) thisObj;
URI base = moduleScope.getBase();
URI current = moduleScope.getUri();
if (base == null) {
// calling module is absolute, resolve to absolute URI
// (but without file extension)
uri = current.resolve(id);
id = uri.toString();
} else {
// try to convert to a relative URI rooted on base
id = base.relativize(current).resolve(id).toString();
if (id.charAt(0) == '.') {
// resulting URI is not contained in base,
// throw error or make absolute depending on sandbox flag.
if (sandboxed) {
throw ScriptRuntime.throwError(cx, scope,
"Module \"" + id + "\" is not contained in sandbox.");
} else {
uri = current.resolve(id);
id = uri.toString();
}
}
}
}
return getExportedModuleInterface(cx, id, uri, false);
}
示例4: construct
import org.mozilla.javascript.ScriptRuntime; //导入方法依赖的package包/类
public Scriptable construct(Context cx, Scriptable scope, Object[] args) {
throw ScriptRuntime.throwError(cx, scope,
"require() can not be invoked as a constructor");
}
示例5: throwError
import org.mozilla.javascript.ScriptRuntime; //导入方法依赖的package包/类
public void throwError(String msg) {
throw ScriptRuntime.throwError(cx, scope, msg);
}
示例6: call
import org.mozilla.javascript.ScriptRuntime; //导入方法依赖的package包/类
@Override
public Object call(Context cx, Scriptable scope, Scriptable thisObj,
Object[] args)
{
if(args == null || args.length < 1) {
throw ScriptRuntime.throwError(cx, scope,
"require() needs one argument");
}
String id = (String)Context.jsToJava(args[0], String.class);
URI uri = null;
URI base = null;
if (id.startsWith("./") || id.startsWith("../")) {
if (!(thisObj instanceof ModuleScope)) {
throw ScriptRuntime.throwError(cx, scope,
"Can't resolve relative module ID \"" + id +
"\" when require() is used outside of a module");
}
ModuleScope moduleScope = (ModuleScope) thisObj;
base = moduleScope.getBase();
URI current = moduleScope.getUri();
uri = current.resolve(id);
if (base == null) {
// calling module is absolute, resolve to absolute URI
// (but without file extension)
id = uri.toString();
} else {
// try to convert to a relative URI rooted on base
id = base.relativize(current).resolve(id).toString();
if (id.charAt(0) == '.') {
// resulting URI is not contained in base,
// throw error or make absolute depending on sandbox flag.
if (sandboxed) {
throw ScriptRuntime.throwError(cx, scope,
"Module \"" + id + "\" is not contained in sandbox.");
} else {
id = uri.toString();
}
}
}
}
return getExportedModuleInterface(cx, id, uri, base, false);
}
示例7: construct
import org.mozilla.javascript.ScriptRuntime; //导入方法依赖的package包/类
@Override
public Scriptable construct(Context cx, Scriptable scope, Object[] args) {
throw ScriptRuntime.throwError(cx, scope,
"require() can not be invoked as a constructor");
}
示例8: call
import org.mozilla.javascript.ScriptRuntime; //导入方法依赖的package包/类
public Object call(Context cx, Scriptable scope, Scriptable thisObj,
Object[] args)
{
if(args == null || args.length < 1) {
throw ScriptRuntime.throwError(cx, scope,
"require() needs one argument");
}
String id = (String)Context.jsToJava(args[0], String.class);
URI uri = null;
URI base = null;
if (id.startsWith("./") || id.startsWith("../")) {
if (!(thisObj instanceof ModuleScope)) {
throw ScriptRuntime.throwError(cx, scope,
"Can't resolve relative module ID \"" + id +
"\" when require() is used outside of a module");
}
ModuleScope moduleScope = (ModuleScope) thisObj;
base = moduleScope.getBase();
URI current = moduleScope.getUri();
uri = current.resolve(id);
if (base == null) {
// calling module is absolute, resolve to absolute URI
// (but without file extension)
id = uri.toString();
} else {
// try to convert to a relative URI rooted on base
id = base.relativize(current).resolve(id).toString();
if (id.charAt(0) == '.') {
// resulting URI is not contained in base,
// throw error or make absolute depending on sandbox flag.
if (sandboxed) {
throw ScriptRuntime.throwError(cx, scope,
"Module \"" + id + "\" is not contained in sandbox.");
} else {
id = uri.toString();
}
}
}
}
return getExportedModuleInterface(cx, id, uri, base, false);
}
示例9: construct
import org.mozilla.javascript.ScriptRuntime; //导入方法依赖的package包/类
public Scriptable construct(Context cx, Scriptable scope, Object[] args) {
throw ScriptRuntime.throwError(cx, scope,
"require() can not be invoked as a constructor");
}