• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java EcmaError类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.mozilla.javascript.EcmaError的典型用法代码示例。如果您正苦于以下问题:Java EcmaError类的具体用法?Java EcmaError怎么用?Java EcmaError使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



EcmaError类属于org.mozilla.javascript包,在下文中一共展示了EcmaError类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: executeSimpleHandlerCore

import org.mozilla.javascript.EcmaError; //导入依赖的package包/类
protected void executeSimpleHandlerCore(String handlerType, org.mozilla.javascript.Context myJavascriptContext) throws EcmaError, EvaluatorException, JavaScriptException, EngineException {
	handlerName = "on" + handlerType;

	Engine.logBeans.trace("(Transaction) Searching the " + handlerType + " handler (" + handlerName + ")");
	Object object = scope.get(handlerName, scope);
	Engine.logBeans.trace("(Transaction) Rhino returned: [" + object.getClass().getName() + "] " + object.toString());
       
	if (!(object instanceof Function)) {
		Engine.logBeans.debug("(Transaction) No " + handlerType + " handler (" + handlerName + ") found");
		return;
	}
	else {
		Engine.logBeans.debug("(Transaction) Execution of the " + handlerType + " handler (" + handlerName + ") for the transaction '" + getName() + "'");
	}

	function = (Function) object;

	Object returnedValue = function.call(myJavascriptContext, scope, scope, null);
	if (returnedValue instanceof org.mozilla.javascript.Undefined) {
		handlerResult = "";
	}
	else {
		handlerResult = returnedValue.toString();
	}
}
 
开发者ID:convertigo,项目名称:convertigo-engine,代码行数:26,代码来源:Transaction.java


示例2: load

import org.mozilla.javascript.EcmaError; //导入依赖的package包/类
/**
 * load
 * @param response
 */
public void load( WebResponse response ) {
		Function onLoadEvent=null;
    try {
        Context context = Context.enter();
        context.initStandardObjects( null );

        HTMLDocument htmlDocument = ((DomWindow) response.getScriptingHandler()).getDocument();
        if (!(htmlDocument instanceof HTMLDocumentImpl)) return;

        HTMLBodyElementImpl body = (HTMLBodyElementImpl) htmlDocument.getBody();
        if (body == null) return;
        onLoadEvent = body.getOnloadEvent();
        if (onLoadEvent == null) return;
        onLoadEvent.call( context, body, body, new Object[0] );
    } catch (JavaScriptException e) {
    	ScriptingEngineImpl.handleScriptException(e, onLoadEvent.toString());
    	// HttpUnitUtils.handleException(e);
    } catch (EcmaError ee) {
    	//throw ee;
    	ScriptingEngineImpl.handleScriptException(ee, onLoadEvent.toString());        	
    } finally {
        Context.exit();
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:29,代码来源:DomBasedScriptingEngineFactory.java


示例3: invokeFunction

import org.mozilla.javascript.EcmaError; //导入依赖的package包/类
public void invokeFunction(String name, Object... parameters) {
    Function func = (Function) globalScope.get(name, globalScope);

    if(func != null) {
        Context.enter();
        try {
            func.call(context, globalScope, globalScope, parameters);
        } catch (EcmaError err) {
            KakaoManager.getInstance().receiveError(err);
        }
        String params = "";
        int i = 0;
        for(Object p : parameters) {
            i++;
            params += " -> " + String.valueOf(p);
            if(i != parameters.length) {
                params += "\n";
            }
        }

        Logger.Log log = new Logger.Log();
        log.type = Logger.Type.APP;
        log.title = "call \"" + name + "\"";
        log.index = "parameters\n" + params;

        Logger.getInstance().add(log);
    }
}
 
开发者ID:Su-Yong,项目名称:NewKakaoBot,代码行数:29,代码来源:ScriptEngine.java


示例4: receiveError

import org.mozilla.javascript.EcmaError; //导入依赖的package包/类
public void receiveError(final EcmaError err) {
    if(isForeground) {
        MainActivity.UIThread(new Runnable() {
            @Override
            public void run() {
                MainActivity.settingPower.setChecked(false);
                Toast.makeText(ctx, "Error: " + err.getName() + " (" + err.lineNumber() + ", " + err.columnNumber() + ")\n" + err.getErrorMessage(), Toast.LENGTH_SHORT).show();
            }
        });
    }

    Logger.Log log = new Logger.Log();
    log.type = Logger.Type.ERROR;
    log.title = err.getName();
    log.index = "at (" + err.lineNumber() + ", " + err.columnNumber() + ")\n" + err.getErrorMessage();

    Logger.getInstance().add(log);
}
 
开发者ID:Su-Yong,项目名称:NewKakaoBot,代码行数:19,代码来源:KakaoManager.java


示例5: executeSimpleHandlerCore

import org.mozilla.javascript.EcmaError; //导入依赖的package包/类
@Override
protected void executeSimpleHandlerCore(String handlerType, Context myJavascriptContext) throws EcmaError, EvaluatorException, JavaScriptException, EngineException {

	handlerName = "on" + handlerType;
	Engine.logBeans.trace("(HtmlTransaction) Searching the " + handlerType + " handler (" + handlerName + ")");
	HandlerStatement handlerStatement = getHandlerStatement(handlerName);

	handlerResult = "";
	if (handlerStatement != null) {
		
		if (!handlerStatement.isEnabled())
			return;
		
		Engine.logBeans.debug("(HtmlTransaction) Execution of the " + handlerType + " handler  (" + handlerName + ") for the transaction '" + getName() + "'");
		handlerStatement.execute(myJavascriptContext, scope);
		Object returnedValue = handlerStatement.getReturnedValue();
		if (returnedValue instanceof org.mozilla.javascript.Undefined) {
			handlerResult = "";
		}
		else {
			handlerResult = returnedValue.toString();
		}
	}
	else {
		Engine.logBeans.debug("(HtmlTransaction) No " + handlerType + " handler  (" + handlerName + ") found");
	}
}
 
开发者ID:convertigo,项目名称:convertigo-engine,代码行数:28,代码来源:HtmlTransaction.java


示例6: executeHandlerCore

import org.mozilla.javascript.EcmaError; //导入依赖的package包/类
@Override
protected void executeHandlerCore(String handlerType, org.mozilla.javascript.Context javascriptContext) throws EcmaError, EvaluatorException, JavaScriptException, EngineException {
	if (!AbstractHttpTransaction.EVENT_DATA_RETRIEVED.equals(handlerType)) {
		super.executeHandlerCore(handlerType, javascriptContext);
		return;
	}

	executeSimpleHandlerCore(handlerType, javascriptContext);
}
 
开发者ID:convertigo,项目名称:convertigo-engine,代码行数:10,代码来源:AbstractHttpTransaction.java


示例7: executeHandlerCore

import org.mozilla.javascript.EcmaError; //导入依赖的package包/类
protected void executeHandlerCore(String handlerType, org.mozilla.javascript.Context myJavascriptContext) throws EcmaError, EvaluatorException, JavaScriptException, EngineException {
	if ((!Transaction.EVENT_XML_GENERATED.equals(handlerType)) &&
		(!Transaction.EVENT_TRANSACTION_STARTED.equals(handlerType))) {
		throw new IllegalArgumentException("Unknown handler type: " + handlerType);
	}

	executeSimpleHandlerCore(handlerType, myJavascriptContext);
}
 
开发者ID:convertigo,项目名称:convertigo-engine,代码行数:9,代码来源:Transaction.java


示例8: testWriteReadOnly_throws

import org.mozilla.javascript.EcmaError; //导入依赖的package包/类
/**
 * @throws Exception if the test fails
 */
@Test
public void testWriteReadOnly_throws() throws Exception {
	try {
		testWriteReadOnly(false);
		Assert.fail();
	}
	catch (EcmaError e) {
		Assert.assertTrue(e.getMessage(), e.getMessage().contains("Cannot set property myProp that has only a getter"));
	}
}
 
开发者ID:middle2tw,项目名称:whackpad,代码行数:14,代码来源:WriteReadOnlyPropertyTest.java


示例9: eval

import org.mozilla.javascript.EcmaError; //导入依赖的package包/类
public void eval(String content) {
	try {
		this.context.evaluateString(this.scope, content, this.getAbsoluteName(), 1, null);
	} catch(EcmaError e) {
		KnuddelsServer.getDefaultLogger().error(e.getMessage());
	}
}
 
开发者ID:MyChannel-Apps,项目名称:Emulator,代码行数:8,代码来源:RhinoApp.java


示例10: jsEval

import org.mozilla.javascript.EcmaError; //导入依赖的package包/类
/**
 * evaluate a javascript String
 * @param name the name of the script (for error messages)
 * @param script the content of the script
 * @return the result
 */
public Object jsEval(String name, String script) {
    try {
        return getContext().evaluateString(scope, script, name, 1, null);
    } catch (EcmaError e) {
        throw new RuntimeException("can't evaluate "+name+": "+script,e);
    }
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:14,代码来源:JsScriptEngine.java


示例11: getFunction

import org.mozilla.javascript.EcmaError; //导入依赖的package包/类
private Function getFunction(String name, Scriptable scope, Context ctx) {
    Object fun;
    try {
        fun = ctx.compileString(name, null, 1, null).exec(ctx, scope);
    } catch (EcmaError ee) {
        throw new RuntimeException ("Function '" + name + "()' not found.");
    }
    
    if (!(fun instanceof Function)) {
        throw new RuntimeException("'" + name + "' is not a function");
    } else {
        return (Function) fun;
    }
}
 
开发者ID:OpenRefine,项目名称:simile-butterfly,代码行数:15,代码来源:ButterflyModuleImpl.java


示例12: executeInternal

import org.mozilla.javascript.EcmaError; //导入依赖的package包/类
private Object executeInternal(final String script, final String scriptName, final ScriptContext context,
	final boolean function, final Class<?> expectedResultClass) throws ScriptException
{
	// never ever execute an empty script, it's just a waste of time
	if( !Check.isEmpty(script) )
	{
		// In most cases apart from calls from birt, we can expect that
		// there'll be no current context, thus one will be generated by
		// this call into the ContextFactory
		return ContextFactory.getGlobal().call(new ContextAction()
		{
			@Override
			public Object run(Context cx)
			{
				Logger errorLogger = context.getLogger();
				if( errorLogger == null )
				{
					errorLogger = logger;
				}

				Scriptable userScriptScope = ((DefaultScriptContext) context).getUserScriptScope(cx);
				ScriptableModuleSourceProvider sourceProvider = new ScriptableModuleSourceProvider(userScriptScope);
				ModuleScriptProvider scriptProvider = new SoftCachingModuleScriptProvider(sourceProvider);

				cx.initStandardObjects();
				Scriptable scope = ((DefaultScriptContext) context).getScope(cx);

				RequireBuilder builder = new RequireBuilder();
				// The "uri" property must not exist in a sandbox
				builder.setSandboxed(false);
				builder.setModuleScriptProvider(scriptProvider);

				Require require = builder.createRequire(cx, scope);

				cx.setOptimizationLevel(-1);
				cx.setErrorReporter(new ScriptErrorReporter(errorLogger));


				final String execScript = (function ? "function runScript() {\n" + script + "\n}\n runScript();"
					: script);
				final String execScriptName = (scriptName != null ? scriptName : "script");

				try
				{
					context.scriptEnter();
					require.install(scope);

					Object result = cx.evaluateString(scope, execScript, execScriptName, 1, null);

					context.scriptExit();
					if( expectedResultClass == String.class )
					{
						return result.toString();
					}
					return result;
				}
				catch( JavaScriptException js )
				{
					throw new ScriptException(js);
				}
				catch( EcmaError ec )
				{
					throw new ScriptException(ec);
				}
				catch( EvaluatorException ev )
				{
					throw new ScriptException(ev);
				}
			}
		});
	}
	return Boolean.TRUE;

}
 
开发者ID:equella,项目名称:Equella,代码行数:75,代码来源:ScriptingServiceImpl.java


示例13: testS15_10_2_15_A1_T4

import org.mozilla.javascript.EcmaError; //导入依赖的package包/类
@Test(expected = EcmaError.class)
public void testS15_10_2_15_A1_T4() {
    String source = "(new RegExp('[\\\\Db-G]').exec('a'))";
    String sourceName = "Conformance/15_Native/15.10_RegExp_Objects/15.10.2_Pattern_Semantics/15.10.2.15_NonemptyClassRanges/S15.10.2.15_A1_T4.js";
    cx.evaluateString(scope, source, sourceName, 0, null);
}
 
开发者ID:F43nd1r,项目名称:rhino-android,代码行数:7,代码来源:Test262RegExpTest.java


示例14: testS15_10_2_15_A1_T5

import org.mozilla.javascript.EcmaError; //导入依赖的package包/类
@Test(expected = EcmaError.class)
public void testS15_10_2_15_A1_T5() {
    String source = "(new RegExp('[\\\\sb-G]').exec('a'))";
    String sourceName = "Conformance/15_Native/15.10_RegExp_Objects/15.10.2_Pattern_Semantics/15.10.2.15_NonemptyClassRanges/S15.10.2.15_A1_T5.js";
    cx.evaluateString(scope, source, sourceName, 0, null);
}
 
开发者ID:F43nd1r,项目名称:rhino-android,代码行数:7,代码来源:Test262RegExpTest.java


示例15: testS15_10_2_15_A1_T6

import org.mozilla.javascript.EcmaError; //导入依赖的package包/类
@Test(expected = EcmaError.class)
public void testS15_10_2_15_A1_T6() {
    String source = "(new RegExp('[\\\\Sb-G]').exec('a'))";
    String sourceName = "Conformance/15_Native/15.10_RegExp_Objects/15.10.2_Pattern_Semantics/15.10.2.15_NonemptyClassRanges/S15.10.2.15_A1_T6.js";
    cx.evaluateString(scope, source, sourceName, 0, null);
}
 
开发者ID:F43nd1r,项目名称:rhino-android,代码行数:7,代码来源:Test262RegExpTest.java


示例16: testS15_10_2_15_A1_T7

import org.mozilla.javascript.EcmaError; //导入依赖的package包/类
@Test(expected = EcmaError.class)
public void testS15_10_2_15_A1_T7() {
    String source = "(new RegExp('[\\\\wb-G]').exec('a'))";
    String sourceName = "Conformance/15_Native/15.10_RegExp_Objects/15.10.2_Pattern_Semantics/15.10.2.15_NonemptyClassRanges/S15.10.2.15_A1_T7.js";
    cx.evaluateString(scope, source, sourceName, 0, null);
}
 
开发者ID:F43nd1r,项目名称:rhino-android,代码行数:7,代码来源:Test262RegExpTest.java


示例17: testS15_10_2_15_A1_T8

import org.mozilla.javascript.EcmaError; //导入依赖的package包/类
@Test(expected = EcmaError.class)
public void testS15_10_2_15_A1_T8() {
    String source = "(new RegExp('[\\\\Wb-G]').exec('a'))";
    String sourceName = "Conformance/15_Native/15.10_RegExp_Objects/15.10.2_Pattern_Semantics/15.10.2.15_NonemptyClassRanges/S15.10.2.15_A1_T8.js";
    cx.evaluateString(scope, source, sourceName, 0, null);
}
 
开发者ID:F43nd1r,项目名称:rhino-android,代码行数:7,代码来源:Test262RegExpTest.java


示例18: loadModule

import org.mozilla.javascript.EcmaError; //导入依赖的package包/类
/**
     * This method runs part of the core module controller.js script so that we
     * can register all operations without having to duplicate configuration
     * here.
     */

    public void loadModule(String name, String path, String... initFunctions)
            throws IOException {

        ButterflyModule core = new ButterflyModuleStub(name);
//        File controllerFile = new File(Configurations.get("refine.root",
//                "../OpenRefine"), path);

        String script = IOUtils.toString(getClass().getClassLoader().getResourceAsStream(path));

        if (script == null) {
            fLogger.warn(String.format(
                    "Can't find controller script for module %s at %s -- "
                            + "module may not work as expected.", name,
                    name));
            return;
        }

        // Compiles and "executes" the controller script. The script basically
        // contains function declarations.
        Context context = ContextFactory.getGlobal().enterContext();
        Script controller = context.compileString(
                script, "init.js", 1, null);

        // Initializes the scope.
        ScriptableObject scope = new ImporterTopLevel(context);

        scope.put("module", scope, core);
        controller.exec(context, scope);

        for (String function : initFunctions) {
            // Runs the function that initializes the OperationRegistry.
            try {
                Object fun = context.compileString(function, null, 1, null)
                        .exec(context, scope);
                if (fun != null && fun instanceof Function) {
                    ((Function) fun).call(context, scope, scope,
                            new Object[]{});
                }
            } catch (EcmaError ex) {
                fLogger.error("Error running controller script.", ex);
            }
        }
    }
 
开发者ID:fusepoolP3,项目名称:p3-batchrefine,代码行数:50,代码来源:TransformEngineImpl.java


示例19: getEventFunction

import org.mozilla.javascript.EcmaError; //导入依赖的package包/类
/**
 * Gets the event function.
 *
 * @param varValue
 *            the var value
 * @param attributeName
 *            the attribute name
 * @return the event function
 */
public Function getEventFunction(Function varValue, String attributeName) {

	if (varValue != null) {
		return varValue;
	}

	String normalAttributeName = this.normalizeAttributeName(attributeName);
	synchronized (this) {
		Map<String, Function> fba = this.functionByAttribute;
		Function f = fba == null ? null : (Function) fba.get(normalAttributeName);
		if (f != null) {
			return f;
		}
		UserAgentContext uac = this.getUserAgentContext();
		if (uac == null) {
			throw new IllegalStateException("No user agent context.");
		}
		if (uac.isScriptingEnabled()) {
			String attributeValue = this.getAttribute(attributeName);
			if (attributeValue == null || attributeValue.length() == 0) {
				f = null;
			} else {
				String functionCode = "function " + normalAttributeName + "_" + System.identityHashCode(this)
						+ "() {" + attributeValue + "}";
				Document doc = this.document;
				if (doc == null) {
					throw new IllegalStateException("Element does not belong to a document.");
				}
				Context ctx = Executor.createContext(this.getDocumentURL(), uac);
				try {
					Scriptable scope = (Scriptable) doc.getUserData(Executor.SCOPE_KEY);
					if (scope == null) {
						throw new IllegalStateException(
								"Scriptable (scope) instance was expected to be keyed as UserData to document using "
										+ Executor.SCOPE_KEY);
					}
					Scriptable thisScope = (Scriptable) JavaScript.getInstance().getJavascriptObject(this, scope);
					try {
						// TODO: Get right line number for script. //TODO:
						// Optimize this in case it's called multiple times?
						// Is that done?
						f = ctx.compileFunction(thisScope, functionCode,
								this.getTagName() + "[" + this.getId() + "]." + attributeName, 1, null);
					} catch (EcmaError ecmaError) {
						logger.error("Javascript error at " + ecmaError.sourceName() + ":" + ecmaError.lineNumber()
								+ ": " + ecmaError.getMessage(), ecmaError);
						f = null;
					} catch (Exception err) {
						logger.error("Unable to evaluate Javascript code", err);
						f = null;
					}
				} finally {
					Context.exit();
				}
			}
			if (fba == null) {
				fba = new HashMap<String, Function>(1);
				this.functionByAttribute = fba;
			}
			fba.put(normalAttributeName, f);
		}
		return f;
	}
}
 
开发者ID:oswetto,项目名称:LoboEvolution,代码行数:74,代码来源:HTMLAbstractUIElement.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java UsbDevice类代码示例发布时间:2022-05-21
下一篇:
Java Stairs类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap