<commit_before>package com.eplian.wechat.component;

/**
 * Created with IntelliJ IDEA.
 * User: bird
 * Date: 13-9-1
 * Time: 下午10:46
 * To change this template use File | Settings | File Templates.
 */
import com.eplian.wechat.core.message.receive.RecvMsg;
import com.eplian.wechat.component.Rule;
import com.eplian.wechat.service.WXService;

import java.lang.Class;
import java.util.List;
import java.util.Iterator;

public class Dispatcher {
    private WXService serivce = null;
    public Dispatcher(RecvMsg msg,List<Rule> rules){
        String type = msg.getMsgType();
        String content =  msg.getContent();
        //遍历规则
        Iterator it = rules.iterator();
        while (it.hasNext()){
            Rule rule = (Rule)it.next();
            if(rule.getType().equals(type)){
                if(type.equals("text")
                        && !rule.getContent().equals("")
                        && !rule.getContent().equals(content))
                    continue;
                try{
                    Class<?> serviceClass = Class.forName(rule.getService());
                    this.serivce = (WXService)serviceClass.newInstance();
                }catch (Exception e) {
                    e.printStackTrace();
                }
                break;
            }
        }

    }
    public WXService getSerivce(){
        return this.serivce;
    }

}
<commit_msg>只根据值转发到service<commit_after>package com.eplian.wechat.component;

/**
 * Created with IntelliJ IDEA.
 * User: bird
 * Date: 13-9-1
 * Time: 下午10:46
 * To change this template use File | Settings | File Templates.
 */
import com.eplian.wechat.core.message.receive.RecvMsg;
import com.eplian.wechat.component.Rule;
import com.eplian.wechat.service.WXService;

import java.lang.Class;
import java.util.List;
import java.util.Iterator;

public class Dispatcher {
    private WXService serivce = null;
    public Dispatcher(String value,List<Rule> rules){
        //遍历规则
        Iterator it = rules.iterator();
        while (it.hasNext()){
            Rule rule = (Rule)it.next();
            if(rule.getValue().equals(value)){
                try{
                    Class<?> serviceClass = Class.forName(rule.getService());
                    this.serivce = (WXService)serviceClass.newInstance();
                }catch (Exception e) {
                    e.printStackTrace();
                }
                break;
            }
        }

    }
    public WXService getSerivce(){
        return this.serivce;
    }

}

{'fraction_non_alphanumeric': 0.11534025374855825, 'fraction_numerical': 0.006151480199923107, 'mean_word_length': 1.765143464399575, 'pattern_counts': {'":': 0, '<': 7, '<?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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6431851', 'n_tokens_mistral': 799, 'n_tokens_neox': 764, 'n_words': 150}