當前位置: 首頁>>代碼示例>>Java>>正文


Java Scriptable.setParentScope方法代碼示例

本文整理匯總了Java中org.mozilla.javascript.Scriptable.setParentScope方法的典型用法代碼示例。如果您正苦於以下問題:Java Scriptable.setParentScope方法的具體用法?Java Scriptable.setParentScope怎麽用?Java Scriptable.setParentScope使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.mozilla.javascript.Scriptable的用法示例。


在下文中一共展示了Scriptable.setParentScope方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: execute

import org.mozilla.javascript.Scriptable; //導入方法依賴的package包/類
@Override
public boolean execute(Context javascriptContext, Scriptable scope) throws EngineException {
	if (isEnabled()) {
		if (super.execute(javascriptContext, scope)) {
			for (FunctionStatement function : getFunctions()) {
				if (function.getName().equals(functionName)) {
					Scriptable curScope = javascriptContext.initStandardObjects();
					curScope.setParentScope(scope);
					boolean ret = function.execute(javascriptContext, curScope);
					Object returnedValue = function.getReturnedValue();
					if (returnedValue != null) {
						ReturnStatement.returnLoop(this.parent, returnedValue);
					}
					return ret;
				}
			}
		}
	}
	return false;
}
 
開發者ID:convertigo,項目名稱:convertigo-engine,代碼行數:21,代碼來源:CallFunctionStatement.java

示例2: addCandidate

import org.mozilla.javascript.Scriptable; //導入方法依賴的package包/類
private void addCandidate(Context js_context, JSONArray result) {
	if (candidate != null) {
		if (js_filter != null) {
			try {
				Scriptable scope = js_context.initStandardObjects(null, true);
				scope.put("category", scope, candidate.getString(0));
				scope.put("time", scope, candidate.getString(1));
				scope.put("level", scope, candidate.getString(2));
				scope.put("thread", scope, candidate.getString(3));
				scope.put("message", scope, candidate.getString(4));
				StringBuffer extra = new StringBuffer();
				for (int i = 5; i < candidate.length(); i++) {
					String sub_extra = candidate.getString(i);
					extra.append(sub_extra).append(' ');
					delim_extra.reset(sub_extra);
					if (delim_extra.matches() && delim_extra.groupCount() == 2) {
						scope.put(delim_extra.group(1), scope, delim_extra.group(2));
					}
				}
				if (extra.length() > 0) {
					scope.put("extra", scope, extra.substring(0, extra.length() - 1));
				}
				scope.setParentScope(js_utils);
				if (Context.toBoolean(js_filter.exec(js_context, scope))) {
					result.put(candidate);
				}
			} catch (Exception e) {
				// TODO: handle exception
			}
		} else {
			result.put(candidate);
		}
		candidate = null;
	}
}
 
開發者ID:convertigo,項目名稱:convertigo-engine,代碼行數:36,代碼來源:LogManager.java

示例3: invokeNextStep

import org.mozilla.javascript.Scriptable; //導入方法依賴的package包/類
protected void invokeNextStep(Step step, Context javascriptContext, Scriptable scope) throws EngineException {
	Step stepToInvoke = getStepCopyToInvoke(step);
   	if (stepToInvoke != null) {
   		// Stack scope
   		// Note: variable must be declared with the 'var' keyword
   		Scriptable curScope = javascriptContext.initStandardObjects();
  			curScope.setParentScope(scope);
  			invokeStep(stepToInvoke, javascriptContext, curScope);
   	}
	currentChildStep++;
	
	performSynchronisation();
}
 
開發者ID:convertigo,項目名稱:convertigo-engine,代碼行數:14,代碼來源:StepWithExpressions.java

示例4: run

import org.mozilla.javascript.Scriptable; //導入方法依賴的package包/類
public void run() {
    Context context = factory.enterContext();
    try {
        // Run each script in its own scope, to keep global variables
        // defined in each script separate
        Scriptable threadScope = context.newObject(globalScope);
        threadScope.setPrototype(globalScope);
        threadScope.setParentScope(null);
        script.exec(context, threadScope);
    } catch (Exception ee) {
        ee.printStackTrace();
    } finally {
        Context.exit();
    }
}
 
開發者ID:middle2tw,項目名稱:whackpad,代碼行數:16,代碼來源:Bug421071Test.java


注:本文中的org.mozilla.javascript.Scriptable.setParentScope方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。