Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

source/net/yacy/data/BookmarksDB: change Bookmark toString function and add getTagsJsonList

piepefa621e456c4
diff --git a/source/net/yacy/data/BookmarksDB.java b/source/net/yacy/data/BookmarksDB.java
index dcd949a3a..fc4d7bcb7 100644
--- a/source/net/yacy/data/BookmarksDB.java
+++ b/source/net/yacy/data/BookmarksDB.java
@@ -528,17 +528,34 @@ public class BookmarksDB {
}
public String getTagsString() {
- Map<String, String> tagsMap = getTags(); // Assuming getTags returns a HashMap of Strings
+ final String s[] = CommonPattern.COMMA.split(ListManager.collection2string(getTags()));
StringBuilder stringBuilder = new StringBuilder();
+ int currentTag = 1;
+ int tagCount = s.length;
+ for (final String element : s){
+ if (!element.startsWith("/")) {
+ stringBuilder.append(element); // Append the element
+ currentTag++;
- int tagCount = tagsMap.size();
- int currentTag = 0;
-
- for (Map.Entry<String, String> entry : tagsMap.entrySet()) {
- String element = entry.getValue();
+ if (currentTag < tagCount) {
+ stringBuilder.append(","); // Add comma if it's not the last element
+ }
+ }
+ }
+ return stringBuilder.toString();
+ }
+ public String getTagsJsonList() {
+ final String s[] = CommonPattern.COMMA.split(ListManager.collection2string(getTags()));
+ StringBuilder stringBuilder = new StringBuilder();
+ int currentTag = 1;
+ int tagCount = s.length;
+ stringBuilder.append("[");
+ for (final String element : s){
if (!element.startsWith("/")) {
+ stringBuilder.append("\"");
stringBuilder.append(element); // Append the element
+ stringBuilder.append("\"");
currentTag++;
if (currentTag < tagCount) {
@@ -546,6 +563,7 @@ public class BookmarksDB {
}
}
}
+ stringBuilder.append("]");
return stringBuilder.toString();
}
@@ -553,15 +571,43 @@ public class BookmarksDB {
public String getFoldersString(){
final String s[] = CommonPattern.COMMA.split(ListManager.collection2string(getTags()));
final StringBuilder stringBuilder = new StringBuilder();
+ int currentTag = 1;
+ int tagCount = s.length;
for (final String element : s){
if(element.startsWith("/")){
+ currentTag++;
stringBuilder.append(element);
- stringBuilder.append(",");
+ if (currentTag < tagCount) {
+ stringBuilder.append(","); // Add comma if it's not the last element
+ }
}
}
return stringBuilder.toString();
}
+ public String getFolderJsonList() {
+ final String s[] = CommonPattern.COMMA.split(ListManager.collection2string(getTags()));
+ StringBuilder stringBuilder = new StringBuilder();
+ int currentTag = 1;
+ int tagCount = s.length;
+ stringBuilder.append("[");
+ for (final String element : s){
+ if (!element.startsWith("/")) {
+ stringBuilder.append("\"");
+ stringBuilder.append(element); // Append the element
+ stringBuilder.append("\"");
+ currentTag++;
+
+ if (currentTag < tagCount) {
+ stringBuilder.append(","); // Add comma if it's not the last element
+ }
+ }
+ }
+ stringBuilder.append("]");
+
+ return stringBuilder.toString();
+ }
+
public String getDescription(){
if(this.entry.containsKey(BOOKMARK_DESCRIPTION)){
return this.entry.get(BOOKMARK_DESCRIPTION);