本文整理了Java中javax.script.ScriptEngine.get()
方法的一些代码示例,展示了ScriptEngine.get()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ScriptEngine.get()
方法的具体详情如下:
包路径:javax.script.ScriptEngine
类名称:ScriptEngine
方法名:get
[英]Retrieves the value which is associated with the specified key in the state of the ScriptEngine.
[中]在脚本引擎的状态下检索与指定键关联的值。
代码示例来源:origin: looly/hutool
@Override
public Object get(String key) {
return engine.get(key);
}
代码示例来源:origin: code4craft/webmagic
case Jython:
engine.eval(defines + "\n" + script, context);
PyDictionary oJython = (PyDictionary) engine.get("result");
Iterator it = oJython.entrySet().iterator();
while (it.hasNext()) {
代码示例来源:origin: looly/hutool
@Override
public Object get(String key) {
return engine.get(key);
}
代码示例来源:origin: looly/hutool
@Override
public Object get(String key) {
return engine.get(key);
}
代码示例来源:origin: looly/hutool
@Override
public Object get(String key) {
return engine.get(key);
}
代码示例来源:origin: apache/nifi
@Override
public String getLanguageName() {
return (String) scriptEngine.get(ScriptEngine.LANGUAGE);
}
代码示例来源:origin: apache/nifi
@Override
public Object getParameter(String key) {
return key == null ? null : scriptEngine.get(key);
}
代码示例来源:origin: apache/nifi
@Override
public String getEngineName() {
return (String) scriptEngine.get(ScriptEngine.ENGINE);
}
代码示例来源:origin: apache/nifi
@Override
public String getEngineVersion() {
return (String) scriptEngine.get(ScriptEngine.ENGINE_VERSION);
}
代码示例来源:origin: apache/nifi
@Override
public String getLanguageVersion() {
return (String) scriptEngine.get(ScriptEngine.LANGUAGE_VERSION);
}
代码示例来源:origin: zendesk/maxwell
private ScriptObjectMirror getFunc(ScriptEngine engine, String fName, String filename) {
ScriptObjectMirror f = (ScriptObjectMirror) engine.get(fName);
if ( f == null )
return null;
else if ( !f.isFunction() ) {
throw new RuntimeException("Expected " + fName + " to be a function!");
} else {
LOGGER.info("using function " + fName + " from " + filename);
}
return f;
}
代码示例来源:origin: jphp-group/jphp
@Override
public String getEngineVersion() {
return getScriptEngine().get(ScriptEngine.ENGINE_VERSION).toString();
}
代码示例来源:origin: jphp-group/jphp
@Override
public String getLanguageVersion() {
return getScriptEngine().get(ScriptEngine.LANGUAGE_VERSION).toString();
}
代码示例来源:origin: jphp-group/jphp
@Override
public Object getParameter(String key) {
return getScriptEngine().get(key).toString();
}
代码示例来源:origin: jphp-group/jphp
@Override
public String getEngineName() {
return getScriptEngine().get(ScriptEngine.ENGINE).toString();
}
代码示例来源:origin: jphp-group/jphp
@Override
public String getLanguageName() {
return getScriptEngine().get(ScriptEngine.LANGUAGE).toString();
}
代码示例来源:origin: jphp-group/jphp
@Test
public void testVariableGet() throws Exception {
ScriptEngineManager factory = new ScriptEngineManager();
ScriptEngine engine = factory.getEngineByName("jphp");
engine.eval("<?php $baz = 'test value';");
Assert.assertEquals("test value", engine.get("baz").toString());
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void customEngineAndRenderFunction() throws Exception {
ScriptEngine engine = mock(InvocableScriptEngine.class);
given(engine.get("key")).willReturn("value");
this.view.setEngine(engine);
this.view.setRenderFunction("render");
this.view.setApplicationContext(this.context);
engine = this.view.getEngine();
assertNotNull(engine);
assertEquals("value", engine.get("key"));
DirectFieldAccessor accessor = new DirectFieldAccessor(this.view);
assertNull(accessor.getPropertyValue("renderObject"));
assertEquals("render", accessor.getPropertyValue("renderFunction"));
assertEquals(StandardCharsets.UTF_8, accessor.getPropertyValue("defaultCharset"));
}
代码示例来源:origin: apache/nifi
@OnDisabled
public void onDisabled(final ConfigurationContext context) {
// Call an non-interface method onDisabled(context), to allow a scripted LookupService the chance to shut down as necessary
final Invocable invocable = (Invocable) scriptEngine;
if (configurationContext != null) {
try {
// Get the actual object from the script engine, versus the proxy stored in lookupService. The object may have additional methods,
// where lookupService is a proxied interface
final Object obj = scriptEngine.get("lookupService");
if (obj != null) {
try {
invocable.invokeMethod(obj, "onDisabled", context);
} catch (final NoSuchMethodException nsme) {
if (getLogger().isDebugEnabled()) {
getLogger().debug("Configured script LookupService does not contain an onDisabled() method.");
}
}
} else {
throw new ScriptException("No LookupService was defined by the script.");
}
} catch (ScriptException se) {
throw new ProcessException("Error executing onDisabled(context) method", se);
}
}
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void customEngineAndRenderFunction() throws Exception {
ScriptEngine engine = mock(InvocableScriptEngine.class);
given(engine.get("key")).willReturn("value");
this.view.setEngine(engine);
this.view.setRenderFunction("render");
this.view.setApplicationContext(this.wac);
engine = this.view.getEngine();
assertNotNull(engine);
assertEquals("value", engine.get("key"));
DirectFieldAccessor accessor = new DirectFieldAccessor(this.view);
assertNull(accessor.getPropertyValue("renderObject"));
assertEquals("render", accessor.getPropertyValue("renderFunction"));
assertEquals(StandardCharsets.UTF_8, accessor.getPropertyValue("charset"));
}
内容来源于网络,如有侵权,请联系作者删除!