<commit_before>package com.dtstack.logstash.utils;

import java.util.Map;
import java.util.Set;

import org.joda.time.DateTimeZone;


/**
 * 
 * Reason: TODO ADD REASON(可选)
 * Date: 2016年12月09日 下午11:27:03
 * Company: www.dtstack.com
 * @author sishu.yss
 *
 */
public class BasePluginUtil {
	
		public void addFields(Map<String,Object> event,Map<String,Object> addFields){
			Set<Map.Entry<String,Object>> sets =addFields.entrySet();
			for(Map.Entry<String,Object> entry:sets){
				String key = entry.getKey();
				if(event.get(key)==null){
					Object value = entry.getValue();
					event.put(key, value);
					if(event.get(value)!=null){
						event.put(key, event.get(value));
					}else if(value instanceof String){
						String vv =value.toString();
						if(vv.indexOf(".")>0){
							String[] vs=vv.split("\\.");
							Object oo = event;
							for(int i=0;i<vs.length;i++){
								oo = loopObject(vs[i],oo);
								if(oo==null)break;	
							}
							if(oo!=null)event.put(key, oo);	
						}else if ("%{hostname}%".equals(vv)){
		        			event.put(key, Public.getHostName());
		        		}else if("%{timestamp}%".equals(vv)){
		        			event.put(key,Public.getTimeStamp(null));
		        		}else if("%{timestamp-utc}%".equals(vv)){
		        			event.put(key,Public.getTimeStamp(DateTimeZone.UTC));
		        		}else if("%{ip}%".equals(vv)){
		        			event.put(key, Public.getHostAddress());
		        		}
		            }
				} 
			}
	    }
	  
		@SuppressWarnings("unchecked")
		private Object loopObject(String value,Object obj){
			if(obj instanceof Map){
				return ((Map<String,Object>)obj).get(value);
			} 
	        return null;
		}

}<commit_msg>bug fix<commit_after>package com.dtstack.logstash.utils;

import java.util.Map;
import java.util.Set;

import org.joda.time.DateTimeZone;


/**
 * 
 * Reason: TODO ADD REASON(可选)
 * Date: 2016年12月09日 下午11:27:03
 * Company: www.dtstack.com
 * @author sishu.yss
 *
 */
public class BasePluginUtil {
	
		public void addFields(Map<String,Object> event,Map<String,Object> addFields){
			Set<Map.Entry<String,Object>> sets =addFields.entrySet();
			for(Map.Entry<String,Object> entry:sets){
				String key = entry.getKey();
				if(event.get(key)==null){
					Object value = entry.getValue();
					event.put(key, value);
					if(event.get(value)!=null){
						event.put(key, event.get(value));
					}else if(value instanceof String){
						String vv =value.toString();
						if(vv.indexOf(".")>0){
							String[] vs=vv.split("\\.");
							Object oo = event;
							for(int i=0;i<vs.length;i++){
								oo = loopObject(vs[i],oo);
								if(oo==null)break;	
							}
							if(oo!=null)event.put(key, oo);	
						}else if ("%{hostname}%".equals(vv)){
		        			event.put(key, Public.getHostName());
		        		}else if("%{timestamp}%".equals(vv)){
		        			event.put(key,Public.getTimeStamp(null));
		        		}else if("%{timestamp-utc}%".equals(vv)){
		        			event.put(key,Public.getTimeStamp(DateTimeZone.UTC));
		        		}else if("%{ip}%".equals(vv)){
		        			event.put(key, Public.getHostAddress());
		        		}
		            }
				} 
			}
	    }
	  
		@SuppressWarnings("unchecked")
		private Object loopObject(String value,Object obj){
			if(obj instanceof Map){
				return ((Map<String,Object>)obj).get(value);
			} 
	        return null;
		}
}
{'fraction_non_alphanumeric': 0.17399103139013453, 'fraction_numerical': 0.009566517189835576, 'mean_word_length': 2.7385474860335197, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '1888182', 'n_tokens_mistral': 1457, 'n_tokens_neox': 1165, 'n_words': 185}