Skip to content

Commit

Permalink
Add method to get value of tag from a book.
Browse files Browse the repository at this point in the history
Only the `getTagStr` method is available on android because we need a
proper exception handling on wrapping side.

Fix #298
  • Loading branch information
mgautierfr committed Jan 30, 2020
1 parent 5c3c637 commit ed66344
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/wrapper/java/book.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string>("", env);
}

#undef GETTER
7 changes: 7 additions & 0 deletions src/wrapper/java/org/kiwix/kiwixlib/Book.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit ed66344

Please sign in to comment.