예제 #1
0
  public String extractLunchNameFromContent(final String htmlContent) throws ParseException {
    final Document document = Jsoup.parse(htmlContent);
    {
      final Elements elements = document.getElementsByClass("tipMacro");
      for (final Element element : elements) {
        for (final Element td : element.getElementsByTag("p")) {
          final String innerHtml = td.html();
          final String result = stringUtil.trim(htmlUtil.filterHtmlTages(innerHtml));
          if (result != null && result.length() > 0) {
            logger.debug("found lunch lame " + result);
            return result;
          }
        }
      }
    }
    {
      int pos = 0;
      pos = parseUtil.indexOf(htmlContent, "ac:name=\"tip\"", pos);
      try {
        pos = parseUtil.indexOf(htmlContent, "INLINE", pos);
      } catch (final ParseException e) {
        // nop
      }
      final int pstart = parseUtil.indexOf(htmlContent, "<ac:rich-text-body>", pos);
      final int pend = parseUtil.indexOf(htmlContent, "</ac:rich-text-body>", pstart);
      final String result =
          stringUtil.trim(htmlUtil.filterHtmlTages(htmlContent.substring(pstart, pend)));
      if (result != null && result.length() > 0) {
        logger.debug("found lunch name " + result);
        return result;
      }
    }

    logger.debug("extractLunchNameFromContent failed " + htmlContent);
    return null;
  }
예제 #2
0
 public boolean extractLunchSubscribed(final String content, final String fullname) {
   final boolean result = htmlUtil.unescapeHtml(content).contains(fullname);
   logger.debug("extractLunchSubscribed fullname: " + fullname + " => " + result);
   return result;
 }