本文整理匯總了Java中javax.script.SimpleBindings.put方法的典型用法代碼示例。如果您正苦於以下問題:Java SimpleBindings.put方法的具體用法?Java SimpleBindings.put怎麽用?Java SimpleBindings.put使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.script.SimpleBindings
的用法示例。
在下文中一共展示了SimpleBindings.put方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: executeScriptWithConsole
import javax.script.SimpleBindings; //導入方法依賴的package包/類
public Object executeScriptWithConsole(ScriptType type, String script, Map<String, Object> params, StringWriter console) {
ScriptEngine scriptEngine = produceScriptEngine(type);
if (console != null) {
scriptEngine.getContext().setWriter(console);
}
SimpleBindings bindings = new SimpleBindings();
bindings.putAll(params);
bindings.put("spring", context);
try {
return scriptEngine.eval(script, bindings);
} catch (ScriptException ex) {
throw new GeneralException(ex);
}
}
示例2: execute
import javax.script.SimpleBindings; //導入方法依賴的package包/類
private Object execute(MapAttribute wellKnowsAttributes) throws MetaException {
try {
SimpleBindings bindings = new SimpleBindings();
bindings.put("attributes", wellKnowsAttributes);
Invocable invocable = (Invocable)engines.getCachedEngine(javascriptPath);
return invocable.invokeFunction("create", wellKnowsAttributes);
} catch (ScriptException|NoSuchMethodException|IOException|URISyntaxException ex) {
throw new MetaException("Error executing script.", ex);
}
}
示例3: handle
import javax.script.SimpleBindings; //導入方法依賴的package包/類
@Override
public void handle(ByteBuf buf, MapleClient client) {
buf.readByte();
String startwp = readMapleAsciiString(buf);
buf.readShort();
MaplePortal portal = client.getCharacter().getMap().getPortal(startwp);
if (portal == null) {
client.sendReallowActions();
return;
}
if(portal.isBlocked(client.getCharacter())){
client.sendReallowActions();
return;
}
if(client.getCharacter().getMapId() == 910000000){
client.getCharacter().changeMap(client.getCharacter().getFmReturnMap());
}else if(portal.getTargetMapId() == 999999999){
MapleScript script = new MapleScript("scripts/portal/"+portal.getScriptName()+".js", "scripts/portal/fallback.js");
PortalScriptManager pm = new PortalScriptManager(client.getCharacter(), portal);
client.getLogger().debug("Running portal script "+script.getFile().getPath());
SimpleBindings sb = new SimpleBindings();
sb.put("pm", pm);
try {
script.execute(sb).startPortal();
} catch (Exception e) {
e.printStackTrace();
client.getLogger().error("Error running script "+portal.getScriptName());
}
client.sendReallowActions();
}else{
portal.enterPortal(client);
}
}
示例4: openSimpleTextNpc
import javax.script.SimpleBindings; //導入方法依賴的package包/類
public void openSimpleTextNpc(String text){
SimpleBindings sb = new SimpleBindings();
sb.put("text", text);
openNpc(new MapleScript("scripts/npc/simple_talk.js"), sb, MapleLifeFactory.getNPC(2080005));
}