Skip to content

Commit 5983e00

Browse files
committed
update
1 parent 806c128 commit 5983e00

File tree

1 file changed

+61
-1
lines changed

1 file changed

+61
-1
lines changed

src/main/java/scheduler/ParserTask.java

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,73 @@
33
import java.util.regex.Matcher;
44
import java.util.regex.Pattern;
55

6+
import org.apache.log4j.Logger;
7+
import org.apache.log4j.PropertyConfigurator;
8+
69
public class ParserTask implements Comparable<ParserTask>{
710
private static final String submissionListURL = ".*/submissions/$"; // 检验是否是题目提交列表页面
811
private static final String problemCodeURL = ".*/submissions/detail/.*"; // 检验是否是题目代码页面
912
private static final String problemListURL = ".*/problemset/algorithms/$"; // 检验是否是题目列表页面
10-
13+
private Logger myLog;
14+
15+
/**
16+
*
17+
* TaskType
18+
* 2015年4月7日 上午10:35:07
19+
*
20+
* @version 1.0.0
21+
*
22+
*/
1123
static enum TaskType {
1224
GET_PROBLEM_LIST_URL, GET_SUBMISION_URL, GET_CODE_URL, GET_CODE
1325
}
1426

1527
private String url;
1628
private TaskType type;
1729

30+
/**
31+
*
32+
* 创建一个新的实例 ParserTask.
33+
*
34+
* @param url
35+
*/
1836
public ParserTask(String url) {
37+
PropertyConfigurator.configure("test.log");
38+
myLog = Logger.getLogger(ParserTask.class);
1939
this.url = url;
2040
}
2141

42+
/**
43+
*
44+
* getUrl(获取url属性)
45+
* @return
46+
*String
47+
* @exception
48+
* @since 1.0.0
49+
*/
2250
public String getUrl() {
2351
return this.url;
2452
}
2553

54+
/**
55+
*
56+
* getType(获取type属性)
57+
* @return
58+
*TaskType
59+
* @exception
60+
* @since 1.0.0
61+
*/
62+
public TaskType getType() {
63+
return this.type;
64+
}
65+
66+
/**
67+
*
68+
* isType(设置task的type属性)
69+
*void
70+
* @exception
71+
* @since 1.0.0
72+
*/
2673
public void isType() {
2774
if (checkPattern(url, problemListURL)) {
2875
type = TaskType.GET_PROBLEM_LIST_URL;
@@ -35,13 +82,26 @@ public void isType() {
3582
}
3683
}
3784

85+
/**
86+
*
87+
* checkPattern(判断url是否是patternString类型)
88+
* @param url
89+
* @param patternString
90+
* @return
91+
*boolean
92+
* @exception
93+
* @since 1.0.0
94+
*/
3895
public boolean checkPattern(String url, String patternString) {
3996
Pattern pattern = Pattern.compile(patternString);
4097
Matcher matcher = pattern.matcher(url);
4198
boolean res = matcher.matches();
4299
return res;
43100
}
44101

102+
/**
103+
* 复写Comparable接口方法
104+
*/
45105
public int compareTo(ParserTask o) {
46106
return o.type.ordinal()-this.type.ordinal();
47107
}

0 commit comments

Comments
 (0)