Beispiel #1
1
  public void runImpl() throws Exception {
    // create the URL corresponding to the date

    URL u = new URL(ADDRESS_ + dateFormatter1_.format(date));
    Messages.debug(3, "Rag::runImpl - reading data from URL=%1", u);
    // fetch the page into the buffer
    buffer_ = new char[BUF_SIZE_];
    Reader r = new InputStreamReader(u.openStream());
    int size = 1;
    charsread_ = 0;
    while (charsread_ < BUF_SIZE_ && size > 0) {
      size = r.read(buffer_, 0, BUF_SIZE_ - charsread_);
      if (size != -1) charsread_ += size;
      // Messages.debug(3, "Rag::runImpl - read %1 chars", String.valueOf(size));
      if (!r.ready()) break;
    }
    r.close();
    // Messages.debug(3, "Rag::runImpl - buffer=\"%1\"XXXXXXX", new String(buffer_, 0, charsread_));
    // create the results
    createResults_();
  }
Beispiel #2
0
 private void createResults_() {
   results = new LinkedList();
   String dateTime = dateFormatter2_.format(date);
   // Messages.debug(3, "Rag::createResults_ dateTime=%1", dateTime);
   String regExp = "HREF=\\/(rapp[\\/a-zA-Z0-9]*" + dateTime + "[a-zA-Z0-9_\\.]*)>";
   Messages.debug(3, "Rag::createResults_ regExp=%1", regExp);
   Regexp reg = Regexp.compile(regExp);
   // Messages.debug(3, "Rag::createResults_ compiled regexp");
   Result result;
   int pos = 0;
   while ((result = reg.searchForward(buffer_, pos, charsread_ - pos)) != null) {
     pos = result.getMatchEnd() + 1;
     // Messages.debug(3, "Rag:: gotResult:" + result.getMatch(1));
     results.add(RESULT_ADDRESS_ + result.getMatch(1));
   }
 }
Beispiel #3
0
 public Object next() {
   if (resultIterator_ != null) {
     String tmp = null;
     try {
       // parse date and further information from result
       tmp = (String) resultIterator_.next();
       // Messages.debug(-1, "Rag::next before parse");
       Date d = dateFormatter3_.parse(tmp.substring(59, 73));
       // Messages.debug(-1, "Rag::next after parse");
       h_.put("URL", tmp);
       tmp = RandomDate.format(d);
       h_.put("U_DATETIME", EtcUtil.makeURLish(tmp));
       h_.put("DATETIME", tmp);
     } catch (Exception e) {
       Messages.warn(-1, "Rag::exception during parsing of s=%1 (%2)", tmp.substring(59, 73), e);
       // e.printStackTrace();
     }
   }
   return h_;
 }