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 String getBookmarks(String searchQuery) {
   // This is more of a scan. Not efficient but it does the
   // job for now considering the number of entries is limited.
   String[] keywords = Strings.split(searchQuery);
   BookmarksHistory history = BookmarksHistory.getInstance();
   Collection<HistoryEntry<BookmarkInfo>> entries = history.getAllEntries();
   Collection<ScoredEntry> sortedEntries = new TreeSet<ScoredEntry>();
   for (HistoryEntry<BookmarkInfo> entry : entries) {
     int matchScore = this.getMatchScore(entry.getItemInfo(), keywords);
     if (matchScore > 0) {
       sortedEntries.add(new ScoredEntry(entry, matchScore));
     }
   }
   Collection<HistoryEntry<BookmarkInfo>> finalEntries =
       new ArrayList<HistoryEntry<BookmarkInfo>>();
   for (ScoredEntry scoredEntry : sortedEntries) {
     finalEntries.add(scoredEntry.getHistoryEntry());
   }
   return this.getBookmarks(finalEntries);
 }