use of org.eclipse.ecf.internal.provider.vbulletin.identity.ThreadMessageID in project ecf by eclipse.
the class VBParser method parseMessages2.
public List<ThreadMessage> parseMessages2(final CharSequence seq, final ID lastReadId, boolean desc, SkippedStatus skipped) throws BBException {
Matcher m;
ThreadMessage msg;
List<ThreadMessage> messages = new ArrayList<ThreadMessage>();
m = PAT_MSG.matcher(seq);
while (m.find()) {
ThreadMessageFactory tmf = new ThreadMessageFactory();
ThreadMessageID id = null;
try {
id = (ThreadMessageID) tmf.createBBObjectId(namespace, baseURL, m.group(1));
} catch (NumberFormatException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IDCreateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if (lastReadId == null || id.getLongValue() > ((ThreadMessageID) lastReadId).getLongValue()) {
String msgSrc = m.group(2);
msg = parseMessage2(id, msgSrc);
if (msg != null) {
if (desc) {
messages.add(0, msg);
} else {
messages.add(msg);
}
}
} else {
skipped.messagesSkipped = true;
}
}
return messages;
}
use of org.eclipse.ecf.internal.provider.vbulletin.identity.ThreadMessageID in project ecf by eclipse.
the class VBParser method parseMessage2.
private ThreadMessage parseMessage2(final ID id, final CharSequence seq) {
ThreadMessage msg = null;
ThreadMessageFactory tmf = new ThreadMessageFactory();
msg = (ThreadMessage) tmf.createBBObject(id, null, null);
Matcher m;
String uname;
Long l = parseTimestamp(seq);
if (l != null) {
msg.timePosted = new Date(l);
}
m = Pattern.compile("<div id=\"postmenu_" + ((ThreadMessageID) id).getLongValue() + "\">(.*?)</div>", Pattern.DOTALL).matcher(seq);
if (m.find()) {
String userInfoStr = m.group(1);
m = PAT_MSG_USER.matcher(userInfoStr);
if (m.find()) {
MemberFactory mf = new MemberFactory();
uname = new String(StringUtil.simpleStripHTML(m.group(3)));
ID uid = null;
try {
uid = mf.createBBObjectId(namespace, baseURL, m.group(2));
} catch (NumberFormatException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IDCreateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
msg.author = (IMember) mf.createBBObject(uid, uname, null);
} else {
// Didn't find a registered author, so the userinfo should
// contain only the username.
msg.author = new Member(new String(userInfoStr.trim()));
}
}
m = Pattern.compile("#<a href=\"showpost.php\\?p=" + ((ThreadMessageID) id).getLongValue() + "(?:.*?)><strong>([0-9]+)</strong></a>").matcher(seq);
m.find();
msg.number = Integer.parseInt(m.group(1));
m = PAT_MSG_TITLE.matcher(seq);
m.find();
msg.setNameInternal(new String(StringUtil.stripHTMLTrim(m.group(1))));
m = PAT_MSG_MESSAGE.matcher(seq);
m.find();
String message = StringUtil.stripHTMLFullTrim(m.group(1));
msg.message = message;
return msg;
}
Aggregations