Enable word wrapping with preference key editor.wrap.words (false by default)
[phpeclipse.git] / archive / net.sourceforge.phpeclipse.wiki / src / net / sourceforge / phpeclipse / wiki / actions / category / ParseCategory.java
diff --git a/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/actions/category/ParseCategory.java b/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/actions/category/ParseCategory.java
new file mode 100644 (file)
index 0000000..6bfb884
--- /dev/null
@@ -0,0 +1,223 @@
+package net.sourceforge.phpeclipse.wiki.actions.category;
+
+import java.util.ArrayList;
+
+public class ParseCategory {
+  ArrayList titleList;
+
+  public ParseCategory() {
+    titleList = new ArrayList();
+  }
+  public void parseCategory(String text) {
+    int index1 = text.indexOf("contentSub");
+    int index2 = text.indexOf("printfooter");
+    if (index2 < 0) {
+      index2 = text.length();
+    }
+    if (index1 > 0 && index2 > index1) {
+      try {
+        int i = index1;
+        int titleStart;
+        int titleEnd;
+        char ch;
+        while (true) {
+          ch = text.charAt(i++);
+          if (i>index2) {
+            break;
+          }
+          if (ch == 't' && text.charAt(i) == 'i' && text.charAt(i +1) == 't' && text.charAt(i + 2) == 'l'
+              && text.charAt(i + 3) == 'e') {
+            i += 4;
+            titleStart = -1;
+            
+// found: "title"
+            while (true) {
+              ch = text.charAt(i++);
+              if (ch=='"') {
+                if (titleStart>0) {
+                  titleList.add(text.substring(titleStart,i-1));
+                  break;
+                }
+                titleStart = i;
+              }
+            }
+            
+          }
+        }
+      } catch (IndexOutOfBoundsException e) {
+
+      }
+
+    }
+  }
+
+  public static void main(String[] args) {
+    String test = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\r\n"
+        + "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"de\" lang=\"de\" dir=\"ltr\">\r\n"
+        + "  <head>\r\n"
+        + "    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>\r\n"
+        + "    <meta name=\"KEYWORDS\" content=\"Kategorie:Eclipse Tips\" />\r\n"
+        + "<meta name=\"robots\" content=\"index,follow\" />\r\n"
+        + "<link rel=\"shortcut icon\" href=\"/favicon.ico\" />\r\n"
+        + "<link title=\"Creative Commons\" type=\"application/rdf+xml\" href=\"/index.php?title=Kategorie:Eclipse_Tips&amp;action=creativecommons\" rel=\"meta\" />\r\n"
+        + "<link rel=\"copyright\" href=\"http://www.gnu.org/copyleft/fdl.html\" />\r\n"
+        + "\r\n"
+        + "    <title>Kategorie:Eclipse Tips - Plog4u</title>\r\n"
+        + "    <style type=\"text/css\" media=\"screen,projection\">/*<![CDATA[*/ @import \"/stylesheets/monobook/main.css\"; /*]]>*/</style>\r\n"
+        + "\r\n"
+        + "    <link rel=\"stylesheet\" type=\"text/css\" media=\"print\" href=\"/stylesheets/commonPrint.css\"/>\r\n"
+        + "    <!--[if IE]><style type=\"text/css\" media=\"all\">@import \"/stylesheets/monobook/IEFixes.css\";</style>\r\n"
+        + "    <script type=\"text/javascript\" src=\"/stylesheets/IEFixes.js\"></script>\r\n"
+        + "    <meta http-equiv=\"imagetoolbar\" content=\"no\" /><![endif]-->\r\n"
+        + "    <script src=\"/index.php?title=-&amp;action=raw&amp;gen=js\" type=\"text/javascript\"></script>\r\n"
+        + "    <script type=\"text/javascript\" src=\"/stylesheets/wikibits.js\"></script>\r\n"
+        + "    <style type=\"text/css\">/*<![CDATA[*/ @import \"/index.php?title=-&action=raw&gen=css\";\r\n"
+        + " /*]]>*/</style>\r\n"
+        + "    \r\n"
+        + "  </head>\r\n"
+        + "  <body class=\"ns-14\">\r\n"
+        + "\r\n"
+        + "    <div id=\"globalWrapper\">\r\n"
+        + "      <div id=\"column-content\">\r\n"
+        + "    <div id=\"content\">\r\n"
+        + "        \r\n"
+        + "      <a name=\"top\" id=\"contentTop\"></a>\r\n"
+        + "      <h1 class=\"firstHeading\">Kategorie:Eclipse Tips</h1>\r\n"
+        + "      <div id=\"bodyContent\">\r\n"
+        + "        <h3 id=\"siteSub\">aus Plog4u, der freien Eclipse Wissensdatenbank</h3>\r\n"
+        + "        <div id=\"contentSub\"></div>\r\n"
+        + "\r\n"
+        + "        \r\n"
+        + "\r\n"
+        + "        \r\n"
+        + "        <!-- start content -->\r\n"
+        + "        <p>(Dieser Artikel enthält momentan keinen Text)<br style=\"clear:both;\"/>\r\n"
+        + "</p>\r\n"
+        + "<h2>Artikel in der Kategorie \"Eclipse Tips\"</h2>\r\n"
+        + "Dieser Kategorie gehören 6 Artikel an.<h3>B</h3>\r\n"
+        + "<ul><li><a href=\"/index.php/Benutzung:Eclipse:Tips:Eclipse_Sprachpaket\" title =\"Benutzung:Eclipse:Tips:Eclipse Sprachpaket\">Benutzung:Eclipse:Tips:Eclipse Sprachpaket</a></li><li><a href=\"/index.php/Benutzung:Eclipse:Tips:Eclipse_Starten\" title =\"Benutzung:Eclipse:Tips:Eclipse Starten\">Benutzung:Eclipse:Tips:Eclipse Starten</a></li><li><a href=\"/index.php/Benutzung:Eclipse:Tips:JDT:Pr%C3%A4fixe_f%C3%BCr_Klassenattribute\" title =\"Benutzung:Eclipse:Tips:JDT:Präfixe für Klassenattribute\">Benutzung:Eclipse:Tips:JDT:Präfixe für Klassenattribute</a></li><li><a href=\"/index.php/Benutzung:Eclipse:Tips:Plugins_aufrufen\" title =\"Benutzung:Eclipse:Tips:Plugins aufrufen\">Benutzung:Eclipse:Tips:Plugins aufrufen</a></li><li><a href=\"/index.php/Benutzung:Eclipse:Tips:Sourceforge_CVS_Zugriff\" title =\"Benutzung:Eclipse:Tips:Sourceforge CVS Zugriff\">Benutzung:Eclipse:Tips:Sourceforge CVS Zugriff</a></li><li><a href=\"/index.php/Benutzung:Eclipse:Tips:Stringvergleiche_in_JUnit\" title =\"Benutzung:Eclipse:Tips:Stringvergleiche in JUnit\">Benutzung:Eclipse:Tips:Stringvergleiche in JUnit</a></li></ul>\r\n"
+        + "\r\n"
+        + "<div class=\"printfooter\">\r\n"
+        + "Von \"<a href=\"http://www.plog4u.de/index.php/Kategorie:Eclipse_Tips\">http://www.plog4u.de/index.php/Kategorie:Eclipse_Tips</a>\"</div>\r\n"
+        + "\r\n"
+        + "        \r\n"
+        + "        <!-- end content -->\r\n"
+        + "        <div class=\"visualClear\"></div>\r\n"
+        + "      </div>\r\n"
+        + "    </div>\r\n"
+        + "      </div>\r\n"
+        + "      <div id=\"column-one\">\r\n"
+        + "\r\n"
+        + "    <div id=\"p-cactions\" class=\"portlet\">\r\n"
+        + "      <h5>Views</h5>\r\n"
+        + "      <ul>\r\n"
+        + "        <li id=\"ca-nstab-category\" class=\"selected\"><a href=\"/index.php/Kategorie:Eclipse_Tips\">Kategorie</a></li><li id=\"ca-talk\" class=\"new\"><a href=\"/index.php?title=Kategorie_Diskussion:Eclipse_Tips&amp;action=edit\">Diskussion</a></li><li id=\"ca-edit\" class=\"\"><a href=\"/index.php?title=Kategorie:Eclipse_Tips&amp;action=edit\">bearbeiten</a></li>\r\n"
+        + "      </ul>\r\n"
+        + "    </div>\r\n"
+        + "    <div class=\"portlet\" id=\"p-personal\">\r\n"
+        + "\r\n"
+        + "      <h5>\'Persönliche Werkzeuge</h5>\r\n"
+        + "      <div class=\"pBody\">\r\n"
+        + "        <ul>\r\n"
+        + "          <li id=\"pt-anonuserpage\"><a href=\"/index.php/Benutzer:217.252.6.161\" class=\"new\">217.252.6.161</a></li><li id=\"pt-anontalk\"><a href=\"/index.php/Benutzer_Diskussion:217.252.6.161\" class=\"new\">Diskussionsseite dieser IP</a></li><li id=\"pt-anonlogin\"><a href=\"/index.php?title=Spezial:Userlogin&amp;returnto=Kategorie:Eclipse_Tips\">Anmelden</a></li>\r\n"
+        + "        </ul>\r\n"
+        + "      </div>\r\n"
+        + "    </div>\r\n"
+        + "\r\n"
+        + "<!--        <div class=\"portlet\" id=\"p-logo\">\r\n"
+        + "      <a style=\"background-image: url(/stylesheets/images/wiki.png);\" href=\"/index.php/Hauptseite\" i18n:attributes=\"title string:mainpage\"></a>\r\n"
+        + "    </div> -->\r\n"
+        + "    <div class=\"portlet\" id=\"p-nav\">\r\n"
+        + "      <h5>Navigation</h5>\r\n"
+        + "      <div class=\"pBody\">\r\n"
+        + "        <ul>\r\n"
+        + "          <li id=\"n-mainpage\"><a href=\"/index.php/Hauptseite\">Hauptseite</a></li>\r\n"
+        + "          <li id=\"n-portal\"><a href=\"/index.php/Plog4u:Portal\">Plog4u-Portal</a></li>\r\n"
+        + "          <li id=\"n-currentevents\"><a href=\"/index.php/Aktuelle_Ereignisse\">Aktuelle Ereignisse</a></li>\r\n"
+        + "\r\n"
+        + "          <li id=\"n-recentchanges\"><a href=\"/index.php/Spezial:Recentchanges\">Letzte Änderungen</a></li>\r\n"
+        + "          <li id=\"n-randompage\"><a href=\"/index.php/Spezial:Randompage\">Zufälliger Artikel</a></li>\r\n"
+        + "          <li id=\"n-help\"><a href=\"/index.php/Plog4u:Hilfe\">Hilfe</a></li>\r\n"
+        + "          \r\n"
+        + "<li><a href=\"http://www.plog4u.de/impressum.html\">Impressum</a></li>\r\n"
+        + "        </ul>\r\n"
+        + "      </div>\r\n"
+        + "    </div>\r\n"
+        + "\r\n"
+        + "    <div id=\"p-search\" class=\"portlet\">\r\n"
+        + "      <h5>Suche</h5>\r\n"
+        + "      <div class=\"pBody\">\r\n"
+        + "        <form name=\"searchform\" action=\"/index.php/Spezial:Search\" id=\"searchform\">\r\n"
+        + "          <input accesskey=\"f\" id=\"searchInput\" name=\"search\" type=\"text\" />\r\n"
+        + "          <input value=\"Los\" type=\"submit\" name=\"go\" class=\"searchButton\" />&nbsp;<input value=\"Suche\" type=\"submit\" name=\"fulltext\" class=\"searchButton\" />\r\n"
+        + "        </form>\r\n"
+        + "      </div>\r\n"
+        + "\r\n"
+        + "    </div>\r\n"
+        + "    <div class=\"portlet\" id=\"p-tb\">\r\n"
+        + "      <h5>Werkzeuge</h5>\r\n"
+        + "      <div class=\"pBody\">\r\n"
+        + "        <ul>\r\n"
+        + "          <li id=\"t-whatlinkshere\"><a href=\"/index.php?title=Spezial:Whatlinkshere&amp;target=Kategorie%3AEclipse_Tips\">Was zeigt hierhin</a></li>\r\n"
+        + "          <li id=\"t-recentchangeslinked\"><a href=\"/index.php?title=Spezial:Recentchangeslinked&amp;target=Kategorie%3AEclipse_Tips\">Verlinkte Seiten</a></li>\r\n"
+        + "\r\n"
+        + "          \r\n"
+        + "          \r\n"
+        + "          \r\n"
+        + "          \r\n"
+        + "          <li id=\"t-specialpages\"><a href=\"/index.php/Spezial:Specialpages\">Spezialseiten</a></li>\r\n"
+        + "        </ul>\r\n"
+        + "      </div>\r\n"
+        + "    </div>\r\n"
+        + "\r\n"
+        + "      <div class=\"portlet\" id=\"p-advertisement\">\r\n"
+        + "       <h5>werbung</h5>\r\n"
+        + "       <div class=\"pBody\">\r\n"
+        + "\r\n"
+        + "<script type=\"text/javascript\"><!--\r\n"
+        + "google_ad_client = \"pub-0182243963199149\";\r\n"
+        + "google_ad_width = 120;\r\n"
+        + "google_ad_height = 240;\r\n"
+        + "google_ad_format = \"120x240_as\";\r\n"
+        + "google_ad_channel =\"4781857343\";\r\n"
+        + "google_ad_language =\"de\";\r\n"
+        + "//--></script>\r\n"
+        + "<script type=\"text/javascript\" src=\"http://pagead2.googlesyndication.com/pagead/show_ads.js\">\r\n"
+        + "</script>\r\n"
+        + "\r\n"
+        + "       </div>\r\n"
+        + "      </div>\r\n"
+        + "    \r\n"
+        + "      </div><!-- end of the left (by default at least) column -->\r\n"
+        + "      <div class=\"visualClear\"></div>\r\n"
+        + "      <div id=\"footer\">\r\n"
+        + "    <div id=\"f-poweredbyico\"><a href=\"http://www.mediawiki.org/\"><img src=\"/stylesheets/images/poweredby_mediawiki_88x31.png\" alt=\"MediaWiki\" /></a></div>\r\n"
+        + "\r\n"
+        + "    <div id=\"f-copyrightico\"><a href=\"http://www.gnu.org/copyleft/fdl.html\"><img src=\"/stylesheets/images/gnu-fdl.png\" alt=\'GNU Free Documentation License 1.2\' /></a></div>\r\n"
+        + "    <ul id=\"f-list\">\r\n"
+        + "      \r\n"
+        + "      \r\n"
+        + "      \r\n"
+        + "      \r\n"
+        + "      <li id=\"f-about\"><a href=\"/index.php/Plog4u:%C3%9Cber_Plog4u\" title =\"Plog4u:Über Plog4u\">Über Plog4u</a></li>\r\n"
+        + "      <li id=\"f-disclaimer\"><a href=\"/index.php/Plog4u:Lizenzbestimmungen\" title =\"Plog4u:Lizenzbestimmungen\">Lizenzbestimmungen</a></li>\r\n"
+        + "    </ul>\r\n"
+        + "      </div>\r\n"
+        + "    </div>\r\n"
+        + "    <!-- Served by single in 0.09 secs. -->\r\n"
+        + "\r\n"
+        + "  </body>\r\n" + "</html>\r\n" + "";
+    ParseCategory pc = new ParseCategory();
+    pc.parseCategory(test);
+    ArrayList list = pc.getTitleList();
+    for (int i = 0; i < list.size(); i++) {
+      System.out.println(list.get(i));
+    }
+  }
+  /**
+   * @return Returns the titleList.
+   */
+  public ArrayList getTitleList() {
+    return titleList;
+  }
+}
\ No newline at end of file