package com.steerinfo.util;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;

public class DoChinFilters {
    public static String doChinFilters(String[] filters, String target){
        String[] res = null;
        if(filters.length > 0) {
            List<String> tempList = Arrays.asList(filters);
            //Arrays.asList(filters) 迭代器实现类 不支持remove() 删除，多一步转化
            List<String> arrList = new ArrayList<String>(tempList);
            Iterator<String> it = arrList.iterator();
            while(it.hasNext()) {
                String x = it.next();
                if(x.indexOf(target) != -1) {
                    it.remove();
                }
            }
            res = new String[arrList.size()];
            arrList.toArray(res);
        }
        StringBuffer sb = new StringBuffer();
        for(int i = 0; i < res.length;i++){
            if (i == 0){
                sb.append(res[i]);
            }else {
                sb.append(",");
                sb.append(res[i]);
            }
        }
        String s = sb.toString();
        return s;
    }

}
