private void writeBookmark(PrintWriter writer, HistoryEntry<BookmarkInfo> entry) { java.net.URL url = entry.getUrl(); String urlText = url.toExternalForm(); BookmarkInfo binfo = entry.getItemInfo(); String text = binfo.getTitle(); if (text == null || text.length() == 0) { text = urlText; } long elapsed = System.currentTimeMillis() - entry.getTimetstamp(); String description = binfo.getDescription(); if (description == null) { description = ""; } writer.println("<LI>"); writer.println("<DIV>"); writer.println( "<A href=\"" + urlText + "\">" + text + "</A> (" + Timing.getElapsedText(elapsed) + " ago)"); writer.println("</DIV>"); writer.println("<DIV>"); writer.println(description); writer.println("</DIV>"); writer.println("</LI>"); }
private int getMatchScore(BookmarkInfo binfo, String keyword) { String keywordTL = keyword.toLowerCase(); int score = 0; String urlText = binfo.getUrl().toExternalForm(); if (urlText.contains(keyword)) { score += 3; } else if (urlText.toLowerCase().contains(keywordTL)) { score += 2; } String title = binfo.getTitle(); if (title != null && title.contains(keyword)) { score += 8; } else if (title != null && title.toLowerCase().contains(keywordTL)) { score += 6; } String description = binfo.getDescription(); if (description != null && description.contains(keyword)) { score += 3; } else if (description != null && description.toLowerCase().contains(keywordTL)) { score += 2; } String[] tags = binfo.getTags(); if (tags != null) { for (int i = 0; i < tags.length; i++) { if (tags[i].equals(keyword)) { score += 8; } else if (tags[i].toLowerCase().equals(keywordTL)) { score += 6; } } } return score; }