本文整理汇总了Java中org.ofbiz.base.util.BshUtil类的典型用法代码示例。如果您正苦于以下问题:Java BshUtil类的具体用法?Java BshUtil怎么用?Java BshUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BshUtil类属于org.ofbiz.base.util包,在下文中一共展示了BshUtil类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkWhen
import org.ofbiz.base.util.BshUtil; //导入依赖的package包/类
public static boolean checkWhen(Map<String, Object> context, String whenStr) {
boolean isWhen = true; //opposite default from checkReturnWhen
if (UtilValidate.isNotEmpty(whenStr)) {
FlexibleStringExpander fse = FlexibleStringExpander.getInstance(whenStr);
String newWhen = fse.expandString(context);
//if (Debug.infoOn()) Debug.logInfo("newWhen:" + newWhen,null);
//if (Debug.infoOn()) Debug.logInfo("context:" + context,null);
try {
Boolean isWhenObj = (Boolean) BshUtil.eval(newWhen, context);
isWhen = isWhenObj.booleanValue();
} catch (EvalError e) {
Debug.logError("Error in evaluating :" + whenStr + " : " + e.getMessage(), null);
throw new RuntimeException(e.getMessage());
}
}
//if (Debug.infoOn()) Debug.logInfo("isWhen:" + isWhen,null);
return isWhen;
}
示例2: checkReturnWhen
import org.ofbiz.base.util.BshUtil; //导入依赖的package包/类
public static boolean checkReturnWhen(Map<String, Object> context, String whenStr) {
boolean isWhen = false; //opposite default from checkWhen
if (UtilValidate.isNotEmpty(whenStr)) {
FlexibleStringExpander fse = FlexibleStringExpander.getInstance(whenStr);
String newWhen = fse.expandString(context);
try {
Boolean isWhenObj = (Boolean) BshUtil.eval(newWhen, context);
isWhen = isWhenObj.booleanValue();
} catch (EvalError e) {
Debug.logError("Error in evaluating :" + whenStr + " : " + e.getMessage(), null);
throw new RuntimeException(e.getMessage());
}
}
return isWhen;
}
示例3: getBshInterpreter
import org.ofbiz.base.util.BshUtil; //导入依赖的package包/类
public Interpreter getBshInterpreter(Map<String, Object> context) throws EvalError {
Interpreter bsh = (Interpreter) context.get("bshInterpreter");
if (bsh == null) {
bsh = BshUtil.makeInterpreter(context);
context.put("bshInterpreter", bsh);
}
return bsh;
}
示例4: runAction
import org.ofbiz.base.util.BshUtil; //导入依赖的package包/类
@Override
public void runAction(Map<String, Object> context) {
if (location.endsWith(".bsh")) {
try {
context.put("_LIST_ITERATOR_", null);
BshUtil.runBshAtLocation(location, context);
Object obj = context.get("_LIST_ITERATOR_");
if (this.modelSubNode != null) {
if (obj != null && (obj instanceof EntityListIterator || obj instanceof ListIterator<?>)) {
ListIterator<? extends Map<String, ? extends Object>> listIt = UtilGenerics.cast(obj);
this.modelSubNode.setListIterator(listIt);
} else {
if (obj instanceof List<?>) {
List<? extends Map<String, ? extends Object>> list = UtilGenerics.checkList(obj);
this.modelSubNode.setListIterator(list.listIterator());
}
}
}
} catch (GeneralException e) {
String errMsg = "Error running BSH script at location [" + location + "]: " + e.toString();
Debug.logError(e, errMsg, module);
throw new IllegalArgumentException(errMsg);
}
} else {
throw new IllegalArgumentException("For tree script actions the script type is not yet support for location:" + location);
}
}