Search in sources :

Example 1 with ForumFactory

use of org.eclipse.ecf.internal.provider.vbulletin.internal.ForumFactory in project ecf by eclipse.

the class VBParser method parseForums.

public Map<ID, Forum> parseForums(final CharSequence seq) {
    Map<ID, Forum> forums = new LinkedHashMap<ID, Forum>();
    Matcher matcher = PAT_FORUM.matcher(seq);
    while (matcher.find()) {
        String name = StringUtil.stripHTMLTrim(matcher.group(2));
        // String desc = StringUtil.stripHTMLTrim(matcher.group(3));
        if (StringUtil.notEmptyStr(name)) {
            ForumFactory ff = new ForumFactory();
            String idStr = matcher.group(1);
            ID id = null;
            try {
                id = ff.createBBObjectId(namespace, baseURL, idStr);
            } catch (NumberFormatException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (IDCreateException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            Forum forum = (Forum) ff.createBBObject(id, name, null);
            // forum.setDescription(desc);
            forums.put(id, forum);
        }
    }
    return forums;
}
Also used : ForumFactory(org.eclipse.ecf.internal.provider.vbulletin.internal.ForumFactory) Matcher(java.util.regex.Matcher) IDCreateException(org.eclipse.ecf.core.identity.IDCreateException) ThreadMessageID(org.eclipse.ecf.internal.provider.vbulletin.identity.ThreadMessageID) ID(org.eclipse.ecf.core.identity.ID) LinkedHashMap(java.util.LinkedHashMap)

Example 2 with ForumFactory

use of org.eclipse.ecf.internal.provider.vbulletin.internal.ForumFactory in project ecf by eclipse.

the class VBParser method parseThreadPageForThreadAttributes.

public Thread parseThreadPageForThreadAttributes(CharSequence seq) throws BBException {
    Thread t = (Thread) genericParser.parseSingleIdName(PD_THREAD_ATTRS, seq, new ThreadFactory());
    if (t != null) {
        Map<ID, IBBObject> forums = genericParser.parseMultiIdName(PD_THREAD_ATTRS_FORUM, seq, new ForumFactory(), true);
        Forum prev = null;
        Forum f = null;
        for (IBBObject obj : forums.values()) {
            f = (Forum) obj;
            if (prev != null) {
                prev.subforums.add(f);
            }
            f.setParent(prev);
            prev = f;
        }
        t.forum = f;
        return t;
    } else {
        throw new BBException("Failed to parse the thread.");
    }
}
Also used : ForumFactory(org.eclipse.ecf.internal.provider.vbulletin.internal.ForumFactory) BBException(org.eclipse.ecf.bulletinboard.BBException) IBBObject(org.eclipse.ecf.bulletinboard.IBBObject) ThreadMessageID(org.eclipse.ecf.internal.provider.vbulletin.identity.ThreadMessageID) ID(org.eclipse.ecf.core.identity.ID)

Aggregations

ID (org.eclipse.ecf.core.identity.ID)2 ThreadMessageID (org.eclipse.ecf.internal.provider.vbulletin.identity.ThreadMessageID)2 ForumFactory (org.eclipse.ecf.internal.provider.vbulletin.internal.ForumFactory)2 LinkedHashMap (java.util.LinkedHashMap)1 Matcher (java.util.regex.Matcher)1 BBException (org.eclipse.ecf.bulletinboard.BBException)1 IBBObject (org.eclipse.ecf.bulletinboard.IBBObject)1 IDCreateException (org.eclipse.ecf.core.identity.IDCreateException)1