FromRequest.java
2.0 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
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);
}
}