Author: jerome
Date: 2009-04-06 12:05:15 +0200 (Mon, 06 Apr 2009)
New Revision: 4353

Modified:
   
software_suite_v2/software/gadgets/tuxdroid-gadget-programsTV/trunk/tuxdroid-gadget-programsTV/src/com/kysoh/tvPrograms/programs/french/FrenchPrograms.java
Log:
* Handling parse errors.

Modified: 
software_suite_v2/software/gadgets/tuxdroid-gadget-programsTV/trunk/tuxdroid-gadget-programsTV/src/com/kysoh/tvPrograms/programs/french/FrenchPrograms.java
===================================================================
--- 
software_suite_v2/software/gadgets/tuxdroid-gadget-programsTV/trunk/tuxdroid-gadget-programsTV/src/com/kysoh/tvPrograms/programs/french/FrenchPrograms.java
 2009-04-06 10:00:54 UTC (rev 4352)
+++ 
software_suite_v2/software/gadgets/tuxdroid-gadget-programsTV/trunk/tuxdroid-gadget-programsTV/src/com/kysoh/tvPrograms/programs/french/FrenchPrograms.java
 2009-04-06 10:05:15 UTC (rev 4353)
@@ -116,111 +116,122 @@
                }
                
                String result = this.recoded;
-               
-               result = result.substring(result.indexOf("<ul 
id=\"heure\"><li><a href=\""));
-               result = result.substring(result.indexOf("<div 
id=\"contenu_nopub\">"));
-               result = result.substring(result.indexOf("/><br /><b>"));
-               result = result.substring(result.indexOf("</b></td></tr><tr>"));
-               String program = result.substring(0, result.indexOf("/><br 
/><b>") + "/><br /><b>".length());
-               
-               int i1 = 0;
-               
-               while(program.contains("onmouseover=\"return overlib('"))
+               if(!result.contains("<ul id=\"heure\"><li><a href=\""))
                {
-                       i1 = program.indexOf("onmouseover=\"return overlib('");
-                       String one = program.substring(i1);
-                       one = one.substring(0, one.indexOf("onmouseout=\"return 
nd();\" />"));
-                       program = program.replace(one, "");
-                       one = one.substring("onmouseover=\"return 
overlib('".length(), one.indexOf("',SNAPY"));
+                       this.triggerError();
                }
-               
-               program = program.replaceAll("<tr><td align=\"center\" 
class=\"b8\" height=\"16\" background=\"/img/fond.gif\">", "");
-               program = program.replaceAll("<b>", "").replaceAll("</b>", 
"").replaceAll("</tr>", "").replaceAll("<tr>", "");
-               program = program.replaceAll("style=\"display: block; margin: 
0px 0px 0px 0px; padding: 0px 0px 0px 0px; font-size:", "");
-               program = program.replaceAll("align=\"center\" class=\"", "");
-               
-
-               while(program.contains("<img src=\""))
+               try
                {
-                       i1 = program.indexOf("<img src=\"");
-                       String dat = program.substring(i1);
-                       dat = dat.substring(0, dat.indexOf("/>"));
-                       program = program.replace(dat, "");
-               }
-               
-               program = "<a>" + program.replace("td", "").replace("/", 
"").replace("<>", "");
-               
-               while(program.contains("<a href=\""))
-               {
-                       String dat = program.substring(program.indexOf("<a 
href=\""));
-                       dat = dat.substring(0, dat.indexOf(">") + 1);
-                       program = program.replace(dat, "<a>");
-               }
-               
-               while(program.contains("< r"))
-               {
-                       i1 = program.indexOf("< r");
+                       result = result.substring(result.indexOf("<ul 
id=\"heure\"><li><a href=\""));
+                       result = result.substring(result.indexOf("<div 
id=\"contenu_nopub\">"));
+                       result = result.substring(result.indexOf("/><br 
/><b>"));
+                       result = 
result.substring(result.indexOf("</b></td></tr><tr>"));
+                       String program = result.substring(0, 
result.indexOf("/><br /><b>") + "/><br /><b>".length());
                        
-                       String match = program.substring(i1);
-                       match = match.substring(0, match.indexOf("\">") + 2);
-                       program = program.replace(match, "");
-               }
-               
-               program = program.replace("<a><a>", "<a>").replace("<a>>", 
"<a>").replace("<<a>", "<a>");
-               
-               while(program.contains("<  1pt;\" height=\""))
-               {
-                       i1 = program.indexOf("<  1pt;\" height=\"");
-                       String one = program.substring(i1);
-                       one = one.substring(0, one.indexOf(">"));
-                       program = program.replace(one, "");
-               }
-               
-               program = program.replace("<a>>>>", "<a>").replace("<a>>>", 
"<a>");
-               program = program.replace("<br >>", "").replace("<br >", "");
-               
-               program = program.substring(0, program.lastIndexOf("<a>"));
-               
-               String tmp = program;
-               while(tmp.contains("<a>"))
-               {
-                       String one = tmp.substring(tmp.indexOf("<a>") + 
"<a>".length());
-                       String rpl = one.substring(0, one.indexOf("<a>"));
-                       if(rpl.length() >= 6)
+                       int i1 = 0;
+                       
+                       while(program.contains("onmouseover=\"return 
overlib('"))
                        {
-                               String replacement = one.substring(0, 5) + 
"<a>" + one.substring(6);
-                               program = program.replace(one, replacement);
+                               i1 = program.indexOf("onmouseover=\"return 
overlib('");
+                               String one = program.substring(i1);
+                               one = one.substring(0, 
one.indexOf("onmouseout=\"return nd();\" />"));
+                               program = program.replace(one, "");
+                               one = one.substring("onmouseover=\"return 
overlib('".length(), one.indexOf("',SNAPY"));
                        }
                        
-                       tmp = tmp.replace("<a>" + one, "");
-               }
-               
-               String[] splited = program.split("<a>");
-               
-               for(int i=0; i < splited.length; i++)
-               {
-                       if(!splited[i].equals(""))
+                       program = program.replaceAll("<tr><td align=\"center\" 
class=\"b8\" height=\"16\" background=\"/img/fond.gif\">", "");
+                       program = program.replaceAll("<b>", 
"").replaceAll("</b>", "").replaceAll("</tr>", "").replaceAll("<tr>", "");
+                       program = program.replaceAll("style=\"display: block; 
margin: 0px 0px 0px 0px; padding: 0px 0px 0px 0px; font-size:", "");
+                       program = program.replaceAll("align=\"center\" 
class=\"", "");
+                       
+       
+                       while(program.contains("<img src=\""))
                        {
+                               i1 = program.indexOf("<img src=\"");
+                               String dat = program.substring(i1);
+                               dat = dat.substring(0, dat.indexOf("/>"));
+                               program = program.replace(dat, "");
+                       }
+                       
+                       program = "<a>" + program.replace("td", 
"").replace("/", "").replace("<>", "");
+                       
+                       while(program.contains("<a href=\""))
+                       {
+                               String dat = 
program.substring(program.indexOf("<a href=\""));
+                               dat = dat.substring(0, dat.indexOf(">") + 1);
+                               program = program.replace(dat, "<a>");
+                       }
+                       
+                       while(program.contains("< r"))
+                       {
+                               i1 = program.indexOf("< r");
                                
-                               String startTime = splited[i];
-                               String title = "";
-                               String description = null;
-                               
-                               if(splited[i + 1].contains("<span"))
+                               String match = program.substring(i1);
+                               match = match.substring(0, match.indexOf("\">") 
+ 2);
+                               program = program.replace(match, "");
+                       }
+                       
+                       program = program.replace("<a><a>", 
"<a>").replace("<a>>", "<a>").replace("<<a>", "<a>");
+                       
+                       while(program.contains("<  1pt;\" height=\""))
+                       {
+                               i1 = program.indexOf("<  1pt;\" height=\"");
+                               String one = program.substring(i1);
+                               one = one.substring(0, one.indexOf(">"));
+                               program = program.replace(one, "");
+                       }
+                       
+                       program = program.replace("<a>>>>", 
"<a>").replace("<a>>>", "<a>");
+                       program = program.replace("<br >>", "").replace("<br 
>", "");
+                       
+                       program = program.substring(0, 
program.lastIndexOf("<a>"));
+                       
+                       String tmp = program;
+                       while(tmp.contains("<a>"))
+                       {
+                               String one = tmp.substring(tmp.indexOf("<a>") + 
"<a>".length());
+                               String rpl = one.substring(0, 
one.indexOf("<a>"));
+                               if(rpl.length() >= 6)
                                {
-                                       title = splited[i + 1].substring(0, 
splited[i + 1].indexOf("<span"));
-                                       description = splited[i + 
1].substring(splited[i + 1].indexOf("<span") + "<span ".length());
-                                       description = 
description.substring(description.indexOf("\">") + 2 , 
description.indexOf("<span>"));
+                                       String replacement = one.substring(0, 
5) + "<a>" + one.substring(6);
+                                       program = program.replace(one, 
replacement);
                                }
-                               else
+                               
+                               tmp = tmp.replace("<a>" + one, "");
+                       }
+                       
+                       String[] splited = program.split("<a>");
+                       
+                       for(int i=0; i < splited.length; i++)
+                       {
+                               if(!splited[i].equals(""))
                                {
-                                       title = splited[i + 1];
+                                       
+                                       String startTime = splited[i];
+                                       String title = "";
+                                       String description = null;
+                                       
+                                       if(splited[i + 1].contains("<span"))
+                                       {
+                                               title = splited[i + 
1].substring(0, splited[i + 1].indexOf("<span"));
+                                               description = splited[i + 
1].substring(splited[i + 1].indexOf("<span") + "<span ".length());
+                                               description = 
description.substring(description.indexOf("\">") + 2 , 
description.indexOf("<span>"));
+                                       }
+                                       else
+                                       {
+                                               title = splited[i + 1];
+                                       }
+                                       
+                                       Program p = new Program(title, 
startTime, null, description, this.channel);
+                                       this.program.add(p);
+                                       i += 1;
                                }
-                               
-                               Program p = new Program(title, startTime, null, 
description, this.channel);
-                               this.program.add(p);
-                               i += 1;
                        }
+               
                }
+               catch(Exception error)
+               {
+                       this.triggerError();
+               }
        }
 }


------------------------------------------------------------------------------
_______________________________________________
Tux-droid-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tux-droid-svn

Reply via email to