blob: ac4f96d6385744952065ea0f2df389e32cfb68b0 (
plain)
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
87
88
89
90
91
92
93
94
95
96
97
98
99
|
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.security.MessageDigest;
import java.net.URL;
public class ICSParser
{
public static void parse
(
final String url,
final Group group,
final boolean lazy,
final boolean uid_override
)
throws Exception
{
final BufferedReader reader;
final StringBuilder sb;
boolean should_record, has_id, ignore_line;
String line;
String class_name;
String hash_seed;
int length;
sb = new StringBuilder();
reader =
new BufferedReader(new InputStreamReader((new URL(url)).openStream()));
class_name = "unknown";
should_record = false;
ignore_line = false;
hash_seed = "";
has_id = false;
while ((line = reader.readLine()) != null)
{
if (line.startsWith("END:VEVENT"))
{
if (!has_id)
{
sb.append("UID:noid_");
sb.append(hash_seed.hashCode());
sb.append("\r\n");
}
sb.append(line);
sb.append("\r\n");
should_record = false;
group.add_ICS_fragment(sb.toString(), class_name, lazy);
sb.setLength(0);
}
else if (line.startsWith("BEGIN:VEVENT"))
{
should_record = true;
has_id = false;
hash_seed = "";
}
else if (line.startsWith("DTSTART:"))
{
hash_seed += line;
}
else if (line.startsWith("SUMMARY:"))
{
class_name = line.substring(8, line.length());
hash_seed += line;
}
else if (line.startsWith("UID"))
{
if (uid_override)
{
ignore_line = true;
}
else
{
has_id = true;
}
}
if (line.matches("\\w+:.*") && should_record)
{
if (!ignore_line)
{
sb.append(line);
sb.append("\r\n");
}
ignore_line = false;
}
}
reader.close();
}
}
|