<commit_before>package net.zz.sql.filter;

import net.zz.dao.params.Order;
import net.zz.dao.params.Order.OrderAD;
import net.zz.dao.params.QueryParams;
import net.zz.dao.params.Where;
import net.zz.dao.params.enums.Restriction;

import javax.servlet.http.HttpServletRequest;
import java.util.Arrays;
import java.util.Enumeration;
import java.util.List;

/**
 * Created by ZaoSheng on 2015/10/25.
 */
public class SqlFilter {
    private HttpServletRequest request;// 为了获取request里面传过来的动态参数
    private String column;
    private Order.OrderAD order;
    Where params = new Where().where();

	/**
	 * 默认构造
	 */
	public SqlFilter(){}
	/**
	 * 带参构造
	 * 
	 * @param request
	 */
	public SqlFilter(HttpServletRequest request) {
		this.request = request;
		addFilter(request);
	}

    public boolean isBlank(String str)
    {
       return null == str || str.trim().isEmpty();
    }

    private void setOrderValue(String prefix)
    {
        switch (order)
        {
            case DESC:
                params.order(column, prefix);
                break;
            case ASC:
                params.order().ASC(column, prefix);
                break;
        }
    }

	/**
	 * 获得添加过滤字段后加上排序字段的Sql
	 * 
	 * @return
	 */
	public void setOrder() {


		if (!isBlank(column) && null != order) {
            int index = column.indexOf(".");
			if ( index < 1) {
                setOrderValue(null);
			}else{
                setOrderValue( column.substring(index));
            }

		} else {
			if (request != null) {
				String s = request.getParameter("sort");
				String o = request.getParameter("order");
				if (isBlank(s) || isBlank(o)) {
					return;
				}
                column = s;
				order = OrderAD.valueOf(o);
                int index = column.indexOf(".");
                if ( index < 1) {
                    setOrderValue( null);
                }else{
                    setOrderValue( column.substring(index));
                }

			}
		}

	}
	/**
	 * 添加过滤
	 * 
	 * @param request
	 */
	public void addFilter(HttpServletRequest request) {
		Enumeration<String> names = request.getParameterNames();
		while (names.hasMoreElements()) {
			String name = names.nextElement();
//            String value = request.getParameter(name);
            String[] values =  request.getParameterValues(name);//需要对应值
            if (values.length > 1 )
            {
                addFilter(name, Arrays.asList(values));
            }else {
                addFilter(name, values[0]);

            }


		}
	}
	

	/**
	 * 添加过滤
	 * 
	 * 举例，name传递：QUERY^t#id^|^EQ
	 * 举例，name传递：QUERY^t#id^!|^EQ
	 *
	 * 举例，value传递：0
	 * 
	 * @param name
	 * @param value
	 */
	public void addFilter(String name, Object value) {

		if (name != null && value != null) {
			if (name.startsWith("QUERY^")) {// 如果有需要过滤的字段
				String[] filterParams = name.split("\\^");
//				String[] filterParams = StringUtils.split(name, "_");
				if (filterParams.length == 4) {
                    String[] ppn =  filterParams[1].split("\\#");
                    String prefix = ppn[0]; //表的别名
					String propertyName = constructCol(ppn[1]);// 要过滤的字段名称
					String ao = filterParams[2];// 操作的逻辑
					String operator = filterParams[3];// SQL操作符
                    Restriction restriction = Restriction.EQ;
                    if (null != operator)
                    {
                        restriction = Restriction.valueOf(operator.toUpperCase());
                        switch (restriction)
                        {
                          case BW:
                              if (value instanceof List) value = ((List) value).toArray();
                              break;
                        }
                    }
                    if ("|".equals(ao)){
                        params.or(propertyName, value, restriction, prefix);
                    }else{
                        params.and(propertyName, value, restriction, prefix);
                    }
				}
			}
		}
	}

	public String constructCol(String str){
		String A = "^[A-Z]";
		StringBuffer col=new StringBuffer();
		for(int i=0;i<str.length();i++){
			//str.charAt(i)
			
			if(String.valueOf(str.charAt(i)).matches(A)){
				col.append("_");
			}
			col.append(str.charAt(i));
		}
		return col.toString();
	}

    public SqlFilter setAlias(String alias) {
        params.setAlias(alias);
        return this;
    }


    public QueryParams getQueryParams() {
        return params;
    }

    public String getColumn() {
        return column;
    }

    public void setColumn(String column) {
        this.column = column;
    }

    public OrderAD getOrder() {
        return order;
    }

    public void setOrder(OrderAD order) {
        this.order = order;
    }


}
<commit_msg>Update the lowercase does not support<commit_after>package net.zz.sql.filter;

import net.zz.dao.params.Order;
import net.zz.dao.params.Order.OrderAD;
import net.zz.dao.params.QueryParams;
import net.zz.dao.params.Where;
import net.zz.dao.params.enums.Restriction;

import javax.servlet.http.HttpServletRequest;
import java.util.Arrays;
import java.util.Enumeration;
import java.util.List;

/**
 * Created by ZaoSheng on 2015/10/25.
 */
public class SqlFilter {
    private HttpServletRequest request;// 为了获取request里面传过来的动态参数
    private String column;
    private Order.OrderAD order;
    Where params = new Where().where();

	/**
	 * 默认构造
	 */
	public SqlFilter(){}
	/**
	 * 带参构造
	 * 
	 * @param request
	 */
	public SqlFilter(HttpServletRequest request) {
		this.request = request;
		addFilter(request);
	}

    public boolean isBlank(String str)
    {
       return null == str || str.trim().isEmpty();
    }

    private void setOrderValue(String prefix)
    {
        switch (order)
        {
            case DESC:
                params.order(column, prefix);
                break;
            case ASC:
                params.order().ASC(column, prefix);
                break;
        }
    }

	/**
	 * 获得添加过滤字段后加上排序字段的Sql
	 * 
	 * @return
	 */
	public void setOrder() {


		if (!isBlank(column) && null != order) {
	            int index = column.indexOf(".");
				if ( index < 1) {
	                setOrderValue(null);
				}else{
	                setOrderValue( column.substring(index));
	            }

		} else {
			if (request != null) {
				String s = request.getParameter("sort");
				String o = request.getParameter("order");
				if (isBlank(s) || isBlank(o)) {
					return;
				}
	                	column = s;
				order = OrderAD.valueOf(o.toUpperCase());
	                	int index = column.indexOf(".");
		                if ( index < 1) {
		                    setOrderValue( null);
		                }else{
		                    setOrderValue( column.substring(index));
		                }

			}
		}

	}
	/**
	 * 添加过滤
	 * 
	 * @param request
	 */
	public void addFilter(HttpServletRequest request) {
		Enumeration<String> names = request.getParameterNames();
		while (names.hasMoreElements()) {
			String name = names.nextElement();
//            String value = request.getParameter(name);
            String[] values =  request.getParameterValues(name);//需要对应值
            if (values.length > 1 )
            {
                addFilter(name, Arrays.asList(values));
            }else {
                addFilter(name, values[0]);

            }


		}
	}
	

	/**
	 * 添加过滤
	 * 
	 * 举例，name传递：QUERY^t#id^|^EQ
	 * 举例，name传递：QUERY^t#id^!|^EQ
	 *
	 * 举例，value传递：0
	 * 
	 * @param name
	 * @param value
	 */
	public void addFilter(String name, Object value) {

		if (name != null && value != null) {
			if (name.startsWith("QUERY^")) {// 如果有需要过滤的字段
				String[] filterParams = name.split("\\^");
//				String[] filterParams = StringUtils.split(name, "_");
				if (filterParams.length == 4) {
                    String[] ppn =  filterParams[1].split("\\#");
                    String prefix = ppn[0]; //表的别名
					String propertyName = constructCol(ppn[1]);// 要过滤的字段名称
					String ao = filterParams[2];// 操作的逻辑
					String operator = filterParams[3];// SQL操作符
                    Restriction restriction = Restriction.EQ;
                    if (null != operator)
                    {
                        restriction = Restriction.valueOf(operator.toUpperCase());
                        switch (restriction)
                        {
                          case BW:
                              if (value instanceof List) value = ((List) value).toArray();
                              break;
                        }
                    }
                    if ("|".equals(ao)){
                        params.or(propertyName, value, restriction, prefix);
                    }else{
                        params.and(propertyName, value, restriction, prefix);
                    }
				}
			}
		}
	}

	public String constructCol(String str){
		String A = "^[A-Z]";
		StringBuffer col=new StringBuffer();
		for(int i=0;i<str.length();i++){
			//str.charAt(i)
			
			if(String.valueOf(str.charAt(i)).matches(A)){
				col.append("_");
			}
			col.append(str.charAt(i));
		}
		return col.toString();
	}

    public SqlFilter setAlias(String alias) {
        params.setAlias(alias);
        return this;
    }


    public QueryParams getQueryParams() {
        return params;
    }

    public String getColumn() {
        return column;
    }

    public void setColumn(String column) {
        this.column = column;
    }

    public OrderAD getOrder() {
        return order;
    }

    public void setOrder(OrderAD order) {
        this.order = order;
    }


}

{'fraction_non_alphanumeric': 0.12908976510067113, 'fraction_numerical': 0.0041946308724832215, 'mean_word_length': 1.7413049726933028, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3016541', 'n_tokens_mistral': 3221, 'n_tokens_neox': 2944, 'n_words': 581}