542ae99c865fac954edb369e120d974b0c01cd56.svn-base 2.0 KB
package com.espeed.reading.util;

/**
 * 
* 
* @项目名称: 邮件跟踪系统
* @版权所有: 深圳市科飞时速网络技术有限公司(0755-88843776) 
* @技术支持: info@21gmail.com 
* @单元名称: 来源分析
* @开始时间: 2018-6-4
* @开发人员: 杨志钊
 */
public enum FromRequest {
	GOOGLEPLUS(1, "plus.google.com", "google+"),
	TWITTER(1, "twitter.com", "推特"),
	FACEBOOK(1, "facebook.com", "facebook"),
	YOUTUBE(1, "youtube.com", "youtube"),
	WHATSAPP(1, "whatsapp.com", "whatsapp"),
	WECHAT(1, "weixin.qq.com", "微信"),
	QQ(1, "qq.com", "QQ"),
	WEIBO(1, "weibo.com", "微博"),
	PINTEREST(1, "pinterest.com", "pinterest"),
	INSTAGRAM(1, "instagram.com", "instagram"),
	IUMBLR(1, "iumblr.com", "iumblr"),
	VK(1, "vk.com", "VK"),
	MIXI(1, "mixi.jp", "mixi"),
	TUENTI(1, "tuenti.com", "tuenti"),
	XING(1, "xing.com", "xing"),
	FARK(1, "fark.com", "fark"),
	DIGG(1, "digg.com", "digg"),
	WANELO(1, "wanelo.co", "wanelo"),
	REDDIT(1, "reddit.com", "reddit"),
	LINKEDIN(1, "linkedin.com", "领英"),
	
	
	BAIDU(2, "baidu.com", "百度"), 
	SO(2, "so.com", "360"), 
	SOGOU(2, "sogou.com", "搜狗"), 
	GOOGLE(2, "google.com", "谷歌"), 
	BING(2, "bing.com", "必应"), 
	YAHOO(2, "yahoo.com", "雅虎");

	

	// 获取来源类别,-1无来源url、0:外链、1社交、2搜索、3邮件
	private int type;
	private String domain;
	private String name;

	private FromRequest(int type, String domain, String name) {
		this.type = type;
		this.domain = domain;
		this.name = name;
	}

	public static FromRequest getFrom(String domain) {

		FromRequest from = null;

		FromRequest[] froms = values();
		for (FromRequest fromRequest : froms) {
			if (domain.contains(fromRequest.getDomain())) {
				from = fromRequest;
				break;
			}
		}

		return from;
	}

	public int getType() {
		return type;
	}

	public String getDomain() {
		return domain;
	}

	public String getName() {
		return name;
	}

	public static void main(String[] args) {
		System.out.println(getFrom("www.b1ing.com").type);
	}
}