@@ -29,7 +29,7 @@ public class Zastup {
2929 //jedlo
3030 private final Pattern menuKomplet =Pattern .compile ("<table class=\" obed_menu\" >(.*?)</table>" );
3131 private final Pattern menuDateRange =Pattern .compile ("<h2>Od (.*?) do (.*?)</h2>" );
32- private final Pattern menuTabulka =Pattern .compile ("<th>Hlavné jedlo</th></tr>(.*?)</tbody>" );
32+ private final Pattern menuTabulka =Pattern .compile ("<th>Hlavné jedlo</th>.*? </tr>(.*?)</tbody>" );
3333 private final Pattern tabulkaRow =Pattern .compile ("<tr style=\" background-color:.*?\" >(.*?)</tr>" );
3434 private final Pattern tabulkaDen =Pattern .compile ("<th class=\" v_align r_align\" >(.*?)</th>" );
3535 private final Pattern tabulkaJedlo =Pattern .compile ("<td class=\" v_align\" >(.*?)</td>\\ s*?<td>\\ s*?(.*?)\\ s*?</td>" );
@@ -59,6 +59,7 @@ public String getOznam(){
5959
6060 @ SuppressWarnings ("deprecation" )
6161 public TreeMap <Date ,String []> getWeekMenu () throws IOException {
62+
6263 TreeMap <Date ,String []> ts =new TreeMap <Date ,String []>();
6364 final Hashtable <String ,Integer > ht =new Hashtable <String ,Integer >();
6465 ht .put ("Pondelok" ,1 );
@@ -78,31 +79,35 @@ public TreeMap<Date,String[]> getWeekMenu() throws IOException{
7879 String inputLine ;
7980 while ((inputLine = in .readLine ()) != null ){
8081 page +=inputLine ;}
82+
8183 Matcher m =menuDateRange .matcher (page );
8284 if (!m .find ()){return null ;}
8385 Date datestart = null ;
8486 try {
8587 datestart =new SimpleDateFormat ("d.M.yyyy" , Locale .ENGLISH ).parse (m .group (1 ));
88+
8689 } catch (ParseException e ) {
8790 e .printStackTrace ();
8891 return null ;
8992 }
9093 m =menuTabulka .matcher (page );
91- if (!m .find ()){return null ;}
94+ if (!m .find ()){return null ;}
9295 String tabulka =m .group (1 );
9396 m =tabulkaRow .matcher (tabulka );
9497 Matcher m2 ,m3 ;
9598 cal .setTime (datestart );
96- if (!m .find ()){return null ;}
99+ if (!m .find ()){System . err . println ( "1" ); return null ;}
97100 m2 =tabulkaDen .matcher (m .group (1 ));
98- if (!m2 .find ()){return null ;}
101+ if (!m2 .find ()){System . err . println ( "1" ); return null ;}
99102 m3 =tabulkaJedlo .matcher (m .group (1 ));
103+
100104 if (m3 .find ()){
105+
101106 jedlo [0 ]=m3 .group (1 ).trim ();
102107 jedlo [1 ]=m3 .group (2 ).trim ();
103108 ts .put (datestart , jedlo );
104109 jedlo =new String [2 ];
105- }
110+ }else { throw new RuntimeException ();}
106111 while (m .find ()){
107112 m2 =tabulkaDen .matcher (m .group (1 ));
108113 if (m2 .find ()){
@@ -112,8 +117,10 @@ public TreeMap<Date,String[]> getWeekMenu() throws IOException{
112117 if (m3 .find ()){
113118 jedlo [0 ]=m3 .group (1 ).trim ();
114119 jedlo [1 ]=m3 .group (2 ).trim ();
120+
115121 ts .put (calt .getTime (),jedlo );
116122 jedlo =new String [2 ];
123+
117124 }
118125 }
119126 }
@@ -354,7 +361,8 @@ private String loadPage(String date) throws IOException{
354361 /**method to get next non-weekend day,from system time
355362 * @return next day(Monday-Friday) date, with 0 time
356363 * */
357- public Date getNextDay (){
364+ @ SuppressLint ("SimpleDateFormat" )
365+ public Date getNextDay (){
358366 Date d =new Date ();
359367 Calendar c =Calendar .getInstance ();
360368 c .setTime (d );
0 commit comments