壹佰网|ERP100 - 企业信息化知识门户

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1777|回复: 3

不好意思,我实在看不明白,有人能帮忙解释一下这个方法是干什么用的吗?

[复制链接]
发表于 2009/9/25 00:18:30 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。如果您注册时有任何问题请联系客服QQ: 83569622  。

您需要 登录 才可以下载或查看,没有帐号?注册

x
不好意思,我实在看不明白,有人能帮忙解释一下这个方法是干什么用的吗?compiere的源码

Java code


    /**
    * Evaluate @context@=value or @context@!value or @context@^value.
    * <pre>
    * value: strips ' and " always (no escape or mid stream)
    * value: can also be a context variable
    * </pre>
    * @param source class implementing get_ValueAsString(variable)
    * @param logic logic tuple
    * @return true or false
    */
    private static boolean evaluateLogicTuple (Evaluatee source, String logic)
    {
    StringTokenizer st = new StringTokenizer (logic.trim(), "!=^><", true);
    if (st.countTokens() != 3)
    {
    log.warning("Logic tuple does not comply with format "
    + "'@context@=value' where operand could be one of '=!^><' => " + logic);
    return false;
    }
    // First Part
    String first = st.nextToken().trim(); // get '@tag@'
    String firstEval = first.trim();
    if (first.indexOf('@') != -1) // variable
    {
    first = first.replace ('@', ' ').trim (); // strip 'tag'
    firstEval = source.get_ValueAsString (first); // replace with it's value
    if (firstEval == null)
    firstEval = "";
    }
    firstEval = firstEval.replace('\'', ' ').replace('"', ' ').trim(); // strip ' and "

    // Comperator
    String operand = st.nextToken();

    // Second Part
    String second = st.nextToken(); // get value
    String secondEval = second.trim();
    if (second.indexOf('@') != -1) // variable
    {
    second = second.replace('@', ' ').trim(); // strip tag
    secondEval = source.get_ValueAsString (second); // replace with it's value
    if (secondEval == null)
    secondEval = "";
    }
    secondEval = secondEval.replace('\'', ' ').replace('"', ' ').trim(); // strip ' and "

    // Handling of ID compare (null => 0)
    if (first.indexOf("_ID") != -1 && firstEval.length() == 0)
    firstEval = "0";
    if (second.indexOf("_ID") != -1 && secondEval.length() == 0)
    secondEval = "0";

    // Logical Comparison
    boolean result = evaluateLogicTuple (firstEval, operand, secondEval);
    //
    if (log.isLevelFinest())
    log.finest(logic
    + " => \"" + firstEval + "\" " + operand + " \"" + secondEval + "\" => " + result);
    //
    return result;
    } // evaluateLogicTuple



代码来自:https://svn.bitsoftware.ro:8443/ ... util/Evaluator.java
发表于 2009/9/25 09:27:33 | 显示全部楼层
1# lord
一个通用的校验逻辑表达式
 楼主| 发表于 2009/9/25 23:10:51 | 显示全部楼层
谢谢楼上,能再详细一点吗,是什么逻辑,什么意思来着??
发表于 2009/9/27 21:45:59 | 显示全部楼层
,如果你在一个字段中写了一个只读或可视逻辑,那么逻辑中的判断就是走这个函数的.
@context@=value
前部分就是上下文变量,后面是确定的值
举个例子来说吧
@#AD_Org_ID@=1000012
表示登录组织是1000012的那么逻辑返回真。
大概是这么个意思
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|Archiver|小黑屋|手机版|壹佰网 ERP100 ( 京ICP备19053597号-2 )

Copyright © 2005-2012 北京海之大网络技术有限责任公司 服务器托管由互联互通
手机:13911575376
网站技术点击发送消息给对方83569622   广告&合作 点击发送消息给对方27675401   点击发送消息给对方634043306   咨询及人才点击发送消息给对方138011526

GMT+8, 2025/11/29 02:35 , Processed in 0.015580 second(s), 14 queries , File On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表