@@ -17,164 +17,168 @@ public class VertretungsHandle {
17
17
18
18
public static ArrayList <String > getSource (String klasse , String woche ) {
19
19
20
- String url = "http://mpg-vertretungsplan.de/w/" + woche + "/" + klasse + ".htm" ;
20
+ String url = "http://mpg-vertretungsplan.de/w/" + woche + "/" + klasse + ".htm" ;
21
21
22
- Document doc = null ;
23
- try {
24
- doc = Jsoup .connect (url ).get ();
25
- } catch (IOException e ) {
26
- e .printStackTrace ();
27
- }
22
+ if (DoesUrlExist .exists (url )) {
23
+
24
+ Document doc = null ;
25
+ try {
26
+ doc = Jsoup .connect (url ).get ();
27
+ } catch (IOException e ) {
28
+ e .printStackTrace ();
29
+ }
28
30
29
- ArrayList <String > returnment = new ArrayList <>();
30
- for (String s : doc .toString ().replace ("\" " , "" ).split ("\n " ))
31
- {
32
- returnment .add (s );
31
+ ArrayList <String > returnment = new ArrayList <>();
32
+ for (String s : doc .toString ().replace ("\" " , "" ).split ("\n " )) {
33
+ returnment .add (s );
34
+ }
35
+ return returnment ;
36
+ }else {
37
+ System .out .println ("Achtung! URL " +url .toString ()+" wurde nicht gefunden!" );
38
+ return null ;
33
39
}
34
- return returnment ;
35
40
}
36
41
42
+
37
43
public static void sortDays (ArrayList <String > days ) {
38
44
39
- // Monday
45
+ // Monday
40
46
41
- int mondayint = 0 ;
42
- boolean mondaybool = false ;
43
- ArrayList <String > monday = new ArrayList <>();
47
+ int mondayint = 0 ;
48
+ boolean mondaybool = false ;
49
+ ArrayList <String > monday = new ArrayList <>();
44
50
45
- for (String s : days ) {
51
+ for (String s : days ) {
46
52
47
- if (s .contains ("<a name=2>" )) {
48
- mondaybool = false ;
49
- }
53
+ if (s .contains ("<a name=2>" )) {
54
+ mondaybool = false ;
55
+ }
50
56
51
- if (mondaybool == true ) {
52
- monday .add (days .get (mondayint ));
53
- }
57
+ if (mondaybool == true ) {
58
+ monday .add (days .get (mondayint ));
59
+ }
54
60
55
- if (s .contains ("<a name=1>" )) {
56
- monday .add (days .get (mondayint ));
57
- mondaybool = true ;
61
+ if (s .contains ("<a name=1>" )) {
62
+ monday .add (days .get (mondayint ));
63
+ mondaybool = true ;
64
+ }
65
+ mondayint ++;
58
66
}
59
- mondayint ++;
60
- }
61
67
62
- addVP (monday , "monday" );
68
+ addVP (monday , "monday" );
63
69
64
70
65
- // Tuesday
71
+ // Tuesday
66
72
67
- int tuesdayint = 0 ;
68
- boolean tuesdaybool = false ;
69
- ArrayList <String > tuesday = new ArrayList <>();
73
+ int tuesdayint = 0 ;
74
+ boolean tuesdaybool = false ;
75
+ ArrayList <String > tuesday = new ArrayList <>();
70
76
71
- for (String s : days ) {
77
+ for (String s : days ) {
72
78
73
- if (s .contains ("<a name=3>" )) {
74
- tuesdaybool = false ;
75
- }
79
+ if (s .contains ("<a name=3>" )) {
80
+ tuesdaybool = false ;
81
+ }
76
82
77
- if (tuesdaybool == true ) {
78
- tuesday .add (days .get (tuesdayint ));
79
- }
83
+ if (tuesdaybool == true ) {
84
+ tuesday .add (days .get (tuesdayint ));
85
+ }
80
86
81
- if (s .contains ("<a name=2>" )) {
82
- tuesday .add (days .get (tuesdayint ));
83
- tuesdaybool = true ;
87
+ if (s .contains ("<a name=2>" )) {
88
+ tuesday .add (days .get (tuesdayint ));
89
+ tuesdaybool = true ;
90
+ }
91
+
92
+ tuesdayint ++;
84
93
}
85
94
86
- tuesdayint ++;
87
- }
95
+ addVP (tuesday , "tuesday" );
88
96
89
- addVP (tuesday , "tuesday" );
90
97
98
+ // Wednesday
91
99
92
- // Wednesday
100
+ int wednesdayint = 0 ;
101
+ boolean wednesdaybool = false ;
102
+ ArrayList <String > wednesday = new ArrayList <>();
93
103
94
- int wednesdayint = 0 ;
95
- boolean wednesdaybool = false ;
96
- ArrayList <String > wednesday = new ArrayList <>();
104
+ for (String s : days ) {
97
105
98
- for (String s : days ) {
106
+ if (s .contains ("<a name=4>" )) {
107
+ wednesdaybool = false ;
108
+ }
99
109
100
- if (s . contains ( "<a name=4>" ) ) {
101
- wednesdaybool = false ;
102
- }
110
+ if (wednesdaybool == true ) {
111
+ wednesday . add ( days . get ( wednesdayint )) ;
112
+ }
103
113
104
- if (wednesdaybool == true ) {
105
- wednesday .add (days .get (wednesdayint ));
106
- }
114
+ if (s .contains ("<a name=3>" )) {
115
+ wednesday .add (days .get (wednesdayint ));
116
+ wednesdaybool = true ;
117
+ }
107
118
108
- if (s .contains ("<a name=3>" )) {
109
- wednesday .add (days .get (wednesdayint ));
110
- wednesdaybool = true ;
119
+ wednesdayint ++;
111
120
}
112
121
113
- wednesdayint ++;
114
- }
122
+ addVP (wednesday , "wednesday" );
115
123
116
- addVP (wednesday , "wednesday" );
117
124
125
+ // Thursday
118
126
119
- // Thursday
127
+ int thursdayint = 0 ;
128
+ boolean thursdaybool = false ;
129
+ ArrayList <String > thursday = new ArrayList <>();
120
130
121
- int thursdayint = 0 ;
122
- boolean thursdaybool = false ;
123
- ArrayList <String > thursday = new ArrayList <>();
131
+ for (String s : days ) {
124
132
125
- for (String s : days ) {
133
+ if (s .contains ("<a name=5>" )) {
134
+ thursdaybool = false ;
135
+ }
126
136
127
- if (s . contains ( "<a name=5>" ) ) {
128
- thursdaybool = false ;
129
- }
137
+ if (thursdaybool == true ) {
138
+ thursday . add ( days . get ( thursdayint )) ;
139
+ }
130
140
131
- if (thursdaybool == true ) {
132
- thursday .add (days .get (thursdayint ));
133
- }
141
+ if (s .contains ("<a name=4>" )) {
142
+ thursday .add (days .get (thursdayint ));
143
+ thursdaybool = true ;
144
+ }
134
145
135
- if (s .contains ("<a name=4>" )) {
136
- thursday .add (days .get (thursdayint ));
137
- thursdaybool = true ;
146
+ thursdayint ++;
138
147
}
139
148
140
- thursdayint ++;
141
- }
149
+ addVP (thursday , "thursday" );
142
150
143
- addVP (thursday , "thursday" );
144
151
152
+ // Friday
145
153
146
- // Friday
154
+ int fridayint = 0 ;
155
+ boolean fridaybool = false ;
156
+ ArrayList <String > friday = new ArrayList <>();
147
157
148
- int fridayint = 0 ;
149
- boolean fridaybool = false ;
150
- ArrayList <String > friday = new ArrayList <>();
158
+ for (String s : days ) {
151
159
152
- for (String s : days ) {
160
+ if (s .contains ("<a name=6>" )) {
161
+ fridaybool = false ;
162
+ }
153
163
154
- if (s . contains ( "<a name=6>" ) ) {
155
- fridaybool = false ;
156
- }
164
+ if (fridaybool == true ) {
165
+ friday . add ( days . get ( fridayint )) ;
166
+ }
157
167
158
- if (fridaybool == true ) {
159
- friday .add (days .get (fridayint ));
160
- }
168
+ if (s .contains ("<a name=5>" )) {
169
+ friday .add (days .get (fridayint ));
170
+ fridaybool = true ;
171
+ }
161
172
162
- if (s .contains ("<a name=5>" )) {
163
- friday .add (days .get (fridayint ));
164
- fridaybool = true ;
173
+ fridayint ++;
165
174
}
166
175
167
- fridayint ++;
168
- }
169
-
170
- addVP (friday , "friday" );
176
+ addVP (friday , "friday" );
171
177
172
178
}
173
179
174
180
175
181
176
-
177
-
178
182
public static void addVP (ArrayList <String > strings , String tag ) {
179
183
180
184
int i = 0 ;
0 commit comments