From ed66344f31c26a64a2b629ffbdcc38135ca5513e Mon Sep 17 00:00:00 2001 From: Matthieu Gautier Date: Thu, 30 Jan 2020 14:46:01 +0100 Subject: [PATCH 1/2] Add method to get value of tag from a book. Only the `getTagStr` method is available on android because we need a proper exception handling on wrapping side. Fix #298 --- src/wrapper/java/book.cpp | 7 +++++++ src/wrapper/java/org/kiwix/kiwixlib/Book.java | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/src/wrapper/java/book.cpp b/src/wrapper/java/book.cpp index b76492c..77cf55d 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 06b72e1..f4f45d6 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(); From 5cee77858eacc1685713ae15f95fe6264c0689ae Mon Sep 17 00:00:00 2001 From: Matthieu Gautier Date: Thu, 30 Jan 2020 14:51:37 +0100 Subject: [PATCH 2/2] Add flavour attribute to book. Fix #259 Fix kiwix/kiwix-tools#316 --- src/wrapper/java/book.cpp | 1 + src/wrapper/java/org/kiwix/kiwixlib/Book.java | 1 + 2 files changed, 2 insertions(+) diff --git a/src/wrapper/java/book.cpp b/src/wrapper/java/book.cpp index 77cf55d..9f7df5b 100644 --- a/src/wrapper/java/book.cpp +++ b/src/wrapper/java/book.cpp @@ -58,6 +58,7 @@ GETTER(jstring, getPublisher) GETTER(jstring, getDate) GETTER(jstring, getUrl) GETTER(jstring, getName) +GETTER(jstring, getFlavour) GETTER(jstring, getTags) GETTER(jlong, getArticleCount) GETTER(jlong, getMediaCount) diff --git a/src/wrapper/java/org/kiwix/kiwixlib/Book.java b/src/wrapper/java/org/kiwix/kiwixlib/Book.java index f4f45d6..3f00956 100644 --- a/src/wrapper/java/org/kiwix/kiwixlib/Book.java +++ b/src/wrapper/java/org/kiwix/kiwixlib/Book.java @@ -19,6 +19,7 @@ public class Book public native String getDate(); public native String getUrl(); public native String getName(); + public native String getFlavour(); public native String getTags(); /** * Return the value associated to the tag tagName