01: package vicazh.hyperpool.stream.net.http;
02:
03: import java.io.*;
04: import java.net.*;
05: import java.util.*;
06:
07: class MonitorItem implements Serializable {
08:
09: int id;
10:
11: String client;
12:
13: String host;
14:
15: String name;
16:
17: MonitorItem(MonitorConnection connection) {
18: id = connection.hashCode();
19: client = connection.client;
20: List<Session> sessions = connection.getSessions();
21: if (sessions.size() == 0)
22: return;
23: ClientStream stream = sessions.get(0).getClient();
24: if (stream == null)
25: return;
26: String method = stream.getMethod();
27: if (method == null)
28: return;
29: if (method.equalsIgnoreCase("connect")) {
30: host = "https://" + stream.getFile();
31: name = method;
32: } else {
33: try {
34: URL url = new URL(stream.getFile());
35: host = url.getProtocol() + "://" + url.getAuthority();
36: name = method + ' ' + url.getFile();
37: } catch (MalformedURLException e) {
38: name = method + ' ' + stream.getFile();
39: }
40: }
41: }
42:
43: public String toString() {
44: return name;
45: }
46:
47: public boolean equals(Object obj) {
48: return obj instanceof MonitorItem
49: && id == ((MonitorItem) obj).id;
50: }
51: }
|