逻辑拼接
来源:互联网 发布:c语言switch case语句 编辑:程序博客网 时间:2024/05/23 10:01
import java.util.ArrayList;import java.util.List;public class LogicalMdxTest {public static void main(String[] args) {String[] input = new String[] { "a and b or c and d or e", "a", "a and b", "a or b", "a and b and c","a or b or c", "a and b and c or d", "a or b and c and d" };for (String item : input) {List<LogicalMdx> mdx = getMdx(item);System.out.println(item);String mdxStr = getMdxStr(mdx);System.out.println(mdxStr);if (item.equals(mdxStr)) {System.out.println("Success-----");} else {System.out.println("Failed----");}}}private static String getMdxStr(List<LogicalMdx> mdx) {StringBuilder sb = new StringBuilder();for (LogicalMdx item : mdx) {sb.append(item.getPrefix());sb.append(item.getContent());}return sb.toString();}private static List<LogicalMdx> getMdx(String input) {List<LogicalMdx> result = new ArrayList<LogicalMdx>();String[] ands = input.split(" and ");LogicalMdx item = new LogicalMdx();for (int i = 0; i < ands.length; i++) {String and = ands[i];if (i > 0) {item.setPrefix(" and ");}String[] ors = and.split(" or ");for (int j = 0; j < ors.length; j++) {String or = ors[j];if (j > 0) {item.setPrefix(" or ");}item.setContent(or);result.add(item);item = new LogicalMdx();}}return result;}}
阅读全文
0 0
- 逻辑拼接
- Python 字符串拼接、逻辑连接符
- 拼接
- 拼接
- 逻辑
- 逻辑
- 逻辑
- 逻辑
- 逻辑
- 图像拼接-硬拼接
- 图象拼接
- 图片拼接!
- 拼接sql
- 拼接显示
- 图像拼接
- 拼接字符串:
- SQL 拼接
- 字符串拼接
- 文章标题
- Mac安装sci-image报错
- python 的logging ,os模块, command模块 , sys模块
- 在线源码管理svn git
- dubbo-admin 在linux 、jdk8 、tomcat7中部署问题总结
- 逻辑拼接
- 小结
- printf与a++那些不得不说的事儿
- zip压缩工具
- 从xml文件中获取Bean的方法
- A
- iOS 友盟统计~统计界面次数
- matllab处理三维点云
- mysql 数据库常用配置