[jsword-devel] API Example
Samuel Lucas Vaz de Mello
samuelmello at gmail.com
Fri Sep 10 11:21:51 MST 2010
Which calls returns the timeout exception? Can you post the full stack
trace?
- Samuel
On Fri, Sep 10, 2010 at 2:49 PM, Matthias Wegner <mic.mat.wegner at web.de>wrote:
> Hi All,
>
>
>
> my Name is Matthias Wegner from Germany, Freiburg. I develop since 13 years
> java and want to use the jsword api for an own application. For that I need
> some bibles and a search for the bible text in dependency of the “key”. I
> try since three days to get the given API Example working. I think I
> understood in a raw concept what the different Installer-Classes and the
> WebRessource-Class are doing, but I don’t get it what is going wrong.
>
>
>
> i tried to get a working APIExample. I use the newest Eclipse, load all
> Librarys from Maven and have a working set. My problem is, that I always get
> a timeout (I moved, so I only have UMTS at the moment). When I put the
> timeout in WebResource-Class to 5000ms the Application below starts, but I
> always get in the Console
>
>
>
> *ESV***
>
> *Book contains key: false***
>
> *Text is ''*
>
> * *
>
> I don‘t get what i am doing wrong. Is the problem a connection problem?
> When I put manually the esv.conf in the mods.d-directory, then the book is
> removed and deleted (that means only the config-file). Is that the way it
> goes? I downloaded the esv and put it relative to mods.d to “../modules”. In
> the full desktop application this works fine, so I don’t understood whats
> wrong.
>
>
>
> I really appreciate some help or hints. Can you give me some tryouts, so I
> can find the “real” problem?
>
>
>
> Warm Regards,
>
> Matthias
>
>
>
> Example Code:
>
>
>
> * public* *static* *void* main(String[] args) {
>
>
>
> InstallManager imanager = *new* InstallManager();
>
> Installer installer = imanager.getInstaller("CrossWire");
>
> *try* {
>
> installer.reloadBookList();
>
> }
>
> *catch* (InstallException e) {
>
> e.printStackTrace();
>
> }
>
>
>
> *List* availableBooks = installer.getBooks(*new* MyBookFilter(
> "ESV"));
>
> Book book = (Book) availableBooks.get(0);
>
>
>
> *if* (book != *null*) {
>
> *try* {
>
> *if* (Books.*installed*().getBook("ESV") != *null*) {
>
> System.*out*.println("Book " + book.getInitials() + " is
> removed");
>
> Books.*installed*().removeBook(book);
>
> System.*out*.println("Book " + book.getInitials() + "
> is deleted");
>
> book.getDriver().delete(book);
>
> }
>
> }
>
> *catch* (BookException e1)
>
> {
>
> e1.printStackTrace();
>
> }
>
>
>
> }
>
>
>
> System.*out*.println(book.getInitials());
>
>
>
> *try* {
>
> installer.install(book);
>
> *if* (Books.*installed*().getBook("ESV") != *null*) {
>
> System.*out*.println("Book is NOT empty");
>
> }
>
> }
>
> *catch* (InstallException e) {
>
> e.printStackTrace();
>
> }
>
>
>
> *try* {
>
> Key key = book.getKey("Gen 1:1");
>
> System.*out*.println("Book contains key: "+
> book.contains(key));
>
> BookData data = *new* BookData(book, key);
>
> String text = OSISUtil.*getCanonicalText*
> (data.getOsisFragment());
>
> System.*out*.println("Text is '" + text+"'");
>
> } *catch* (NoSuchKeyException e) {
>
> e.printStackTrace();
>
> } *catch* (BookException e) {
>
> e.printStackTrace();
>
> }
>
>
>
> System.*exit*(1);
>
> }
>
>
>
> *static* *class* MyBookFilter *implements* BookFilter
>
> {
>
> *public* MyBookFilter(String bookName)
>
> {
>
> name = bookName;
>
> }
>
>
>
> *public* *boolean* test(Book bk)
>
> {
>
> *return* bk.getInitials().equals(name);
>
> }
>
>
>
> *private* String name;
>
> }
>
> _______________________________________________
> jsword-devel mailing list
> jsword-devel at crosswire.org
> http://www.crosswire.org/mailman/listinfo/jsword-devel
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.crosswire.org/pipermail/jsword-devel/attachments/20100910/658f5fb0/attachment-0001.html>
More information about the jsword-devel
mailing list