use of org.eclipse.ecf.bulletinboard.IBBObject in project ecf by eclipse.
the class AbstractParser method parseMemberGroups.
public Map<ID, IMemberGroup> parseMemberGroups(final CharSequence seq) throws BBException {
Matcher m = getMemberGroupContainerPattern().matcher(seq);
if (m.find()) {
// TODO is stripHTMLTrim needed? GenericParser doesn't do it
Map<ID, IBBObject> objects = genericParser.parseMultiIdName(getMemberGroupPattern(), m.group(0), getMemberGroupFactory(), true);
Map<ID, IMemberGroup> members = new LinkedHashMap<ID, IMemberGroup>(objects.size());
for (IBBObject obj : objects.values()) {
members.put(obj.getID(), (IMemberGroup) obj);
}
return members;
} else {
throwException("Could not find member groups.", seq);
}
return Collections.emptyMap();
}
use of org.eclipse.ecf.bulletinboard.IBBObject 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.");
}
}
use of org.eclipse.ecf.bulletinboard.IBBObject 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;
}
use of org.eclipse.ecf.bulletinboard.IBBObject in project ecf by eclipse.
the class AbstractParser method parseMembers.
public Map<ID, IMember> parseMembers(final CharSequence seq) {
// TODO is stripHTMLTrim needed? GenericParser doesn't do it
Map<ID, IBBObject> objects = genericParser.parseMultiIdName(getMemberPattern(), seq, getMemberFactory(), true);
Map<ID, IMember> members = new LinkedHashMap<ID, IMember>(objects.size());
for (IBBObject obj : objects.values()) {
members.put(obj.getID(), (IMember) obj);
}
return members;
}
use of org.eclipse.ecf.bulletinboard.IBBObject in project ecf by eclipse.
the class GenericParser method parseIdNamePairs.
private Object parseIdNamePairs(IPatternDescriptor pattern, CharSequence sequence, IBBObjectFactory factory, boolean expectMultipleMatches, boolean preserveOrder) {
final Matcher m = pattern.getPattern().matcher(sequence);
Map<ID, IBBObject> objectMap = null;
if (expectMultipleMatches) {
if (preserveOrder) {
objectMap = new LinkedHashMap<ID, IBBObject>();
} else {
objectMap = new HashMap<ID, IBBObject>();
}
}
while (m.find()) {
final Map<String, Object> values = pattern.getValueMap(m);
ID id = null;
try {
id = factory.createBBObjectId(namespace, baseURL, (String) values.get(IPatternDescriptor.ID_PARAM));
} catch (final IDCreateException e) {
// TODO autogen e
e.printStackTrace();
}
final String name = StringUtil.stripHTMLTrim((String) values.get(IPatternDescriptor.NAME_PARAM));
final IBBObject obj = factory.createBBObject(id, new String(name), values);
if (expectMultipleMatches) {
objectMap.put(id, obj);
} else {
return obj;
}
}
if (expectMultipleMatches) {
return objectMap;
} else {
return null;
}
}
Aggregations