Exemple #1
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_;
 }
Exemple #2
0
  /*  Broken:
   *  http://sohowww.nascom.nasa.gov/data/synoptic/gif/000123/nanc_164Mz_fd_2023_1046.gif
   *  http://sohowww.nascom.nasa.gov/data/synoptic/gif/000123/nanc_164Mz_fd_2023_0916.gif
   *  http://sohowww.nascom.nasa.gov/data/synoptic/gif/000123/meud_halph_fd_2023_1356.gif
   *  http://sohowww.nascom.nasa.gov/data/synoptic/gif/000213/nanc_164Mz_fd_2113_0919.gif
   *
   *  Ok:
   *  http://sohowww.nascom.nasa.gov/data/synoptic/gif/000212/pdmo_cogha_fd_20000212_0814.gif
   *  http://sohowww.nascom.nasa.gov/data/synoptic/gif/000212/pdmo_cogha_fd_20000212_0945.gif
   */
  private static void determineAttributes_(Hashtable h, String url) {
    int idxl = url.lastIndexOf('/') + 1;
    int idxr = url.indexOf('_');
    String tmp = null;
    try {
      // Messages.debug(2, "Soho:DeterminAttrib1 idxl=%1 idxr=%2 url=%3", String.valueOf(idxl),
      // String.valueOf(idxr), url);
      tmp = (String) INSTITUTE_CODES_.get(url.substring(idxl, idxr));
      h.put("U_INSTITUTE_CODE", (tmp == null) ? "unknown" : EtcUtil.makeURLish(tmp));
      h.put("INSTITUTE_CODE", tmp);

      idxl = idxr + 1;
      idxr = url.indexOf('_', idxl);
      // Messages.debug(2, "Soho:DeterminAttrib2 idxl=%1 idxr=%2", String.valueOf(idxl),
      // String.valueOf(idxr));
      tmp = (String) TYPE_CODES_.get(url.substring(idxl, idxr));
      h.put("U_TYPE_CODE", (tmp == null) ? "unknown" : EtcUtil.makeURLish(tmp));
      h.put("TYPE_CODE", tmp);

      idxl = idxr + 1;
      idxr = url.indexOf('_', idxl);
      // Messages.debug(2, "Soho:DeterminAttrib3 idxl=%1 idxr=%2", String.valueOf(idxl),
      // String.valueOf(idxr));
      tmp = (String) INFO_CODES_.get(url.substring(idxl, idxr));
      h.put("U_INFO_CODE", (tmp == null) ? "unknown" : EtcUtil.makeURLish(tmp));

      idxl = idxr + 1;
      idxr = url.indexOf('_', idxl);
      // Messages.debug(2, "Soho:DeterminAttrib4 idxl=%1 idxr=%2", String.valueOf(idxl),
      // String.valueOf(idxr));
      tmp = url.substring(idxl, idxr);
      idxl = idxr + 1;
      idxr = url.indexOf('.', idxl);
      // Messages.debug(2, "Soho:DeterminAttrib5 idxl=%1 idxr=%2", String.valueOf(idxl),
      // String.valueOf(idxr));
      tmp += url.substring(idxl, idxr);
      Date d = null;
      if (tmp.length() == 12) {
        // Messages.debug(1, "Soho::determineAttributes before parse");
        d = dateFormatter2_.parse(tmp);
        tmp = RandomDate.format(d);
      } else if (tmp.length() == 8) tmp = "date not parsed";
      h.put("U_DATETIME", EtcUtil.makeURLish(tmp));
      h.put("DATETIME", tmp);

      idxl = url.lastIndexOf(".");
      // Messages.debug(2, "Soho:DeterminAttrib6 idxl=%1", String.valueOf(idxl));
      tmp = (String) FORMAT_CODES_.get(url.substring(idxl + 1));
      // Messages.debug(1, "Soho::determineAttributes formatcode=%1", tmp);
      h.put("U_FORMAT_CODE", (tmp == null) ? "unknown" : EtcUtil.makeURLish(tmp));
      // Messages.debug(3, SOH02_, url);
    } catch (Exception e) {
      Messages.warn(0, SOH01_, url);
      // Messages.debug(1, "Soho::exception during parsing (%1)", e);
      // e.printStackTrace();
      if (h.get("INSTITUTE_CODE") == null) h.put("INSTITUTE_CODE", "unknown");
      if (h.get("U_INSTITUTE_CODE") == null) h.put("U_INSTITUTE_CODE", "unknown");
      if (h.get("TYPE_CODE") == null) h.put("TYPE_CODE", "unknown");
      if (h.get("U_TYPE_CODE") == null) h.put("U_TYPE_CODE", "unknown");
      if (h.get("U_INFO_CODE") == null) h.put("U_INFO_CODE", "unknown");
      if (h.get("DATE_TIME") == null) h.put("DATE_TIME", "unknown");
      if (h.get("U_DATE_TIME") == null) h.put("U_DATE_TIME", "unknown");
      if (h.get("U_FORMAT_CODE") == null) h.put("U_FORMAT_CODE", "unknown");
    }
  }