private static int print_XBEL(final Iterator<String> bit, int count) { BookmarksDB.Bookmark bookmark = null; Date date; while (bit.hasNext()) { bookmark = sb.bookmarksDB.getBookmark(bit.next()); date = new Date(bookmark.getTimeStamp()); prop.put( "display_xbel_" + count + "_elements", "<bookmark id=\"" + bookmark.getUrlHash() + "\" href=\"" + CharacterCoding.unicode2xml(bookmark.getUrl(), true) + "\" added=\"" + CharacterCoding.unicode2xml(ISO8601Formatter.FORMATTER.format(date), true) + "\">"); count++; prop.put("display_xbel_" + count + "_elements", "<title>"); count++; prop.putXML("display_xbel_" + count + "_elements", bookmark.getTitle()); count++; prop.put("display_xbel_" + count + "_elements", "</title>"); count++; prop.put("display_xbel_" + count + "_elements", "<info>"); count++; prop.put( "display_xbel_" + count + "_elements", "<metadata owner=\"Mozilla\" ShortcutURL=\"" + CharacterCoding.unicode2xml( bookmark.getTagsString().replaceAll("/.*,", "").toLowerCase(), true) + "\"/>"); count++; prop.put( "display_xbel_" + count + "_elements", "<metadata owner=\"YaCy\" public=\"" + Boolean.toString(bookmark.getPublic()) + "\"/>"); count++; prop.put("display_xbel_" + count + "_elements", "</info>"); count++; prop.put("display_xbel_" + count + "_elements", "<desc>"); count++; prop.putXML("display_xbel_" + count + "_elements", bookmark.getDescription()); count++; prop.put("display_xbel_" + count + "_elements", "</desc>"); count++; prop.put("display_xbel_" + count + "_elements", "</bookmark>"); count++; } return count; }
private static int recurseFolders( final Iterator<String> it, String root, int count, final boolean next, final String prev) { String fn = ""; if (next) fn = it.next(); else fn = prev; if ("\uffff".equals(fn)) { int i = prev.replaceAll("[^/]", "").length() - R; while (i > 0) { prop.put("display_xbel_" + count + "_elements", "</folder>"); count++; i--; } return count; } if (fn.startsWith(("/".equals(root) ? root : root + "/"))) { prop.put( "display_xbel_" + count + "_elements", "<folder id=\"" + BookmarkHelper.tagHash(fn) + "\">"); count++; final String title = fn; // just to make sure fn stays untouched prop.put( "display_xbel_" + count + "_elements", "<title>" + CharacterCoding.unicode2xml(title.replaceAll("(/.[^/]*)*/", ""), true) + "</title>"); count++; final Iterator<String> bit = sb.bookmarksDB.getBookmarksIterator(fn, isAdmin); count = print_XBEL(bit, count); if (it.hasNext()) { count = recurseFolders(it, fn, count, true, fn); } } else { if (count > 0) { prop.put("display_xbel_" + count + "_elements", "</folder>"); count++; } root = root.replaceAll("(/.[^/]*$)", ""); if ("".equals(root)) { root = "/"; } count = recurseFolders(it, root, count, false, fn); } return count; }