⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 expression.java

📁 一个工作流的原型
💻 JAVA
字号:
/* * Expression.java * * Created on 2005年1月9日, 上午10:17 */package workflow.xwfbox.tools;import java.util.Vector;import org.apache.oro.text.regex.*;/** * * @author  Administrator */public class Expression {        /** Creates a new instance of Expression */    public Expression() {    }        public Vector ParseCondition(String condtion) {        Vector cond = new Vector();        PatternCompiler compiler;        PatternMatcher matcher;        Pattern pattern   = null;        String expression = "(\\D[a-zA-Z0-9_]*)\\s*(>=|<=|!=|<|>|==|)\\s*\\\"([^\"]*)\\\"";        // Create Perl5Compiler and Perl5Matcher instances.        compiler = new Perl5Compiler();        matcher  = new Perl5Matcher();                try {          pattern = compiler.compile(expression);        } catch(MalformedPatternException e) {          System.err.println("Bad pattern.");          System.err.println(e.getMessage());        }                if(matcher.matches(condtion, pattern)) {          System.out.println("matches() Result: TRUE, EXACT MATCH");          MatchResult result = matcher.getMatch();          int i = result.groups();          cond.add(result.group(1));          cond.add(result.group(2));          cond.add(result.group(3));        } else           System.out.println("matches() Result: FALSE, NOT EXACT MATCH");                return cond;    }        public static boolean computeExpression(String var1,String oper, String var2) {        if (oper.equals("==")) {            if (var1.compareTo(var2) == 0) return true; else return false;        } else if (oper.equals("!=")) {            if (var1.compareTo(var2) != 0) return true; else return false;        } else if (oper.equals("<")) {            if (var1.compareTo(var2) < 0) return true; else return false;        } else if (oper.equals(">")) {            if (var1.compareTo(var2) > 0) return true; else return false;        } else if (oper.equals(">=")) {            if (var1.compareTo(var2) >= 0) return true; else return false;        } else if (oper.equals("<=")) {            if (var1.compareTo(var2) <= 0) return true; else return false;        }        return false;    }}

⌨️ 快捷键说明

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