// Software like FindBugs will complain we're pointlessly calling the
// String constructor, but in this case, we know exactly what we're doing.
Matcher mat = numPattern.matcher(text);
if(!mat.find()) {
throw new ContentParseException("Could not parse thread (post num regex failed)");
}
int num = Integer.parseInt(mat.group(1));
mat = titlePattern.matcher(text);
if(!mat.find()) {
throw new ContentParseException("Could not parse thread (post title regex failed)");
}
String title = new String(mat.group(1));
String email = null;
mat = emailPattern.matcher(text);
if(mat.find()) {
email = new String(mat.group(1));
}
mat = postParsePattern1.matcher(text);
if(!mat.find()) {
throw new ContentParseException("Could not parse thread (post info block regex failed)");
}
String name = new String(mat.group(1));
String trip = (mat.group(2) != null) ? new String(mat.group(2)) : null;
String capcode = (mat.group(3) != null) ? new String(mat.group(3)) : null;
String uid = mat.group(4);
String country = (mat.group(5) != null) ? new String(mat.group(5)) : null;
mat = datePattern.matcher(text);
if(!mat.find()) {
throw new ContentParseException("Could not parse thread (post timestamp regex failed)");
}
long dateUtc = Long.parseLong(mat.group(1));
mat = postParsePattern2.matcher(text);
String link = null;
boolean spoiler = false;
String fileSize = null;
int width = 0;
int height = 0;
String fileName = null;
String md5b64 = null;
int tHeight = 0;
int tWidth = 0;
if(mat.find()) {
link = (mat.group(2) != null) ? new String(mat.group(2)) : null;
spoiler = (mat.group(3) != null);
fileSize = (mat.group(4) != null) ? new String(mat.group(4)) : null;
width = (mat.group(5) != null) ? Integer.parseInt(mat.group(5)) : 0;
height = (mat.group(6) != null) ? Integer.parseInt(mat.group(6)) : 0;
fileName = (mat.group(7) == null) ?
((mat.group(1) != null) ? new String(mat.group(1)) : null) :
new String(mat.group(7));
md5b64 = (mat.group(8) != null) ? new String(mat.group(8)) : null;
tHeight = (mat.group(9) != null) ? Integer.parseInt(mat.group(9)) : 0;
tWidth = (mat.group(10) != null) ? Integer.parseInt(mat.group(10)) : 0;
}
mat = commentPattern.matcher(text);
if(!mat.find()) {
throw new ContentParseException("Could not parse thread (post comment regex failed)");
}
String comment = new String(mat.group(1));
boolean sticky = false;
mat = stickyPattern.matcher(text);