1 package us.codecraft.webmagic;
2
3 import java.util.LinkedHashMap;
4 import java.util.Map;
5
6
7
8
9
10
11
12
13
14
15 public class ResultItems {
16
17 private Map<String, Object> fields = new LinkedHashMap<String, Object>();
18
19 private Request request;
20
21 private boolean skip;
22
23 @SuppressWarnings("unchecked")
24 public <T> T get(String key) {
25 Object o = fields.get(key);
26 if (o == null) {
27 return null;
28 }
29 return (T) fields.get(key);
30 }
31
32 public Map<String, Object> getAll() {
33 return fields;
34 }
35
36 public <T> ResultItems put(String key, T value) {
37 fields.put(key, value);
38 return this;
39 }
40
41 public Request getRequest() {
42 return request;
43 }
44
45 public ResultItems setRequest(Request request) {
46 this.request = request;
47 return this;
48 }
49
50
51
52
53
54
55
56 public boolean isSkip() {
57 return skip;
58 }
59
60
61
62
63
64
65
66
67
68 public ResultItems setSkip(boolean skip) {
69 this.skip = skip;
70 return this;
71 }
72
73 @Override
74 public String toString() {
75 return "ResultItems{" +
76 "fields=" + fields +
77 ", request=" + request +
78 ", skip=" + skip +
79 '}';
80 }
81 }