added getFolderList() to bookmarksDB

added cleanTagsString() to bookmarksDB
added getFoldersString() to Bookmark
modified getTagsString() to exclude folderTags

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@4383 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
apfelmaennchen 17 years ago
parent db25425893
commit f3a9e9c542

@ -160,6 +160,56 @@ public class bookmarksDB {
return plasmaCondenser.word2hash(user+":"+tagName.toLowerCase()); return plasmaCondenser.word2hash(user+":"+tagName.toLowerCase());
} }
public Iterator<String> getFolderList(boolean priv){
Set<String> folders = new TreeSet<String>();
String path = "";
Iterator it = this.getTagIterator(priv);
Tag tag;
while(it.hasNext()){
tag=(Tag) it.next();
if (tag.getFriendlyName().startsWith("/")) {
path = tag.getFriendlyName();
path = cleanTagsString(path);
while(path.length() > 0){
folders.add(path);
path = path.replaceAll("(/.[^/]*$)", ""); // create missing folders in path
}
}
}
folders.add("\uffff");
return (Iterator<String>) folders.iterator();
}
public static String cleanTagsString(String tagsString){
// get rid of heading, trailing and double commas since they are useless
while (tagsString.startsWith(",")) {
tagsString = tagsString.substring(1);
}
while (tagsString.endsWith(",")) {
tagsString = tagsString.substring(0,tagsString.length() -1);
}
while(tagsString.contains(",,")){
tagsString = tagsString.replaceAll(",,", ",");
}
// get rid of double and trailing slashes
while(tagsString.endsWith("/")){
tagsString = tagsString.substring(0, tagsString.length() -1);
}
while(tagsString.contains("/,")){
tagsString = tagsString.replaceAll("/,", ",");
}
while(tagsString.contains("//")){
tagsString = tagsString.replaceAll("//", "/");
}
// space characters following a comma are removed
tagsString = tagsString.replaceAll(",\\s+", ",");
return tagsString;
}
// ----------------------------------------------------------- // -----------------------------------------------------------
// bookmarksDB's functions for bookmarksTable / bookmarkCache // bookmarksDB's functions for bookmarksTable / bookmarkCache
// ----------------------------------------------------------- // -----------------------------------------------------------
@ -901,7 +951,24 @@ public class bookmarksDB {
return tags; return tags;
} }
public String getTagsString(){ public String getTagsString(){
return listManager.collection2string(getTags()); String s[] = listManager.collection2string(getTags()).split(",");
String tagsString="";
for (int i=0; i<s.length; i++){
if(!s[i].startsWith("/")){
tagsString += s[i]+",";
}
}
return tagsString;
}
public String getFoldersString(){
String s[] = listManager.collection2string(getTags()).split(",");
String foldersString="";
for (int i=0; i<s.length; i++){
if(s[i].startsWith("/")){
foldersString += s[i]+",";
}
}
return foldersString;
} }
public String getDescription(){ public String getDescription(){
if(entry.containsKey(BOOKMARK_DESCRIPTION)){ if(entry.containsKey(BOOKMARK_DESCRIPTION)){

Loading…
Cancel
Save