Example #1
0
  private boolean getNextEntryURL(String allText, int entryNumber, Map<String, JLabel> entries) {
    String toFind = "<div class=\"numbering\">";
    int index = allText.indexOf(toFind, piv);
    int endIndex = allText.indexOf("<br clear=\"all\" />", index);
    piv = endIndex;

    if (index >= 0) {
      String text = allText.substring(index, endIndex);
      // Always try RIS import first
      Matcher fullCitation = ACMPortalFetcher.FULL_CITATION_PATTERN.matcher(text);
      String item;
      if (fullCitation.find()) {
        String link = getEntryBibTeXURL(fullCitation.group(1));
        if (endIndex > 0) {
          StringBuilder sb = new StringBuilder();

          // Find authors:
          String authMarker = "<div class=\"authors\">";
          int authStart = text.indexOf(authMarker);
          if (authStart >= 0) {
            int authEnd = text.indexOf("</div>", authStart + authMarker.length());
            if (authEnd >= 0) {
              sb.append("<p>").append(text.substring(authStart, authEnd)).append("</p>");
            }
          }
          // Find title:
          Matcher titM = ACMPortalFetcher.TITLE_PATTERN.matcher(text);
          if (titM.find()) {
            sb.append("<p>").append(titM.group(1)).append("</p>");
          }

          String sourceMarker = "<div class=\"source\">";
          int sourceStart = text.indexOf(sourceMarker);
          if (sourceStart >= 0) {
            int sourceEnd = text.indexOf("</div>", sourceStart + sourceMarker.length());
            if (sourceEnd >= 0) {
              String sourceText = text.substring(sourceStart, sourceEnd);
              // Find source:
              Matcher source = ACMPortalFetcher.SOURCE_PATTERN.matcher(sourceText);
              if (source.find()) {
                sb.append("<p>").append(source.group(1)).append("</p>");
              }
            }
          }

          item = sb.toString();
        } else {
          item = link;
        }

        JLabel preview = new JLabel("<html>" + item + "</html>");
        preview.setPreferredSize(new Dimension(750, 100));
        entries.put(link, preview);
        return true;
      }
      LOGGER.warn("Citation unmatched " + Integer.toString(entryNumber));
      return false;
    }
    return false;
  }
Example #2
0
  private String makeUrl() {
    StringBuilder sb =
        new StringBuilder(ACMPortalFetcher.START_URL)
            .append(ACMPortalFetcher.SEARCH_URL_PART)
            .append(terms.replace(" ", "%20"))
            .append(ACMPortalFetcher.SEARCH_URL_PART_II);

    if (acmOrGuide) {
      sb.append("ACM");
    } else {
      sb.append("GUIDE");
    }
    sb.append(ACMPortalFetcher.END_URL);
    return sb.toString();
  }