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


Java ScriptRuntime.throwError方法代码示例

本文整理汇总了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);
}
 
开发者ID:MikaGuraN,项目名称:HL4A,代码行数:46,代码来源:Require.java

示例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");
}
 
开发者ID:MikaGuraN,项目名称:HL4A,代码行数:6,代码来源:Require.java

示例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);
}
 
开发者ID:middle2tw,项目名称:whackpad,代码行数:45,代码来源:Require.java

示例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");
}
 
开发者ID:middle2tw,项目名称:whackpad,代码行数:5,代码来源:Require.java

示例5: throwError

import org.mozilla.javascript.ScriptRuntime; //导入方法依赖的package包/类
public void throwError(String msg) {
    throw ScriptRuntime.throwError(cx, scope, msg);
}
 
开发者ID:F43nd1r,项目名称:rhino-android,代码行数:4,代码来源:Issue176Test.java

示例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);
  }
 
开发者ID:tiffit,项目名称:TaleCraft,代码行数:46,代码来源:Require.java

示例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");
  }
 
开发者ID:tiffit,项目名称:TaleCraft,代码行数:6,代码来源:Require.java

示例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);
}
 
开发者ID:CyboticCatfish,项目名称:code404,代码行数:45,代码来源:Require.java

示例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");
}
 
开发者ID:CyboticCatfish,项目名称:code404,代码行数:5,代码来源:Require.java


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