From 918445a2f433fa5ad3d622b6ac6d59792f3bee96 Mon Sep 17 00:00:00 2001 From: allo Date: Fri, 24 Mar 2006 14:34:27 +0000 Subject: [PATCH] Bugfix for last commit. git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@1964 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- htroot/Bookmarks.java | 3 ++- source/de/anomic/data/bookmarksDB.java | 29 ++++++++++++++------------ 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/htroot/Bookmarks.java b/htroot/Bookmarks.java index 3b1b4af87..a23e480a4 100644 --- a/htroot/Bookmarks.java +++ b/htroot/Bookmarks.java @@ -49,6 +49,7 @@ import java.io.File; import java.io.IOException; import java.net.MalformedURLException; import java.util.ArrayList; +import java.util.HashSet; import java.util.Iterator; import de.anomic.data.bookmarksDB; @@ -103,7 +104,7 @@ public class Bookmarks { if(tagsString.equals("")){ tagsString="unsorted"; //defaulttag } - ArrayList tags=listManager.string2arraylist(tagsString); + HashSet tags=listManager.string2hashset(tagsString); bookmarksDB.Bookmark bookmark = switchboard.bookmarksDB.createBookmark(url); if(bookmark != null){ diff --git a/source/de/anomic/data/bookmarksDB.java b/source/de/anomic/data/bookmarksDB.java index ca1cbc32c..91355ba50 100644 --- a/source/de/anomic/data/bookmarksDB.java +++ b/source/de/anomic/data/bookmarksDB.java @@ -219,13 +219,13 @@ public class bookmarksDB { */ public void storeBookmark(Bookmark bookmark){ try { - bookmarksDB.this.bookmarksTable.set(bookmark.getUrlHash(), bookmark.mem); + bookmarksDB.this.bookmarksTable.set(bookmark.getUrlHash(), bookmark.getMap()); } catch (IOException e) {} } public void flushBookmarkCache(){ Iterator it=bookmarkCache.keySet().iterator(); while(it.hasNext()){ - storeBookmark((Bookmark) it.next()); + storeBookmark((Bookmark) bookmarkCache.get(it.next())); } bookmarkCache=new HashMap(); } @@ -347,10 +347,10 @@ public class bookmarksDB { saveTag(tag); Iterator it = urlHashes.iterator(); Bookmark bookmark; - ArrayList tags; + HashSet tags; while (it.hasNext()) { bookmark = getBookmark((String) it.next()); - tags = listManager.string2arraylist(bookmark.getTags()); + tags = listManager.string2hashset(bookmark.getTags()); tags.remove(oldName); //this will fail, if upper/lowercase is not matching tags.add(newName); bookmark.setTags(tags, true); @@ -478,7 +478,7 @@ public class bookmarksDB { Iterator it; String url,title; Bookmark bm; - ArrayList tags=listManager.string2arraylist(tag); //this allow multiple default tags + HashSet tags=listManager.string2hashset(tag); //this allow multiple default tags try { //load the links htmlFilterContentScraper scraper = new htmlFilterContentScraper(baseURL); @@ -542,13 +542,13 @@ public class bookmarksDB { if(attributes.getNamedItem("time")!=null){ time=attributes.getNamedItem("time").getNodeValue(); } - ArrayList tags=new ArrayList(); + HashSet tags=new HashSet(); if(title != null){ bm.setProperty(Bookmark.BOOKMARK_TITLE, title); } if(tagsString!=null){ - tags = listManager.string2arraylist(tagsString.replace(' ', ',')); + tags = listManager.string2hashset(tagsString.replace(' ', ',')); } bm.setTags(tags, true); if(time != null){ @@ -760,6 +760,9 @@ public class bookmarksDB { mem=new HashMap(); mem.put(BOOKMARK_URL, url); } + public Map getMap(){ + return mem; + } public String getUrlHash(){ return urlHash; } @@ -806,11 +809,11 @@ public class bookmarksDB { //setBookmarksTable(); } public void addTag(String tag){ - ArrayList tags; + HashSet tags; if(!mem.containsKey(BOOKMARK_TAGS)){ - tags=new ArrayList(); + tags=new HashSet(); }else{ - tags=listManager.string2arraylist((String) mem.get(BOOKMARK_TAGS)); + tags=listManager.string2hashset((String) mem.get(BOOKMARK_TAGS)); } tags.add(tag); this.setTags(tags, true); @@ -819,7 +822,7 @@ public class bookmarksDB { * set the Tags of the bookmark, and write them into the tags table. * @param tags a ArrayList with the tags */ - public void setTags(ArrayList tags){ + public void setTags(HashSet tags){ setTags(tags, true); } /** @@ -827,8 +830,8 @@ public class bookmarksDB { * @param tags ArrayList with the tagnames * @param local sets, whether the updated tags should be stored to tagsDB */ - public void setTags(ArrayList tags, boolean local){ - mem.put(BOOKMARK_TAGS, listManager.arraylist2string(tags)); + public void setTags(HashSet tags, boolean local){ + mem.put(BOOKMARK_TAGS, listManager.hashset2string(tags)); Iterator it=tags.iterator(); while(it.hasNext()){ String tagName=(String) it.next();