Search in sources :

Example 1 with IPatternDescriptor

use of org.eclipse.ecf.internal.bulletinboard.commons.parsing.IPatternDescriptor in project ecf by eclipse.

the class AbstractParser method parseThreads.

public Map<ID, IThread> parseThreads(final CharSequence seq) {
    IPatternDescriptor pattern = getThreadPattern();
    IBBObjectFactory factory = getThreadFactory();
    Matcher m = pattern.getPattern().matcher(seq);
    Map<ID, IThread> threads = new LinkedHashMap<ID, IThread>();
    while (m.find()) {
        Map<String, Object> values = pattern.getValueMap(m);
        ID id = null;
        try {
            id = factory.createBBObjectId(namespace, baseURL, (String) values.get(IPatternDescriptor.ID_PARAM));
        } catch (IDCreateException e) {
            // TODO autogen e
            e.printStackTrace();
        }
        String name = StringUtil.stripHTMLTrim((String) values.get(IPatternDescriptor.NAME_PARAM));
        String authorInfo = (String) values.get("authorInfo");
        IBBObject member = genericParser.parseSingleIdName(getAuthorInfoMemberPattern(), authorInfo, getMemberFactory());
        if (member != null) {
            values.put("author", member);
        } else {
            IBBObjectFactory gf = getGuestFactory();
            String guestName = StringUtil.stripHTMLTrim(authorInfo);
            ID guestID = null;
            try {
                guestID = gf.createBBObjectId(namespace, baseURL, guestName);
            } catch (IDCreateException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            values.put("author", getGuestFactory().createBBObject(guestID, guestName, null));
        }
        IThread obj = (IThread) factory.createBBObject(id, new String(name), values);
        threads.put(id, obj);
    }
    return threads;
}
Also used : Matcher(java.util.regex.Matcher) IDCreateException(org.eclipse.ecf.core.identity.IDCreateException) IBBObject(org.eclipse.ecf.bulletinboard.IBBObject) IBBObject(org.eclipse.ecf.bulletinboard.IBBObject) ID(org.eclipse.ecf.core.identity.ID) IPatternDescriptor(org.eclipse.ecf.internal.bulletinboard.commons.parsing.IPatternDescriptor) IThread(org.eclipse.ecf.bulletinboard.IThread) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

LinkedHashMap (java.util.LinkedHashMap)1 Matcher (java.util.regex.Matcher)1 IBBObject (org.eclipse.ecf.bulletinboard.IBBObject)1 IThread (org.eclipse.ecf.bulletinboard.IThread)1 ID (org.eclipse.ecf.core.identity.ID)1 IDCreateException (org.eclipse.ecf.core.identity.IDCreateException)1 IPatternDescriptor (org.eclipse.ecf.internal.bulletinboard.commons.parsing.IPatternDescriptor)1