Exemple #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;
  }
Exemple #2
0
  @Override
  public Page getPage(int pageNum, String lastMod)
      throws ContentGetException, ContentParseException {
    String[] wgetReply = this.wgetText(this.linkPage(pageNum), lastMod);
    String pageText = wgetReply[0];
    String newLastMod = wgetReply[1];

    Page p = new Page(pageNum);
    Topic t = null;

    Matcher mat = postGetPattern.matcher(pageText);

    while (mat.find()) {
      String text = mat.group(1);
      String type = mat.group(2);

      if (type.equals("opContainer")) {
        t = this.parseThread(text);
        p.addThread(t);
      } else {
        if (t != null) t.addPost(this.parsePost(text, t.getNum()));
      }
    }

    p.setLastMod(newLastMod);
    return p;
  }