X-Git-Url: http://git.phpeclipse.com 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 index 0000000..6bfb884 --- /dev/null +++ b/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/actions/category/ParseCategory.java @@ -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 = "\r\n" + + "\r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + "\r\n" + + "\r\n" + + "\r\n" + + "\r\n" + + "\r\n" + + " Kategorie:Eclipse Tips - Plog4u\r\n" + + " \r\n" + + "\r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + "\r\n" + + "
\r\n" + + "
\r\n" + + "
\r\n" + + " \r\n" + + " \r\n" + + "

Kategorie:Eclipse Tips

\r\n" + + "
\r\n" + + "

aus Plog4u, der freien Eclipse Wissensdatenbank

\r\n" + + "
\r\n" + + "\r\n" + + " \r\n" + + "\r\n" + + " \r\n" + + " \r\n" + + "

(Dieser Artikel enthält momentan keinen Text)
\r\n" + + "

\r\n" + + "

Artikel in der Kategorie \"Eclipse Tips\"

\r\n" + + "Dieser Kategorie gehören 6 Artikel an.

B

\r\n" + + "\r\n" + + "\r\n" + + "\r\n" + + "\r\n" + + " \r\n" + + " \r\n" + + "
\r\n" + + "
\r\n" + + "
\r\n" + + "
\r\n" + + "
\r\n" + + "\r\n" + + "
\r\n" + + "
Views
\r\n" + + " \r\n" + + "
\r\n" + + "
\r\n" + + "\r\n" + + "
\'Persönliche Werkzeuge
\r\n" + + "
\r\n" + + " \r\n" + + "
\r\n" + + "
\r\n" + + "\r\n" + + "\r\n" + + "
\r\n" + + "
Navigation
\r\n" + + "
\r\n" + + " \r\n" + + "
\r\n" + + "
\r\n" + + "\r\n" + + "
\r\n" + + "
Suche
\r\n" + + "
\r\n" + + "
\r\n" + + " \r\n" + + "  \r\n" + + "
\r\n" + + "
\r\n" + + "\r\n" + + "
\r\n" + + "
\r\n" + + "
Werkzeuge
\r\n" + + "
\r\n" + + " \r\n" + + "
\r\n" + + "
\r\n" + + "\r\n" + + "
\r\n" + + "
werbung
\r\n" + + "
\r\n" + + "\r\n" + + "\r\n" + + "\r\n" + + "\r\n" + + "
\r\n" + + "
\r\n" + + " \r\n" + + "
\r\n" + + "
\r\n" + + "
\r\n" + + "
\"MediaWiki\"
\r\n" + + "\r\n" + + "
\'GNU
\r\n" + + " \r\n" + + "
\r\n" + + "
\r\n" + + " \r\n" + + "\r\n" + + " \r\n" + "\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