FilterUtils { public static IFilter createFilter(String where) { if (StringUtils.isEmpty(where)) { return null; } MySqlExprVisitor visitor = MySqlExprVisitor.parser(where); Object value = visitor.getColumnOrValue(); if (value instanceof IFilter) { return (IFilter) value; } else if (value instanceof ISelectable) { throw new IllegalArgumentException("illegal filter:" + where); } else { return visitor.buildConstanctFilter(value); } }  static IFilter toDNFAndFlat(IFilter node); static IFilter toDNF(IFilter node); static List<List<IFilter>> toDNFNodesArray(IFilter node); static List<IFilter> toDNFNode(IFilter node); static Map<Object, List<IFilter>> toColumnFiltersMap(List<IFilter> DNFNode); static boolean isDNF(IFilter node); static boolean isCNFNode(IFilter node); static IFilter merge(IFilter filter); static IFilter DNFToOrLogicTree(List<List<IFilter>> DNFNodes); static IFilter DNFToAndLogicTree(List<IFilter> DNFNode); static IFilter and(IFilter root, IFilter o); static IFilter or(IFilter root, IFilter o); static IBooleanFilter equal(Object columnName, Object value); static boolean isConstFilter(IBooleanFilter f); static IFilter createFilter(String where); static boolean isConstValue(Object v); static Object getFilterColumn(IFilter filter);  }
@Test public void testCreateFilter() { String where = "id > 1 and id <= 10"; IFilter filter = FilterUtils.createFilter(where); System.out.println(filter); where = "name = 'hello' and id in ('1','2')"; filter = FilterUtils.createFilter(where); System.out.println(filter); where = "gmt_create = '2013-11-11 11:11:11'"; filter = FilterUtils.createFilter(where); System.out.println(filter); where = "1+1"; filter = FilterUtils.createFilter(where); System.out.println(filter); }