diff --git a/include/book.h b/include/book.h index e3bf185cd..7e3bb0cf9 100644 --- a/include/book.h +++ b/include/book.h @@ -60,6 +60,8 @@ class Book const std::string& getUrl() const { return m_url; } const std::string& getName() const { return m_name; } const std::string& getTags() const { return m_tags; } + std::string getTagStr(const std::string& tagName) const; + bool getTagBool(const std::string& tagName) const; const std::string& getOrigId() const { return m_origId; } const uint64_t& getArticleCount() const { return m_articleCount; } const uint64_t& getMediaCount() const { return m_mediaCount; } diff --git a/src/book.cpp b/src/book.cpp index 15bd31743..103535e60 100644 --- a/src/book.cpp +++ b/src/book.cpp @@ -23,6 +23,7 @@ #include "tools/base64.h" #include "tools/regexTools.h" #include "tools/networkTools.h" +#include "tools/otherTools.h" #include @@ -203,4 +204,12 @@ const std::string& Book::getFavicon() const { return m_favicon; } +std::string Book::getTagStr(const std::string& tagName) const { + return getTagValueFromTagList(convertTags(m_tags), tagName); +} + +bool Book::getTagBool(const std::string& tagName) const { + return convertStrToBool(getTagStr(tagName)); +} + } diff --git a/src/wrapper/java/book.cpp b/src/wrapper/java/book.cpp index b76492c31..77cf55dcd 100644 --- a/src/wrapper/java/book.cpp +++ b/src/wrapper/java/book.cpp @@ -66,4 +66,11 @@ GETTER(jstring, getFavicon) GETTER(jstring, getFaviconUrl) GETTER(jstring, getFaviconMimeType) +METHOD(jstring, Book, getTagStr, jstring tagName) try { + auto cRet = Book->getTagStr(jni2c(tagName, env)); + return c2jni(cRet, env); +} catch(...) { + return c2jni("", env); +} + #undef GETTER diff --git a/src/wrapper/java/org/kiwix/kiwixlib/Book.java b/src/wrapper/java/org/kiwix/kiwixlib/Book.java index 06b72e11d..f4f45d68e 100644 --- a/src/wrapper/java/org/kiwix/kiwixlib/Book.java +++ b/src/wrapper/java/org/kiwix/kiwixlib/Book.java @@ -20,6 +20,13 @@ public class Book public native String getUrl(); public native String getName(); public native String getTags(); + /** + * Return the value associated to the tag tagName + * + * @param tagName the tag name to search for. + * @return The value of the tag. If the tag is not found, return empty string. + */ + public native String getTagStr(String tagName); public native long getArticleCount(); public native long getMediaCount();