Java表达式解析求值程序 jExParser

码农软件 · 软件分类 · 常用工具包 · 2019-08-13 09:13:19

软件介绍

jExParser 一个简单的Java表达式解析求值程序

在jSqlBox项目开发时写的一个简单的Java表达式解析求值程序,支持变量和参数,现将源码抽取出来,没有什么特别优点,唯一的长处就是简单,直接中缀求值,仅三个文件700行源码,无第三方库依赖。因为比较简单而且通常用于二次开发,所以没有做成包发布,如有项目中需要用到把源码拷过去就可以用了。 用法如下(或参考单元测试):

  Map<String, Object> keywords = new HashMap<String, Object>();
  keywords.put("USERNAME", "Tom");
  keywords.put("ID", "001");
  Assert.assertEquals(true, new ExParser().doParse(keywords,
    "(1+2)*3/4>0.1/(9+?) and (userName equals ?) or id equals ?", 100, "Tom", "001"));

ExParser类的doParse()方法解析一个表达式,返回类型可能为Boolean、Long、Double、String、null之一。 目前支持的操作符和函数如下:

>  <  =  >=  <=  
+  -  *  /  
or  and  not  
'  ( )  ?  0~9 . 
equals  equalsIgnoreCase  contains  containsIgnoreCase  
startWith  startWithIgnoreCase  endWith  endWithIgnoreCase

本文地址:https://codercto.com/soft/d/12257.html

The Algorithm Design Manual

The Algorithm Design Manual

Steven S Skiena / Springer / 2011-11-14 / GBP 55.07

....The most comprehensive guide to designing practical and efficient algorithms.... Written by a well-known algorithms researcher who received the IEEE Computer Science and Engineering Teaching Aw......一起来看看 《The Algorithm Design Manual》 这本书的介绍吧!

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

随机密码生成器
随机密码生成器

多种字符组合密码

URL 编码/解码
URL 编码/解码

URL 编码/解码