com.jfplugin.xsql.statement.IsTrueStatement Maven / Gradle / Ivy
The newest version!
package com.jfplugin.xsql.statement;
import ognl.Ognl;
import org.w3c.dom.Node;
import com.jfplugin.xsql.core.Context;
import com.jfplugin.xsql.exception.ExpException;
/**
* test - 检测的语句
* @author farmer
*
*/
public class IsTrueStatement extends Statement{
public IsTrueStatement(Node node) {
super(node);
}
@Override
public void execute(Context ctx, Object localVar) {
String test = attr("test");
try {
Boolean value = false;
try {
value = (Boolean) Ognl.getValue(test, localVar); //先检本地变量,在检测全局变量。
} catch (Exception e) {
value = (Boolean) Ognl.getValue(test, ctx.globalVar);
}
if(value){
ctx.sw.append(test);
for (Statement child : children) {
child.execute(ctx, localVar);
}
}
} catch (Exception e) {
throw new ExpException("表达式异常"+test,e);
}
}
}