本文整理了Java中bsh.Interpreter.set()
方法的一些代码示例,展示了Interpreter.set()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Interpreter.set()
方法的具体详情如下:
包路径:bsh.Interpreter
类名称:Interpreter
方法名:set
[英]Assign the value to the name. name may evaluate to anything assignable. e.g. a variable or field.
[中]将该值指定给名称。名称可以计算为任何可分配的内容。e、 变量或字段。
代码示例来源:origin: org.testng/testng
private void setContext(Interpreter interpreter, Method method, Map<String, String> groups, ITestNGMethod tm) {
try {
interpreter.set("method", method);
interpreter.set("groups", groups);
interpreter.set("testngMethod", tm);
}
catch(EvalError evalError) {
throw new TestNGException("Cannot set BSH interpreter", evalError);
}
}
代码示例来源:origin: spring-projects/spring-framework
@Override
@Nullable
public Object evaluate(ScriptSource script, @Nullable Map<String, Object> arguments) {
try {
Interpreter interpreter = new Interpreter();
interpreter.setClassLoader(this.classLoader);
if (arguments != null) {
for (Map.Entry<String, Object> entry : arguments.entrySet()) {
interpreter.set(entry.getKey(), entry.getValue());
}
}
return interpreter.eval(new StringReader(script.getScriptAsString()));
}
catch (IOException ex) {
throw new ScriptCompilationException(script, "Cannot access BeanShell script", ex);
}
catch (EvalError ex) {
throw new ScriptCompilationException(script, ex);
}
}
代码示例来源:origin: org.jbpm/jbpm-form-modeler-ui
public void populate(Interpreter interpreter) throws EvalError {
if (item != null) {
interpreter.set("item", item);
}
interpreter.set("ctx", this);
}
}
代码示例来源:origin: org.springframework/spring-context
@Override
@Nullable
public Object evaluate(ScriptSource script, @Nullable Map<String, Object> arguments) {
try {
Interpreter interpreter = new Interpreter();
interpreter.setClassLoader(this.classLoader);
if (arguments != null) {
for (Map.Entry<String, Object> entry : arguments.entrySet()) {
interpreter.set(entry.getKey(), entry.getValue());
}
}
return interpreter.eval(new StringReader(script.getScriptAsString()));
}
catch (IOException ex) {
throw new ScriptCompilationException(script, "Cannot access BeanShell script", ex);
}
catch (EvalError ex) {
throw new ScriptCompilationException(script, ex);
}
}
代码示例来源:origin: jpos/jPOS
private Interpreter initInterpreter () throws EvalError {
Interpreter bsh = new Interpreter ();
bsh.set ("sp", sp);
bsh.set ("spacelet", this);
bsh.set ("log", getLog());
return bsh;
}
private Interpreter initInterpreter (Object key) throws EvalError {
代码示例来源:origin: jpos/jPOS
private Interpreter initInterpreter (Object key, long timeout)
throws EvalError
{
Interpreter bsh = initInterpreter (key);
bsh.set ("timeout", timeout);
return bsh;
}
private boolean eval (Interpreter bsh, String script, String source)
代码示例来源:origin: com.bbossgroups.rpc/bboss-rpc
synchronized void createInterpreter() {
// create interpreter just-in-time
if(interpreter == null) {
interpreter=new Interpreter();
try {
interpreter.set("bsh_prot", this);
}
catch(EvalError evalError) {
}
}
}
代码示例来源:origin: jpos/jPOS
private Interpreter initInterpreter (Object key) throws EvalError {
Interpreter bsh = initInterpreter ();
bsh.set ("key", key);
return bsh;
}
private Interpreter initInterpreter (Object key, Object value)
代码示例来源:origin: jpos/jPOS
private Interpreter initInterpreter (Object key, Object value)
throws EvalError
{
Interpreter bsh = initInterpreter (key);
bsh.set ("value", value);
return bsh;
}
private Interpreter initInterpreter
代码示例来源:origin: jpos/jPOS
private Interpreter initInterpreter
(Object key, Object value, long timeout)
throws EvalError
{
Interpreter bsh = initInterpreter (key, value);
bsh.set ("timeout", timeout);
return bsh;
}
private Interpreter initInterpreter (Object key, long timeout)
代码示例来源:origin: beanshell/beanshell
/**
Unchecked set for internal use
*/
void setu(String name, Object value) {
try {
set(name, value);
} catch ( EvalError e ) {
throw new InterpreterError("set: "+e, e);
}
}
代码示例来源:origin: org.jmock/jmock-script
private void defineParameters(Interpreter interpreter, Invocation invocation)
throws EvalError
{
interpreter.set("$this", invocation.getInvokedObject());
for (int i = 0; i < invocation.getParameterCount(); i++) {
interpreter.set("$" + i, invocation.getParameter(i));
}
}
代码示例来源:origin: jmock-developers/jmock-library
private void defineParameters(Interpreter interpreter, Invocation invocation)
throws EvalError
{
interpreter.set("$this", invocation.getInvokedObject());
for (int i = 0; i < invocation.getParameterCount(); i++) {
interpreter.set("$" + i, invocation.getParameter(i));
}
}
代码示例来源:origin: stackoverflow.com
public @ResponseBody void executeJavaCode(@RequestParam("javaEvent")
String javaEvent) {
Interpreter interpreter = new Interpreter();
message = new HashMap();
interpreter.set("message", message);
interpreter.eval(javaEvent);
// do stuff to message
}
代码示例来源:origin: stackoverflow.com
import bsh.Interpreter;
private void runString(String code){
Interpreter interpreter = new Interpreter();
try {
interpreter.set("context", this);//set any variable, you can refer to it directly from string
interpreter.eval(code);//execute code
}
catch (Exception e){//handle exception
e.printStackTrace();
}
}
代码示例来源:origin: org.ofbiz/ofbcore-jira-share
public void declareBean(BSFDeclaredBean bean) throws BSFException {
try {
interpreter.set(bean.name, bean.bean);
} catch (EvalError e) {
throw new BSFException("error declaring bean: " + bean.name + " : " + e.toString());
}
}
代码示例来源: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: ESAPI/esapi-java-legacy
public BeanShellRule(String fileLocation, String id, Pattern path) throws IOException, EvalError {
i = new Interpreter();
i.set("logger", logger);
this.script = getFileContents(ESAPI.securityConfiguration().getResourceFile(fileLocation));
this.id = id;
this.path = path;
}
代码示例来源:origin: org.owasp.esapi/esapi
public BeanShellRule(String fileLocation, String id, Pattern path) throws IOException, EvalError {
i = new Interpreter();
i.set("logger", logger);
this.script = getFileContents( ESAPI.securityConfiguration().getResourceFile(fileLocation));
this.id = id;
this.path = path;
}
代码示例来源:origin: jpos/jPOS-EE
private Interpreter initBSH () throws UtilEvalError, EvalError {
Interpreter bsh = new Interpreter ();
BshClassManager bcm = bsh.getClassManager();
bcm.setClassPath(getServer().getLoader().getURLs());
bcm.setClassLoader(getServer().getLoader());
bsh.set ("qbean", this);
bsh.set ("log", getLog());
bsh.eval (getPersist().getChildTextTrim ("init"));
return bsh;
}
private ISOMsg applyRequestProps (ISOMsg m, Interpreter bsh)
内容来源于网络,如有侵权,请联系作者删除!