conditionbizatomstatement.java

来自「这个是使用java开发的一个平台」· Java 代码 · 共 75 行

JAVA
75
字号
package com.exp.bizatom.auto.statement;

import com.exp.bizatom.auto.BizAutoAtomLogic;
import com.exp.bizatom.auto.BizAutoAtomUtil;
import com.exp.bizatom.auto.FunctionStack;
import com.exp.fcl.xml.EXPXMLNode;

public class ConditionBizAtomStatement extends BizAtomStatement {
    protected String depend;

    protected String rule;

    protected void parse(EXPXMLNode node) {
        this.depend = node.getAttributeValue("depend");
        this.rule = node.getAttributeValue("rule");
    }

    public Object create() {
        ConditionBizAtomStatement ret = new ConditionBizAtomStatement();
        ret.depend = this.depend;
        ret.rule = this.rule;
        return ret;
    }

    public int execute(BizAutoAtomLogic function, int row)
            throws java.lang.Throwable {
        boolean bMatch = false;
        if (!"".equals(depend)) {
            Object vo = BizAutoAtomUtil.getRealValue(function.getStack(),
                    this.depend);

            if (vo != null) {
                bMatch = this.matchRule(vo.toString(), this.rule, function
                        .getStack());
            } else {
                bMatch = this.matchRule(null, this.rule, function.getStack());
            }
        }
        return bMatch ? 101 : 102;
    }

    protected boolean matchRule(String dependValue, String disableRule,
            FunctionStack stack) {
        if ("".equals(disableRule)) {
            return false;
        }
        if ("null".equalsIgnoreCase(disableRule)) {
            if (dependValue == null) {
                return true;
            }
        } else if ("empty".equalsIgnoreCase(disableRule)) {
            if ("".equals(dependValue)) {
                return true;
            }
        } else if (disableRule.startsWith("!")) {
            String ref = disableRule.substring(1);
            Object exceptedValue = BizAutoAtomUtil.getRealValue(stack, ref);
            if (exceptedValue == null) {
                return dependValue != null;
            } else {
                return !exceptedValue.equals(dependValue);
            }
        } else {
            Object exceptedValue = BizAutoAtomUtil.getRealValue(stack,
                    disableRule);
            if (exceptedValue == null) {
                return dependValue == null;
            } else {
                return exceptedValue.equals(dependValue);
            }
        }
        return false;
    }

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?