Exemplo n.º 1
0
  @Override
  public Topic getThread(int threadNum, String lastMod)
      throws ContentGetException, ContentParseException {
    String[] wgetReply = this.wgetText(this.linkThread(threadNum), lastMod);
    String threadText = wgetReply[0];
    String newLastMod = wgetReply[1];

    Topic t = null;

    Matcher mat = postGetPattern.matcher(threadText);

    while (mat.find()) {
      String text = mat.group(1);
      String type = mat.group(2);
      if (type.equals("opContainer")) {
        if (t == null) {
          t = this.parseThread(text);
        } else {
          throw new ContentParseException("Two OP posts in thread in " + threadNum);
        }
      } else {
        if (t != null) {
          t.addPost(this.parsePost(text, t.getNum()));
        } else {
          throw new ContentParseException("Thread without OP post in " + threadNum);
        }
      }
    }

    t.setLastMod(newLastMod);
    return t;
  }