本文整理了Java中bsh.Interpreter.get()
方法的一些代码示例,展示了Interpreter.get()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Interpreter.get()
方法的具体详情如下:
包路径:bsh.Interpreter
类名称:Interpreter
方法名:get
[英]Get the value of the name. name may be any value. e.g. a variable or field
[中]获取名称的值。名称可以是任何值。e、 g.变量或字段
代码示例来源:origin: stackoverflow.com
Interpreter interpreter = new Interpreter();
interpreter.eval("result = 5+4*(7-15)");
System.out.println(interpreter.get("result"));
代码示例来源:origin: org.picocontainer.script/picocontainer-script-bsh
protected PicoContainer createContainerFromScript(PicoContainer parentContainer, Object assemblyScope) {
Interpreter i = new Interpreter();
try {
i.set("parent", parentContainer);
i.set("assemblyScope", assemblyScope);
i.setClassLoader(this.getClassLoader());
i.eval(getScriptReader(), i.getNameSpace(), "picocontainer.bsh");
return (PicoContainer) i.get("pico");
} catch (EvalError e) {
throw new ScriptedPicoContainerMarkupException(e);
} catch (IOException e) {
throw new ScriptedPicoContainerMarkupException(e);
}
}
}
代码示例来源:origin: beanshell/beanshell
/**
Unchecked get for internal use
*/
Object getu( String name ) {
try {
return get( name );
} catch ( EvalError e ) {
throw new InterpreterError("set: "+e, e);
}
}
代码示例来源:origin: picocontainer/picocontainer
@Override
protected PicoContainer createContainerFromScript(final PicoContainer parentContainer, final Object assemblyScope) {
Interpreter i = new Interpreter();
try {
i.set("parent", parentContainer);
i.set("assemblyScope", assemblyScope);
i.setClassLoader(this.getClassLoader());
i.eval(getScriptReader(), i.getNameSpace(), "picocontainer.bsh");
return (PicoContainer) i.get("pico");
} catch (EvalError e) {
throw new ScriptedPicoContainerMarkupException(e);
} catch (IOException e) {
throw new ScriptedPicoContainerMarkupException(e);
}
}
}
代码示例来源:origin: jpos/jPOS
/** Sets the given arguments to the Interpreter, evaluates the script and
* returns the object stored on the variable named resultName.
*
* @param arguments Parameters to set to the Interpreter. For every
* Map.Entry (key, value), interpreter.set(key, value)
* is called. All keys must be Strings.
*/
public Object execute(Map arguments, String resultName) throws EvalError, IOException {
Interpreter i = initInterpreter(arguments);
return i.get(resultName);
}
代码示例来源:origin: jitlogic/zorka
/**
Unchecked get for internal use
*/
Object getu( String name ) {
try {
return get( name );
} catch ( EvalError e ) {
throw new InterpreterError("set: "+e);
}
}
代码示例来源:origin: jdmp/java-data-mining-package
public Object get(String name) {
try {
return interpreter.get(name);
} catch (EvalError e) {
e.printStackTrace();
return null;
}
}
代码示例来源:origin: stackoverflow.com
Interpreter interpreter = new Interpreter();
interpreter.eval("result = (7+21*6)/(32-27)");
System.out.println(interpreter.get("result"));
代码示例来源:origin: stackoverflow.com
Interpreter interpreter = new Interpreter();
interpreter.eval("result = 5+4*(7-15)");
System.out.println(interpreter.get("result"));
代码示例来源:origin: stackoverflow.com
Interpreter ip = new Interpreter();
ip.eval("res = 45+5*4-6");
System.out.print(ip.get("res"));
代码示例来源:origin: stackoverflow.com
public static void bsh() throws EvalError {
String expression = "input=2+2-5";
String value = " ";
Interpreter i = new Interpreter();
try {
i.eval(expression);
} catch (EvalError evalError) {
evalError.printStackTrace();
}
value = String.valueOf((Integer)i.get("input"));
System.out.println(value);
}
代码示例来源:origin: org.zkoss.zk/zk
protected Object get(String name) {
try {
return unwrap(_ip.get(name));
} catch (EvalError ex) {
throw UiException.Aide.wrap(ex);
}
}
代码示例来源:origin: stackoverflow.com
import bsh.EvalError;
import bsh.Interpreter;
public class BeanShellInterpreter {
public static void main(String[] args) throws EvalError {
Interpreter i = new Interpreter(); // Construct an interpreter
i.set("x", 5);
// Eval a statement and get the result
i.eval("eq1 = (-3.874999999999* Math.pow(x, 4.0) + 48.749999999993* Math.pow(x, 3.0))");
System.out.println( i.get("eq1") );
}
}
代码示例来源:origin: stackoverflow.com
Interpreter interpreter = new Interpreter();
interpreter.eval("x = 50");
interpreter.eval("result = 100 - x + 200");
System.out.println(interpreter.get("result"));
代码示例来源:origin: Fanping/iveely.search
/**
* Dynamic execut javascript
* @param code code
* @return response
*/
public static String eval(String code) {
Interpreter interpreter = new Interpreter();
try {
interpreter.set("string", interpreter.eval(code).toString());
return (String) interpreter.get("string");
} catch (EvalError e) {
e.printStackTrace();
return null;
}
}
代码示例来源:origin: jpos/jPOS
public Object in (Object key) {
try {
Interpreter bsh = initInterpreter (key);
synchronized (sp) {
if (eval (bsh, inScript, inSource)) {
return bsh.get ("value");
} else {
return sp.in (key);
}
}
} catch (Throwable t) {
throw new SpaceError (t);
}
}
public Object rd (Object key) {
代码示例来源:origin: jpos/jPOS
public Object in (Object key, long timeout) {
try {
Interpreter bsh = initInterpreter (key, timeout);
synchronized (sp) {
if (eval (bsh, inScript, inSource)) {
return bsh.get ("value");
} else {
return sp.in (key, timeout);
}
}
} catch (Throwable t) {
throw new SpaceError (t);
}
}
public Object rd (Object key, long timeout) {
代码示例来源:origin: jpos/jPOS
public Object rd (Object key, long timeout) {
try {
Interpreter bsh = initInterpreter (key, timeout);
synchronized (sp) {
if (eval (bsh, rdScript, rdSource)) {
return bsh.get ("value");
} else {
return sp.rd (key, timeout);
}
}
} catch (Throwable t) {
throw new SpaceError (t);
}
}
public Object inp (Object key) {
代码示例来源:origin: jpos/jPOS
public Object rd (Object key) {
try {
Interpreter bsh = initInterpreter (key);
synchronized (sp) {
if (eval (bsh, rdScript, rdSource)) {
return bsh.get ("value");
} else {
return sp.rd (key);
}
}
} catch (Throwable t) {
throw new SpaceError (t);
}
}
public Object in (Object key, long timeout) {
代码示例来源:origin: jpos/jPOS
public Object inp (Object key) {
try {
Interpreter bsh = initInterpreter (key);
bsh.set ("probe", true);
synchronized (sp) {
if (eval (bsh, inScript, inSource)) {
return bsh.get ("value");
} else {
return sp.inp (key);
}
}
} catch (Throwable t) {
throw new SpaceError (t);
}
}
public Object rdp (Object key) {
内容来源于网络,如有侵权,请联系作者删除!