[sword-svn] r2462 - in trunk/bindings: corba/omniorbcpp corba/orbitcpp java-jni java-jni/jni java-jni/src/org/crosswire/android/sword
scribe at crosswire.org
scribe at crosswire.org
Tue Oct 13 22:38:40 MST 2009
Author: scribe
Date: 2009-10-13 22:38:40 -0700 (Tue, 13 Oct 2009)
New Revision: 2462
Modified:
trunk/bindings/corba/omniorbcpp/swordorb-impl.cpp
trunk/bindings/corba/orbitcpp/swordorb-impl.cpp
trunk/bindings/java-jni/Makefile
trunk/bindings/java-jni/jni/Android.mk
trunk/bindings/java-jni/jni/org_crosswire_android_sword_SWModule.h
trunk/bindings/java-jni/jni/swordstub.cpp
trunk/bindings/java-jni/src/org/crosswire/android/sword/SWMgr.java
trunk/bindings/java-jni/src/org/crosswire/android/sword/SWModule.java
Log:
updated to impl all interface methods and supply search progress feedback
Modified: trunk/bindings/corba/omniorbcpp/swordorb-impl.cpp
===================================================================
--- trunk/bindings/corba/omniorbcpp/swordorb-impl.cpp 2009-10-13 17:33:47 UTC (rev 2461)
+++ trunk/bindings/corba/omniorbcpp/swordorb-impl.cpp 2009-10-14 05:38:40 UTC (rev 2462)
@@ -103,7 +103,6 @@
delegate->RenderText(); // force parse
std::vector<SWBuf> results;
swordorb::StringList *retVal = new swordorb::StringList;
- int count = 0;
sword::AttributeTypeList &entryAttribs = delegate->getEntryAttributes();
sword::AttributeTypeList::iterator i1Start, i1End;
@@ -158,7 +157,7 @@
(*retVal)[i] = CORBA::string_dup(assureValidUTF8(delegate->RenderText(results[i].c_str())));
}
else {
- (*retVal)[count++] = CORBA::string_dup(assureValidUTF8(results[i].c_str()));
+ (*retVal)[i] = CORBA::string_dup(assureValidUTF8(results[i].c_str()));
}
}
Modified: trunk/bindings/corba/orbitcpp/swordorb-impl.cpp
===================================================================
--- trunk/bindings/corba/orbitcpp/swordorb-impl.cpp 2009-10-13 17:33:47 UTC (rev 2461)
+++ trunk/bindings/corba/orbitcpp/swordorb-impl.cpp 2009-10-14 05:38:40 UTC (rev 2462)
@@ -226,7 +226,6 @@
delegate->RenderText(); // force parse
std::vector<SWBuf> results;
StringList *retVal = new StringList;
- int count = 0;
sword::AttributeTypeList &entryAttribs = delegate->getEntryAttributes();
sword::AttributeTypeList::iterator i1Start, i1End;
@@ -281,7 +280,7 @@
(*retVal)[i] = CORBA::string_dup(delegate->RenderText(results[i].c_str()));
}
else {
- (*retVal)[count++] = CORBA::string_dup(results[i].c_str());
+ (*retVal)[i] = CORBA::string_dup(results[i].c_str());
}
}
Modified: trunk/bindings/java-jni/Makefile
===================================================================
--- trunk/bindings/java-jni/Makefile 2009-10-13 17:33:47 UTC (rev 2461)
+++ trunk/bindings/java-jni/Makefile 2009-10-14 05:38:40 UTC (rev 2462)
@@ -7,6 +7,7 @@
javap -s -classpath classes/ org.crosswire.android.sword.SWMgr.ModInfo > ModInfo.txt
javap -s -classpath classes/ org.crosswire.android.sword.SWModule > SWModule.txt
javap -s -classpath classes/ org.crosswire.android.sword.SWModule.SearchHit > SearchHit.txt
+ javap -s -classpath classes/ org.crosswire.android.sword.SWModule.SearchProgressReporter > SearchProgressReporter.txt
cp src/org/crosswire/android/sword/*.java /home/scribe/workspace/bishop/src/org/crosswire/android/sword/
Modified: trunk/bindings/java-jni/jni/Android.mk
===================================================================
--- trunk/bindings/java-jni/jni/Android.mk 2009-10-13 17:33:47 UTC (rev 2461)
+++ trunk/bindings/java-jni/jni/Android.mk 2009-10-14 05:38:40 UTC (rev 2462)
@@ -34,139 +34,139 @@
-D__SGI_STL_INTERNAL_PAIR_H \
-DANDROID \
-DOS_ANDROID
-LOCAL_SRC_FILES := ../../../../../sword/src/modules/comments/zcom/zcom.cpp \
-../../../../../sword/src/modules/comments/rawfiles/rawfiles.cpp \
-../../../../../sword/src/modules/comments/rawcom4/rawcom4.cpp \
-../../../../../sword/src/modules/comments/rawcom/rawcom.cpp \
-../../../../../sword/src/modules/comments/swcom.cpp \
-../../../../../sword/src/modules/comments/hrefcom/hrefcom.cpp \
-../../../../../sword/src/modules/swmodule.cpp \
-../../../../../sword/src/modules/tests/echomod.cpp \
-../../../../../sword/src/modules/genbook/swgenbook.cpp \
-../../../../../sword/src/modules/genbook/rawgenbook/rawgenbook.cpp \
-../../../../../sword/src/modules/lexdict/swld.cpp \
-../../../../../sword/src/modules/lexdict/rawld4/rawld4.cpp \
-../../../../../sword/src/modules/lexdict/zld/zld.cpp \
-../../../../../sword/src/modules/lexdict/rawld/rawld.cpp \
-../../../../../sword/src/modules/texts/rawtext/rawtext.cpp \
-../../../../../sword/src/modules/texts/rawtext4/rawtext4.cpp \
-../../../../../sword/src/modules/texts/swtext.cpp \
-../../../../../sword/src/modules/texts/ztext/ztext.cpp \
-../../../../../sword/src/modules/common/rawstr4.cpp \
-../../../../../sword/src/modules/common/lzsscomprs.cpp \
-../../../../../sword/src/modules/common/zipcomprs.cpp \
-../../../../../sword/src/modules/common/rawverse4.cpp \
-../../../../../sword/src/modules/common/swcipher.cpp \
-../../../../../sword/src/modules/common/swcomprs.cpp \
-../../../../../sword/src/modules/common/rawverse.cpp \
-../../../../../sword/src/modules/common/sapphire.cpp \
-../../../../../sword/src/modules/common/zstr.cpp \
-../../../../../sword/src/modules/common/entriesblk.cpp \
-../../../../../sword/src/modules/common/zverse.cpp \
-../../../../../sword/src/modules/common/rawstr.cpp \
-../../../../../sword/src/modules/filters/gbfwordjs.cpp \
-../../../../../sword/src/modules/filters/utf8latin1.cpp \
-../../../../../sword/src/modules/filters/utf8greekaccents.cpp \
-../../../../../sword/src/modules/filters/utf16utf8.cpp \
-../../../../../sword/src/modules/filters/gbfwebif.cpp \
-../../../../../sword/src/modules/filters/plainfootnotes.cpp \
-../../../../../sword/src/modules/filters/utf8transliterator.cpp \
-../../../../../sword/src/modules/filters/gbfstrongs.cpp \
-../../../../../sword/src/modules/filters/osisplain.cpp \
-../../../../../sword/src/modules/filters/thmlhtmlhref.cpp \
-../../../../../sword/src/modules/filters/thmlgbf.cpp \
-../../../../../sword/src/modules/filters/utf8utf16.cpp \
-../../../../../sword/src/modules/filters/utf8cantillation.cpp \
-../../../../../sword/src/modules/filters/utf8arshaping.cpp \
-../../../../../sword/src/modules/filters/cipherfil.cpp \
-../../../../../sword/src/modules/filters/thmlheadings.cpp \
-../../../../../sword/src/modules/filters/thmlscripref.cpp \
-../../../../../sword/src/modules/filters/latin1utf8.cpp \
-../../../../../sword/src/modules/filters/gbfhtml.cpp \
-../../../../../sword/src/modules/filters/thmlosis.cpp \
-../../../../../sword/src/modules/filters/utf8nfkd.cpp \
-../../../../../sword/src/modules/filters/thmlstrongs.cpp \
-../../../../../sword/src/modules/filters/osisvariants.cpp \
-../../../../../sword/src/modules/filters/thmlmorph.cpp \
-../../../../../sword/src/modules/filters/gbfplain.cpp \
-../../../../../sword/src/modules/filters/gbfhtmlhref.cpp \
-../../../../../sword/src/modules/filters/utf8html.cpp \
-../../../../../sword/src/modules/filters/utf8nfc.cpp \
-../../../../../sword/src/modules/filters/rtfhtml.cpp \
-../../../../../sword/src/modules/filters/gbfredletterwords.cpp \
-../../../../../sword/src/modules/filters/latin1utf16.cpp \
-../../../../../sword/src/modules/filters/osisscripref.cpp \
-../../../../../sword/src/modules/filters/thmlhtml.cpp \
-../../../../../sword/src/modules/filters/gbfthml.cpp \
-../../../../../sword/src/modules/filters/teihtmlhref.cpp \
-../../../../../sword/src/modules/filters/gbfrtf.cpp \
-../../../../../sword/src/modules/filters/gbfosis.cpp \
-../../../../../sword/src/modules/filters/teirtf.cpp \
-../../../../../sword/src/modules/filters/thmlwordjs.cpp \
-../../../../../sword/src/modules/filters/papyriplain.cpp \
-../../../../../sword/src/modules/filters/osisfootnotes.cpp \
-../../../../../sword/src/modules/filters/osiswordjs.cpp \
-../../../../../sword/src/modules/filters/osismorph.cpp \
-../../../../../sword/src/modules/filters/osislemma.cpp \
-../../../../../sword/src/modules/filters/osisredletterwords.cpp \
-../../../../../sword/src/modules/filters/osisrtf.cpp \
-../../../../../sword/src/modules/filters/gbfheadings.cpp \
-../../../../../sword/src/modules/filters/osisruby.cpp \
-../../../../../sword/src/modules/filters/osishtmlhref.cpp \
-../../../../../sword/src/modules/filters/utf8bidireorder.cpp \
-../../../../../sword/src/modules/filters/thmlrtf.cpp \
-../../../../../sword/src/modules/filters/swoptfilter.cpp \
-../../../../../sword/src/modules/filters/utf8arabicpoints.cpp \
-../../../../../sword/src/modules/filters/osisstrongs.cpp \
-../../../../../sword/src/modules/filters/osisheadings.cpp \
-../../../../../sword/src/modules/filters/unicodertf.cpp \
-../../../../../sword/src/modules/filters/gbffootnotes.cpp \
-../../../../../sword/src/modules/filters/greeklexattribs.cpp \
-../../../../../sword/src/modules/filters/osiswebif.cpp \
-../../../../../sword/src/modules/filters/thmlfootnotes.cpp \
-../../../../../sword/src/modules/filters/thmlplain.cpp \
-../../../../../sword/src/modules/filters/osisosis.cpp \
-../../../../../sword/src/modules/filters/utf8hebrewpoints.cpp \
-../../../../../sword/src/modules/filters/osismorphsegmentation.cpp \
-../../../../../sword/src/modules/filters/thmlwebif.cpp \
-../../../../../sword/src/modules/filters/thmlvariants.cpp \
-../../../../../sword/src/modules/filters/plainhtml.cpp \
-../../../../../sword/src/modules/filters/thmllemma.cpp \
-../../../../../sword/src/modules/filters/gbfmorph.cpp \
-../../../../../sword/src/modules/filters/teiplain.cpp \
-../../../../../sword/src/modules/filters/swbasicfilter.cpp \
-../../../../../sword/src/mgr/stringmgr.cpp \
-../../../../../sword/src/mgr/swmgr.cpp \
-../../../../../sword/src/mgr/swsearchable.cpp \
-../../../../../sword/src/mgr/localemgr.cpp \
-../../../../../sword/src/mgr/swconfig.cpp \
-../../../../../sword/src/mgr/markupfiltmgr.cpp \
-../../../../../sword/src/mgr/encfiltmgr.cpp \
-../../../../../sword/src/mgr/swfiltermgr.cpp \
-../../../../../sword/src/mgr/swcacher.cpp \
-../../../../../sword/src/mgr/installmgr.cpp \
-../../../../../sword/src/mgr/swlocale.cpp \
-../../../../../sword/src/mgr/filemgr.cpp \
-../../../../../sword/src/mgr/versemgr.cpp \
-../../../../../sword/src/mgr/ftptrans.cpp \
-../../../../../sword/src/utilfuns/swobject.cpp \
-../../../../../sword/src/utilfuns/roman.cpp \
-../../../../../sword/src/utilfuns/swbuf.cpp \
-../../../../../sword/src/utilfuns/utilstr.cpp \
-../../../../../sword/src/utilfuns/url.cpp \
-../../../../../sword/src/utilfuns/swversion.cpp \
-../../../../../sword/src/utilfuns/utilxml.cpp \
-../../../../../sword/src/utilfuns/swunicod.cpp \
-../../../../../sword/src/utilfuns/regex.c \
-../../../../../sword/src/keys/swkey.cpp \
-../../../../../sword/src/keys/versetreekey.cpp \
-../../../../../sword/src/keys/treekeyidx.cpp \
-../../../../../sword/src/keys/versekey.cpp \
-../../../../../sword/src/keys/strkey.cpp \
-../../../../../sword/src/keys/treekey.cpp \
-../../../../../sword/src/keys/listkey.cpp \
-../../../../../sword/src/frontend/swdisp.cpp \
-../../../../../sword/src/frontend/swlog.cpp
+LOCAL_SRC_FILES := ../../../src/modules/comments/zcom/zcom.cpp \
+../../../src/modules/comments/rawfiles/rawfiles.cpp \
+../../../src/modules/comments/rawcom4/rawcom4.cpp \
+../../../src/modules/comments/rawcom/rawcom.cpp \
+../../../src/modules/comments/swcom.cpp \
+../../../src/modules/comments/hrefcom/hrefcom.cpp \
+../../../src/modules/swmodule.cpp \
+../../../src/modules/tests/echomod.cpp \
+../../../src/modules/genbook/swgenbook.cpp \
+../../../src/modules/genbook/rawgenbook/rawgenbook.cpp \
+../../../src/modules/lexdict/swld.cpp \
+../../../src/modules/lexdict/rawld4/rawld4.cpp \
+../../../src/modules/lexdict/zld/zld.cpp \
+../../../src/modules/lexdict/rawld/rawld.cpp \
+../../../src/modules/texts/rawtext/rawtext.cpp \
+../../../src/modules/texts/rawtext4/rawtext4.cpp \
+../../../src/modules/texts/swtext.cpp \
+../../../src/modules/texts/ztext/ztext.cpp \
+../../../src/modules/common/rawstr4.cpp \
+../../../src/modules/common/lzsscomprs.cpp \
+../../../src/modules/common/zipcomprs.cpp \
+../../../src/modules/common/rawverse4.cpp \
+../../../src/modules/common/swcipher.cpp \
+../../../src/modules/common/swcomprs.cpp \
+../../../src/modules/common/rawverse.cpp \
+../../../src/modules/common/sapphire.cpp \
+../../../src/modules/common/zstr.cpp \
+../../../src/modules/common/entriesblk.cpp \
+../../../src/modules/common/zverse.cpp \
+../../../src/modules/common/rawstr.cpp \
+../../../src/modules/filters/gbfwordjs.cpp \
+../../../src/modules/filters/utf8latin1.cpp \
+../../../src/modules/filters/utf8greekaccents.cpp \
+../../../src/modules/filters/utf16utf8.cpp \
+../../../src/modules/filters/gbfwebif.cpp \
+../../../src/modules/filters/plainfootnotes.cpp \
+../../../src/modules/filters/utf8transliterator.cpp \
+../../../src/modules/filters/gbfstrongs.cpp \
+../../../src/modules/filters/osisplain.cpp \
+../../../src/modules/filters/thmlhtmlhref.cpp \
+../../../src/modules/filters/thmlgbf.cpp \
+../../../src/modules/filters/utf8utf16.cpp \
+../../../src/modules/filters/utf8cantillation.cpp \
+../../../src/modules/filters/utf8arshaping.cpp \
+../../../src/modules/filters/cipherfil.cpp \
+../../../src/modules/filters/thmlheadings.cpp \
+../../../src/modules/filters/thmlscripref.cpp \
+../../../src/modules/filters/latin1utf8.cpp \
+../../../src/modules/filters/gbfhtml.cpp \
+../../../src/modules/filters/thmlosis.cpp \
+../../../src/modules/filters/utf8nfkd.cpp \
+../../../src/modules/filters/thmlstrongs.cpp \
+../../../src/modules/filters/osisvariants.cpp \
+../../../src/modules/filters/thmlmorph.cpp \
+../../../src/modules/filters/gbfplain.cpp \
+../../../src/modules/filters/gbfhtmlhref.cpp \
+../../../src/modules/filters/utf8html.cpp \
+../../../src/modules/filters/utf8nfc.cpp \
+../../../src/modules/filters/rtfhtml.cpp \
+../../../src/modules/filters/gbfredletterwords.cpp \
+../../../src/modules/filters/latin1utf16.cpp \
+../../../src/modules/filters/osisscripref.cpp \
+../../../src/modules/filters/thmlhtml.cpp \
+../../../src/modules/filters/gbfthml.cpp \
+../../../src/modules/filters/teihtmlhref.cpp \
+../../../src/modules/filters/gbfrtf.cpp \
+../../../src/modules/filters/gbfosis.cpp \
+../../../src/modules/filters/teirtf.cpp \
+../../../src/modules/filters/thmlwordjs.cpp \
+../../../src/modules/filters/papyriplain.cpp \
+../../../src/modules/filters/osisfootnotes.cpp \
+../../../src/modules/filters/osiswordjs.cpp \
+../../../src/modules/filters/osismorph.cpp \
+../../../src/modules/filters/osislemma.cpp \
+../../../src/modules/filters/osisredletterwords.cpp \
+../../../src/modules/filters/osisrtf.cpp \
+../../../src/modules/filters/gbfheadings.cpp \
+../../../src/modules/filters/osisruby.cpp \
+../../../src/modules/filters/osishtmlhref.cpp \
+../../../src/modules/filters/utf8bidireorder.cpp \
+../../../src/modules/filters/thmlrtf.cpp \
+../../../src/modules/filters/swoptfilter.cpp \
+../../../src/modules/filters/utf8arabicpoints.cpp \
+../../../src/modules/filters/osisstrongs.cpp \
+../../../src/modules/filters/osisheadings.cpp \
+../../../src/modules/filters/unicodertf.cpp \
+../../../src/modules/filters/gbffootnotes.cpp \
+../../../src/modules/filters/greeklexattribs.cpp \
+../../../src/modules/filters/osiswebif.cpp \
+../../../src/modules/filters/thmlfootnotes.cpp \
+../../../src/modules/filters/thmlplain.cpp \
+../../../src/modules/filters/osisosis.cpp \
+../../../src/modules/filters/utf8hebrewpoints.cpp \
+../../../src/modules/filters/osismorphsegmentation.cpp \
+../../../src/modules/filters/thmlwebif.cpp \
+../../../src/modules/filters/thmlvariants.cpp \
+../../../src/modules/filters/plainhtml.cpp \
+../../../src/modules/filters/thmllemma.cpp \
+../../../src/modules/filters/gbfmorph.cpp \
+../../../src/modules/filters/teiplain.cpp \
+../../../src/modules/filters/swbasicfilter.cpp \
+../../../src/mgr/stringmgr.cpp \
+../../../src/mgr/swmgr.cpp \
+../../../src/mgr/swsearchable.cpp \
+../../../src/mgr/localemgr.cpp \
+../../../src/mgr/swconfig.cpp \
+../../../src/mgr/markupfiltmgr.cpp \
+../../../src/mgr/encfiltmgr.cpp \
+../../../src/mgr/swfiltermgr.cpp \
+../../../src/mgr/swcacher.cpp \
+../../../src/mgr/installmgr.cpp \
+../../../src/mgr/swlocale.cpp \
+../../../src/mgr/filemgr.cpp \
+../../../src/mgr/versemgr.cpp \
+../../../src/mgr/ftptrans.cpp \
+../../../src/utilfuns/swobject.cpp \
+../../../src/utilfuns/roman.cpp \
+../../../src/utilfuns/swbuf.cpp \
+../../../src/utilfuns/utilstr.cpp \
+../../../src/utilfuns/url.cpp \
+../../../src/utilfuns/swversion.cpp \
+../../../src/utilfuns/utilxml.cpp \
+../../../src/utilfuns/swunicod.cpp \
+../../../src/utilfuns/regex.c \
+../../../src/keys/swkey.cpp \
+../../../src/keys/versetreekey.cpp \
+../../../src/keys/treekeyidx.cpp \
+../../../src/keys/versekey.cpp \
+../../../src/keys/strkey.cpp \
+../../../src/keys/treekey.cpp \
+../../../src/keys/listkey.cpp \
+../../../src/frontend/swdisp.cpp \
+../../../src/frontend/swlog.cpp
#../../../../../sword/src/mgr/ftplibftpt.cpp \
#../../../../../sword/src/mgr/curlftpt.cpp \
Modified: trunk/bindings/java-jni/jni/org_crosswire_android_sword_SWModule.h
===================================================================
--- trunk/bindings/java-jni/jni/org_crosswire_android_sword_SWModule.h 2009-10-13 17:33:47 UTC (rev 2461)
+++ trunk/bindings/java-jni/jni/org_crosswire_android_sword_SWModule.h 2009-10-14 05:38:40 UTC (rev 2462)
@@ -7,6 +7,16 @@
#ifdef __cplusplus
extern "C" {
#endif
+#undef org_crosswire_android_sword_SWModule_SEARCHTYPE_REGEX
+#define org_crosswire_android_sword_SWModule_SEARCHTYPE_REGEX 1L
+#undef org_crosswire_android_sword_SWModule_SEARCHTYPE_PHRASE
+#define org_crosswire_android_sword_SWModule_SEARCHTYPE_PHRASE -1L
+#undef org_crosswire_android_sword_SWModule_SEARCHTYPE_MULTIWORD
+#define org_crosswire_android_sword_SWModule_SEARCHTYPE_MULTIWORD -2L
+#undef org_crosswire_android_sword_SWModule_SEARCHTYPE_ENTRYATTR
+#define org_crosswire_android_sword_SWModule_SEARCHTYPE_ENTRYATTR -3L
+#undef org_crosswire_android_sword_SWModule_SEARCHTYPE_LUCENE
+#define org_crosswire_android_sword_SWModule_SEARCHTYPE_LUCENE -4L
/*
* Class: org_crosswire_android_sword_SWModule
* Method: terminateSearch
@@ -18,10 +28,10 @@
/*
* Class: org_crosswire_android_sword_SWModule
* Method: search
- * Signature: (Ljava/lang/String;IJLjava/lang/String;)[Lorg/crosswire/android/sword/SWModule/SearchHit;
+ * Signature: (Ljava/lang/String;IJLjava/lang/String;Lorg/crosswire/android/sword/SWModule/SearchProgressReporter;)[Lorg/crosswire/android/sword/SWModule/SearchHit;
*/
JNIEXPORT jobjectArray JNICALL Java_org_crosswire_android_sword_SWModule_search
- (JNIEnv *, jobject, jstring, jint, jlong, jstring);
+ (JNIEnv *, jobject, jstring, jint, jlong, jstring, jobject);
/*
* Class: org_crosswire_android_sword_SWModule
Modified: trunk/bindings/java-jni/jni/swordstub.cpp
===================================================================
--- trunk/bindings/java-jni/jni/swordstub.cpp 2009-10-13 17:33:47 UTC (rev 2461)
+++ trunk/bindings/java-jni/jni/swordstub.cpp 2009-10-14 05:38:40 UTC (rev 2462)
@@ -17,6 +17,8 @@
//#include "first.h"
#include <iostream>
+#include <vector>
+
#include <jni.h>
#include <utilstr.h>
@@ -24,6 +26,8 @@
#include <swmgr.h>
#include <swmodule.h>
#include <versekey.h>
+#include <localemgr.h>
+#include <treekeyidx.h>
#include "webmgr.hpp"
#include "org_crosswire_android_sword_SWMgr.h"
@@ -46,6 +50,7 @@
return env->NewStringUTF(v.currentVersion);
}
+
JNIEXPORT jstring JNICALL Java_org_crosswire_android_sword_SWMgr_getPrefixPath
(JNIEnv *env, jobject me) {
init();
@@ -121,96 +126,213 @@
return retVal;
}
-#if 0
+
/*
* Class: org_crosswire_android_sword_SWMgr
* Method: setGlobalOption
* Signature: (Ljava/lang/String;Ljava/lang/String;)V
*/
JNIEXPORT void JNICALL Java_org_crosswire_android_sword_SWMgr_setGlobalOption
- (JNIEnv *, jobject, jstring, jstring);
+ (JNIEnv *env, jobject me, jstring optionJS, jstring valueJS) {
+ const char *option = env->GetStringUTFChars(optionJS, NULL);
+ const char *value = env->GetStringUTFChars(valueJS, NULL);
+ mgr->setGlobalOption(option, value);
+
+ env->ReleaseStringUTFChars(valueJS, value);
+ env->ReleaseStringUTFChars(optionJS, option);
+}
+
+
/*
* Class: org_crosswire_android_sword_SWMgr
* Method: getGlobalOption
* Signature: (Ljava/lang/String;)Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_org_crosswire_android_sword_SWMgr_getGlobalOption
- (JNIEnv *, jobject, jstring);
+ (JNIEnv *env, jobject me, jstring optionJS) {
+ const char *option = env->GetStringUTFChars(optionJS, NULL);
+ SWBuf value = mgr->getGlobalOption(option);
+
+ env->ReleaseStringUTFChars(optionJS, option);
+
+ return env->NewStringUTF(value);
+}
+
+
/*
* Class: org_crosswire_android_sword_SWMgr
* Method: getGlobalOptionTip
* Signature: (Ljava/lang/String;)Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_org_crosswire_android_sword_SWMgr_getGlobalOptionTip
- (JNIEnv *, jobject, jstring);
+ (JNIEnv *env, jobject me, jstring optionJS) {
+ const char *option = env->GetStringUTFChars(optionJS, NULL);
+ SWBuf value = mgr->getGlobalOptionTip(option);
+
+ env->ReleaseStringUTFChars(optionJS, option);
+
+ return env->NewStringUTF(value);
+}
+
+
/*
* Class: org_crosswire_android_sword_SWMgr
* Method: filterText
* Signature: (Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_org_crosswire_android_sword_SWMgr_filterText
- (JNIEnv *, jobject, jstring, jstring);
+ (JNIEnv *env, jobject me, jstring filterNameJS, jstring textJS) {
+ const char *filterName = env->GetStringUTFChars(filterNameJS, NULL);
+ const char *text = env->GetStringUTFChars(textJS, NULL);
+ SWBuf buf = text;
+ // hmmm, in the future, provide a param to specify filter value maybe?
+ mgr->setGlobalOption("Greek Accents", "Off");
+ char errStatus = mgr->filterText(filterName, buf);
+
+ env->ReleaseStringUTFChars(textJS, text);
+ env->ReleaseStringUTFChars(filterNameJS, filterName);
+
+ return env->NewStringUTF(buf);
+}
+
+
/*
* Class: org_crosswire_android_sword_SWMgr
* Method: getGlobalOptions
* Signature: ()[Ljava/lang/String;
*/
JNIEXPORT jobjectArray JNICALL Java_org_crosswire_android_sword_SWMgr_getGlobalOptions
- (JNIEnv *, jobject);
+ (JNIEnv *env, jobject me) {
+ sword::StringList options = mgr->getGlobalOptions();
+ int count = 0;
+ for (sword::StringList::iterator it = options.begin(); it != options.end(); it++) {
+ count++;
+ }
+ jclass clazzString = env->FindClass("java/lang/String");
+ jobjectArray ret = (jobjectArray) env->NewObjectArray(count, clazzString, NULL);
+
+ count = 0;
+ for (sword::StringList::iterator it = options.begin(); it != options.end(); it++) {
+ env->SetObjectArrayElement(ret, count++, env->NewStringUTF(*it));
+ }
+
+ return ret;
+}
+
+
/*
* Class: org_crosswire_android_sword_SWMgr
* Method: getGlobalOptionValues
* Signature: (Ljava/lang/String;)[Ljava/lang/String;
*/
JNIEXPORT jobjectArray JNICALL Java_org_crosswire_android_sword_SWMgr_getGlobalOptionValues
- (JNIEnv *, jobject, jstring);
+ (JNIEnv *env, jobject me, jstring optionJS) {
+ const char *option = env->GetStringUTFChars(optionJS, NULL);
+ sword::StringList options = mgr->getGlobalOptionValues(option);
+
+ env->ReleaseStringUTFChars(optionJS, option);
+
+ int count = 0;
+ for (sword::StringList::iterator it = options.begin(); it != options.end(); it++) {
+ count++;
+ }
+ jclass clazzString = env->FindClass("java/lang/String");
+ jobjectArray ret = (jobjectArray) env->NewObjectArray(count, clazzString, NULL);
+
+ count = 0;
+ for (sword::StringList::iterator it = options.begin(); it != options.end(); it++) {
+ env->SetObjectArrayElement(ret, count++, env->NewStringUTF(*it));
+ }
+
+ return ret;
+}
+
+
/*
* Class: org_crosswire_android_sword_SWMgr
* Method: setCipherKey
* Signature: (Ljava/lang/String;Ljava/lang/String;)V
*/
JNIEXPORT void JNICALL Java_org_crosswire_android_sword_SWMgr_setCipherKey
- (JNIEnv *, jobject, jstring, jstring);
+ (JNIEnv *env, jobject me , jstring modNameJS, jstring keyJS) {
+ const char *modName = env->GetStringUTFChars(modNameJS, NULL);
+ const char *key = env->GetStringUTFChars(keyJS, NULL);
+ mgr->setCipherKey(modName, key);
+
+ env->ReleaseStringUTFChars(keyJS, key);
+ env->ReleaseStringUTFChars(modNameJS, modName);
+}
+
+
/*
* Class: org_crosswire_android_sword_SWMgr
* Method: setJavascript
* Signature: (Z)V
*/
JNIEXPORT void JNICALL Java_org_crosswire_android_sword_SWMgr_setJavascript
- (JNIEnv *, jobject, jboolean);
+ (JNIEnv *env, jobject me, jboolean val) {
+ mgr->setJavascript(val == JNI_TRUE);
+}
+
/*
* Class: org_crosswire_android_sword_SWMgr
* Method: getAvailableLocales
* Signature: ()[Ljava/lang/String;
*/
JNIEXPORT jobjectArray JNICALL Java_org_crosswire_android_sword_SWMgr_getAvailableLocales
- (JNIEnv *, jobject);
+ (JNIEnv *env, jobject me) {
+ sword::StringList localeNames = LocaleMgr::getSystemLocaleMgr()->getAvailableLocales();
+ int count = 0;
+ for (sword::StringList::iterator it = localeNames.begin(); it != localeNames.end(); it++) {
+ count++;
+ }
+ jclass clazzString = env->FindClass("java/lang/String");
+ jobjectArray ret = (jobjectArray) env->NewObjectArray(count, clazzString, NULL);
+
+ count = 0;
+ for (sword::StringList::iterator it = localeNames.begin(); it != localeNames.end(); it++) {
+ env->SetObjectArrayElement(ret, count++, env->NewStringUTF(*it));
+ }
+ return ret;
+}
+
+
/*
* Class: org_crosswire_android_sword_SWMgr
* Method: setDefaultLocale
* Signature: (Ljava/lang/String;)V
*/
JNIEXPORT void JNICALL Java_org_crosswire_android_sword_SWMgr_setDefaultLocale
- (JNIEnv *, jobject, jstring);
+ (JNIEnv *env, jobject me, jstring localeNameJS) {
+ const char *localeName = env->GetStringUTFChars(localeNameJS, NULL);
-#endif
+ LocaleMgr::getSystemLocaleMgr()->setDefaultLocaleName(localeName);
+ env->ReleaseStringUTFChars(localeNameJS, localeName);
+}
-
-
// SWModule methods ----------------------------------------------------------------------------------
+SWModule *getModule(JNIEnv *env, jobject me) {
+ jclass clazzSWModule = env->FindClass("org/crosswire/android/sword/SWModule");
+ jfieldID fieldID = env->GetFieldID(clazzSWModule, "name", "Ljava/lang/String;");
+ jstring modNameJS = (jstring)env->GetObjectField(me, fieldID);
+ const char *modName = env->GetStringUTFChars(modNameJS, NULL);
+ sword::SWModule *module = mgr->getModule(modName);
+ env->ReleaseStringUTFChars(modNameJS, modName);
+ return module;
+}
/*
* Class: org_crosswire_android_sword_SWModule
@@ -220,12 +342,7 @@
JNIEXPORT void JNICALL Java_org_crosswire_android_sword_SWModule_setKeyText
(JNIEnv *env, jobject me, jstring keyTextJS) {
- jclass clazzSWModule = env->FindClass("org/crosswire/android/sword/SWModule");
- jfieldID fieldID = env->GetFieldID(clazzSWModule, "name", "Ljava/lang/String;");
- jstring modNameJS = (jstring)env->GetObjectField(me, fieldID);
- const char *modName = env->GetStringUTFChars(modNameJS, NULL);
- sword::SWModule *module = mgr->getModule(modName);
- env->ReleaseStringUTFChars(modNameJS, modName);
+ SWModule *module = getModule(env, me);
if (module) {
const char *keyText = env->GetStringUTFChars(keyTextJS, NULL);
@@ -257,13 +374,9 @@
*/
JNIEXPORT jstring JNICALL Java_org_crosswire_android_sword_SWModule_getKeyText
(JNIEnv *env, jobject me) {
- jclass clazzSWModule = env->FindClass("org/crosswire/android/sword/SWModule");
- jfieldID fieldID = env->GetFieldID(clazzSWModule, "name", "Ljava/lang/String;");
- jstring modNameJS = (jstring)env->GetObjectField(me, fieldID);
- const char *modName = env->GetStringUTFChars(modNameJS, NULL);
- sword::SWModule *module = mgr->getModule(modName);
- env->ReleaseStringUTFChars(modNameJS, modName);
+ SWModule *module = getModule(env, me);
+
jstring retVal = 0;
if (module) {
retVal = env->NewStringUTF(module->getKeyText());
@@ -280,12 +393,7 @@
JNIEXPORT jstring JNICALL Java_org_crosswire_android_sword_SWModule_getRenderText
(JNIEnv *env, jobject me) {
- jclass clazzSWModule = env->FindClass("org/crosswire/android/sword/SWModule");
- jfieldID fieldID = env->GetFieldID(clazzSWModule, "name", "Ljava/lang/String;");
- jstring modNameJS = (jstring)env->GetObjectField(me, fieldID);
- const char *modName = env->GetStringUTFChars(modNameJS, NULL);
- sword::SWModule *module = mgr->getModule(modName);
- env->ReleaseStringUTFChars(modNameJS, modName);
+ SWModule *module = getModule(env, me);
jstring retVal = 0;
if (module) {
@@ -295,152 +403,546 @@
}
-
-
-#if 0
-
/*
* Class: org_crosswire_android_sword_SWModule
* Method: terminateSearch
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_org_crosswire_android_sword_SWModule_terminateSearch
- (JNIEnv *, jobject);
+ (JNIEnv *env, jobject me) {
-/*
- * Class: org_crosswire_android_sword_SWModule
- * Method: search
- * Signature: (Ljava/lang/String;IJLjava/lang/String;)[Lorg/crosswire/android/sword/SWModule/SearchHit;
- */
-JNIEXPORT jobjectArray JNICALL Java_org_crosswire_android_sword_SWModule_search
- (JNIEnv *, jobject, jstring, jint, jlong, jstring);
+ SWModule *module = getModule(env, me);
+ if (module) {
+ module->terminateSearch = true;
+ }
+}
+
+
/*
* Class: org_crosswire_android_sword_SWModule
* Method: error
* Signature: ()C
*/
JNIEXPORT jchar JNICALL Java_org_crosswire_android_sword_SWModule_error
- (JNIEnv *, jobject);
+ (JNIEnv *env, jobject me) {
+ SWModule *module = getModule(env, me);
+
+ return (module) ? module->Error() : -99;
+}
+
+
/*
* Class: org_crosswire_android_sword_SWModule
* Method: getEntrySize
* Signature: ()J
*/
JNIEXPORT jlong JNICALL Java_org_crosswire_android_sword_SWModule_getEntrySize
- (JNIEnv *, jobject);
+ (JNIEnv *env, jobject me) {
+ SWModule *module = getModule(env, me);
+
+ return (module) ? module->getEntrySize() : 0;
+}
+
+
/*
* Class: org_crosswire_android_sword_SWModule
* Method: getEntryAttribute
* Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Z)[Ljava/lang/String;
*/
JNIEXPORT jobjectArray JNICALL Java_org_crosswire_android_sword_SWModule_getEntryAttribute
- (JNIEnv *, jobject, jstring, jstring, jstring, jboolean);
+ (JNIEnv *env, jobject me, jstring level1JS, jstring level2JS, jstring level3JS, jboolean filteredJS) {
+ const char *level1 = env->GetStringUTFChars(level1JS, NULL);
+ const char *level2 = env->GetStringUTFChars(level2JS, NULL);
+ const char *level3 = env->GetStringUTFChars(level3JS, NULL);
+ bool filtered = (filteredJS == JNI_TRUE);
+ jclass clazzString = env->FindClass("java/lang/String");
+ jobjectArray ret = (jobjectArray) env->NewObjectArray(0, clazzString, NULL);
+
+ SWModule *module = getModule(env, me);
+
+ if (module) {
+
+ module->RenderText(); // force parse
+ std::vector<SWBuf> results;
+
+ sword::AttributeTypeList &entryAttribs = module->getEntryAttributes();
+ sword::AttributeTypeList::iterator i1Start, i1End;
+ sword::AttributeList::iterator i2Start, i2End;
+ sword::AttributeValue::iterator i3Start, i3End;
+
+ if ((level1) && (*level1)) {
+ i1Start = entryAttribs.find(level1);
+ i1End = i1Start;
+ if (i1End != entryAttribs.end())
+ i1End++;
+ }
+ else {
+ i1Start = entryAttribs.begin();
+ i1End = entryAttribs.end();
+ }
+ for (;i1Start != i1End; i1Start++) {
+ if ((level2) && (*level2)) {
+ i2Start = i1Start->second.find(level2);
+ i2End = i2Start;
+ if (i2End != i1Start->second.end())
+ i2End++;
+ }
+ else {
+ i2Start = i1Start->second.begin();
+ i2End = i1Start->second.end();
+ }
+ for (;i2Start != i2End; i2Start++) {
+ if ((level3) && (*level3)) {
+ i3Start = i2Start->second.find(level3);
+ i3End = i3Start;
+ if (i3End != i2Start->second.end())
+ i3End++;
+ }
+ else {
+ i3Start = i2Start->second.begin();
+ i3End = i2Start->second.end();
+ }
+ for (;i3Start != i3End; i3Start++) {
+ results.push_back(i3Start->second);
+ }
+ if (i3Start != i3End)
+ break;
+ }
+ if (i2Start != i2End)
+ break;
+ }
+
+ ret = (jobjectArray) env->NewObjectArray(results.size(), clazzString, NULL);
+
+ for (int i = 0; i < results.size(); i++) {
+ if (filtered) {
+ env->SetObjectArrayElement(ret, i, env->NewStringUTF(module->RenderText(results[i].c_str())));
+ }
+ else {
+ env->SetObjectArrayElement(ret, i, env->NewStringUTF(results[i].c_str()));
+ }
+ }
+ }
+
+ env->ReleaseStringUTFChars(level3JS, level3);
+ env->ReleaseStringUTFChars(level2JS, level2);
+ env->ReleaseStringUTFChars(level1JS, level1);
+
+ return ret;
+}
+
+
/*
* Class: org_crosswire_android_sword_SWModule
* Method: parseKeyList
* Signature: (Ljava/lang/String;)[Ljava/lang/String;
*/
JNIEXPORT jobjectArray JNICALL Java_org_crosswire_android_sword_SWModule_parseKeyList
- (JNIEnv *, jobject, jstring);
+ (JNIEnv *env, jobject me, jstring keyListTextJS) {
+ const char *keyListText = env->GetStringUTFChars(keyListTextJS, NULL);
+
+ SWModule *module = getModule(env, me);
+ jclass clazzString = env->FindClass("java/lang/String");
+ jobjectArray ret;
+
+ if (module) {
+ sword::SWKey *k = module->getKey();
+ sword::VerseKey *parser = SWDYNAMIC_CAST(VerseKey, k);
+ if (parser) {
+ sword::ListKey result;
+ result = parser->ParseVerseList(keyListText, *parser, true);
+ int count = 0;
+ for (result = sword::TOP; !result.Error(); result++) {
+ count++;
+ }
+ ret = (jobjectArray) env->NewObjectArray(count, clazzString, NULL);
+
+ count = 0;
+ for (result = sword::TOP; !result.Error(); result++) {
+ env->SetObjectArrayElement(ret, count++, env->NewStringUTF((const char *)result));
+ }
+ }
+ else {
+ ret = (jobjectArray) env->NewObjectArray(1, clazzString, NULL);
+ env->SetObjectArrayElement(ret, 0, env->NewStringUTF(keyListText));
+ }
+ }
+
+ env->ReleaseStringUTFChars(keyListTextJS, keyListText);
+
+ return ret;
+}
+
+
/*
* Class: org_crosswire_android_sword_SWModule
* Method: hasKeyChildren
* Signature: ()Z
*/
JNIEXPORT jboolean JNICALL Java_org_crosswire_android_sword_SWModule_hasKeyChildren
- (JNIEnv *, jobject);
+ (JNIEnv *env, jobject me) {
+ SWModule *module = getModule(env, me);
+ jboolean retVal = JNI_FALSE;
+
+ if (module) {
+ sword::SWKey *key = module->getKey();
+
+ TreeKeyIdx *tkey = SWDYNAMIC_CAST(TreeKeyIdx, key);
+ if (tkey) {
+ retVal = (tkey->hasChildren())?JNI_TRUE:JNI_FALSE;
+ }
+ }
+ return retVal;
+}
+
/*
* Class: org_crosswire_android_sword_SWModule
* Method: getKeyChildren
* Signature: ()[Ljava/lang/String;
*/
JNIEXPORT jobjectArray JNICALL Java_org_crosswire_android_sword_SWModule_getKeyChildren
- (JNIEnv *, jobject);
+ (JNIEnv *env, jobject me) {
+ jclass clazzString = env->FindClass("java/lang/String");
+ jobjectArray ret;
+
+ SWModule *module = getModule(env, me);
+
+ if (module) {
+ sword::SWKey *key = module->getKey();
+ int count = 0;
+
+ sword::VerseKey *vkey = SWDYNAMIC_CAST(VerseKey, key);
+ if (vkey) {
+ ret = (jobjectArray) env->NewObjectArray(7, clazzString, NULL);
+ SWBuf num;
+ num.appendFormatted("%d", vkey->getTestament());
+ env->SetObjectArrayElement(ret, 0, env->NewStringUTF(num.c_str()));
+ num = "";
+ num.appendFormatted("%d", vkey->getBook());
+ env->SetObjectArrayElement(ret, 1, env->NewStringUTF(num.c_str()));
+ num = "";
+ num.appendFormatted("%d", vkey->getChapter());
+ env->SetObjectArrayElement(ret, 2, env->NewStringUTF(num.c_str()));
+ num = "";
+ num.appendFormatted("%d", vkey->getVerse());
+ env->SetObjectArrayElement(ret, 3, env->NewStringUTF(num.c_str()));
+ num = "";
+ num.appendFormatted("%d", vkey->getChapterMax());
+ env->SetObjectArrayElement(ret, 4, env->NewStringUTF(num.c_str()));
+ num = "";
+ num.appendFormatted("%d", vkey->getVerseMax());
+ env->SetObjectArrayElement(ret, 5, env->NewStringUTF(num.c_str()));
+ num = "";
+ num.appendFormatted("%d", vkey->getBookName());
+ env->SetObjectArrayElement(ret, 6, env->NewStringUTF(num.c_str()));
+ }
+ else {
+ TreeKeyIdx *tkey = SWDYNAMIC_CAST(TreeKeyIdx, key);
+ if (tkey) {
+ if (tkey->firstChild()) {
+ do {
+ count++;
+ }
+ while (tkey->nextSibling());
+ tkey->parent();
+ }
+ ret = (jobjectArray) env->NewObjectArray(count, clazzString, NULL);
+ count = 0;
+ if (tkey->firstChild()) {
+ do {
+ env->SetObjectArrayElement(ret, count++, env->NewStringUTF(tkey->getLocalName()));
+ }
+ while (tkey->nextSibling());
+ tkey->parent();
+ }
+ }
+ }
+ return ret;
+ }
+}
+
+
/*
* Class: org_crosswire_android_sword_SWModule
* Method: getKeyParent
* Signature: ()Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_org_crosswire_android_sword_SWModule_getKeyParent
- (JNIEnv *, jobject);
+ (JNIEnv *env, jobject me) {
+ SWBuf retVal = "";
+
+ SWModule *module = getModule(env, me);
+
+ if (module) {
+
+ sword::SWKey *key = module->getKey();
+
+ TreeKeyIdx *tkey = SWDYNAMIC_CAST(TreeKeyIdx, key);
+ if (tkey) {
+ if (tkey->parent()) {
+ retVal = tkey->getText();
+ }
+ }
+ }
+ return env->NewStringUTF(retVal);
+}
+
+
/*
* Class: org_crosswire_android_sword_SWModule
* Method: previous
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_org_crosswire_android_sword_SWModule_previous
- (JNIEnv *, jobject);
+ (JNIEnv *env, jobject me) {
+ SWModule *module = getModule(env, me);
+
+ if (module) {
+ module->decrement();
+ }
+}
+
+
/*
* Class: org_crosswire_android_sword_SWModule
* Method: next
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_org_crosswire_android_sword_SWModule_next
- (JNIEnv *, jobject);
+ (JNIEnv *env, jobject me) {
+ SWModule *module = getModule(env, me);
+
+ if (module) {
+ module->increment();
+ }
+}
+
+
/*
* Class: org_crosswire_android_sword_SWModule
* Method: begin
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_org_crosswire_android_sword_SWModule_begin
- (JNIEnv *, jobject);
+ (JNIEnv *env, jobject me) {
+ SWModule *module = getModule(env, me);
+
+ if (module) {
+ module->setPosition(sword::TOP);
+ }
+}
+
+
/*
* Class: org_crosswire_android_sword_SWModule
* Method: getStripText
* Signature: ()Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_org_crosswire_android_sword_SWModule_getStripText
- (JNIEnv *, jobject);
+ (JNIEnv *env, jobject me) {
+ SWBuf retVal = "";
+
+ SWModule *module = getModule(env, me);
+
+ if (module) {
+ retVal = module->StripText();
+ }
+
+ return env->NewStringUTF(retVal);
+}
+
+
/*
* Class: org_crosswire_android_sword_SWModule
* Method: getRawEntry
* Signature: ()Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_org_crosswire_android_sword_SWModule_getRawEntry
- (JNIEnv *, jobject);
+ (JNIEnv *env, jobject me) {
+ SWBuf retVal = "";
+
+ SWModule *module = getModule(env, me);
+
+ if (module) {
+ retVal = module->getRawEntry();
+ }
+
+ return env->NewStringUTF(retVal);
+}
+
+
/*
* Class: org_crosswire_android_sword_SWModule
* Method: setRawEntry
* Signature: (Ljava/lang/String;)V
*/
JNIEXPORT void JNICALL Java_org_crosswire_android_sword_SWModule_setRawEntry
- (JNIEnv *, jobject, jstring);
+ (JNIEnv *env, jobject me, jstring newEntryTextJS) {
+ const char *newEntryText = env->GetStringUTFChars(newEntryTextJS, NULL);
+
+ SWModule *module = getModule(env, me);
+
+ if (module) {
+ module->setEntry(newEntryText);
+ }
+
+ env->ReleaseStringUTFChars(newEntryTextJS, newEntryText);
+}
+
+
/*
* Class: org_crosswire_android_sword_SWModule
* Method: getConfigEntry
* Signature: (Ljava/lang/String;)Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_org_crosswire_android_sword_SWModule_getConfigEntry
- (JNIEnv *, jobject, jstring);
+ (JNIEnv *env, jobject me, jstring configKeyJS) {
+ jstring retVal = 0;
+
+ const char *configKey = env->GetStringUTFChars(configKeyJS, NULL);
+
+ SWModule *module = getModule(env, me);
+
+ if (module && module->getConfigEntry(configKey)) {
+ retVal = env->NewStringUTF(module->getConfigEntry(configKey));
+ }
+
+ env->ReleaseStringUTFChars(configKeyJS, configKey);
+
+ return retVal;
+}
+
+
/*
* Class: org_crosswire_android_sword_SWModule
* Method: deleteSearchFramework
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_org_crosswire_android_sword_SWModule_deleteSearchFramework
- (JNIEnv *, jobject);
+ (JNIEnv *env, jobject me) {
+ SWModule *module = getModule(env, me);
+
+ if (module) {
+ module->deleteSearchFramework();
+ }
+}
+
+
/*
* Class: org_crosswire_android_sword_SWModule
* Method: hasSearchFramework
* Signature: ()Z
*/
JNIEXPORT jboolean JNICALL Java_org_crosswire_android_sword_SWModule_hasSearchFramework
- (JNIEnv *, jobject);
+ (JNIEnv *env, jobject me) {
-#endif
+ SWModule *module = getModule(env, me);
+
+ return (module && module->hasSearchFramework()) ? JNI_TRUE : JNI_FALSE;
+}
+
+
+struct pu {
+ pu(JNIEnv *env, jobject pr) : env(env), progressReporter(pr), last(0) {}
+ JNIEnv *env;
+ jobject progressReporter;
+ char last;
+};
+
+
+void percentUpdate(char percent, void *userData) {
+ struct pu *p = (struct pu *)userData;
+
+ if (percent != p->last) {
+ p->last = percent;
+ jclass cls = p->env->GetObjectClass(p->progressReporter);
+ jmethodID mid = p->env->GetMethodID(cls, "progressReport", "(I)V");
+ if (mid != 0) {
+ p->env->CallVoidMethod(p->progressReporter, mid, (jint)percent);
+ }
+ }
+}
+
+
+/*
+ * Class: org_crosswire_android_sword_SWModule
+ * Method: search
+ * Signature: (Ljava/lang/String;IJLjava/lang/String;Lorg/crosswire/android/sword/SWModule/SearchProgressReporter;)[Lorg/crosswire/android/sword/SWModule/SearchHit;
+ */
+JNIEXPORT jobjectArray JNICALL Java_org_crosswire_android_sword_SWModule_search
+ (JNIEnv *env, jobject me, jstring expressionJS, jint srchType, jlong flags, jstring scopeJS, jobject progressReporter) {
+
+ const char *expression = env->GetStringUTFChars(expressionJS, NULL);
+ const char *scope = env->GetStringUTFChars(scopeJS, NULL);
+
+ jclass clazzSearchHit = env->FindClass("org/crosswire/android/sword/SWModule$SearchHit");
+ jobjectArray ret = (jobjectArray) env->NewObjectArray(0, clazzSearchHit, NULL);
+
+ SWModule *module = getModule(env, me);
+
+ struct pu peeuuu(env, progressReporter);
+
+ if (module) {
+ sword::ListKey lscope;
+ sword::ListKey result;
+
+ if ((scope) && (strlen(scope)) > 0) {
+ sword::SWKey *p = module->CreateKey();
+ sword::VerseKey *parser = SWDYNAMIC_CAST(VerseKey, p);
+ if (!parser) {
+ delete p;
+ parser = new VerseKey();
+ }
+ *parser = module->getKeyText();
+ lscope = parser->ParseVerseList(scope, *parser, true);
+ result = module->search(expression, srchType, flags, &lscope, 0, &percentUpdate, &peeuuu);
+ delete parser;
+ }
+ else result = module->search(expression, srchType, flags, 0, 0, &percentUpdate, &peeuuu);
+
+ int count = 0;
+ for (result = sword::TOP; !result.Error(); result++) count++;
+
+ ret = (jobjectArray) env->NewObjectArray(count, clazzSearchHit, NULL);
+
+ // if we're sorted by score, let's re-sort by verse, because Java can always re-sort by score
+ result = sword::TOP;
+ if ((count) && (long)result.getElement()->userData)
+ result.sort();
+
+ int i = 0;
+ for (result = sword::TOP; !result.Error(); result++) {
+ jfieldID fieldID;
+ jobject searchHit = env->AllocObject(clazzSearchHit);
+
+ fieldID = env->GetFieldID(clazzSearchHit, "modName", "Ljava/lang/String;"); env->SetObjectField(searchHit, fieldID, env->NewStringUTF(module->Name()));
+ fieldID = env->GetFieldID(clazzSearchHit, "key", "Ljava/lang/String;"); env->SetObjectField(searchHit, fieldID, env->NewStringUTF((const char *)result));
+ fieldID = env->GetFieldID(clazzSearchHit, "score", "J"); env->SetLongField(searchHit, fieldID, (long)result.getElement()->userData);
+
+ env->SetObjectArrayElement(ret, i++, searchHit);
+ }
+ }
+
+ env->ReleaseStringUTFChars(scopeJS, scope);
+ env->ReleaseStringUTFChars(expressionJS, expression);
+
+ return ret;
+}
+
+
Modified: trunk/bindings/java-jni/src/org/crosswire/android/sword/SWMgr.java
===================================================================
--- trunk/bindings/java-jni/src/org/crosswire/android/sword/SWMgr.java 2009-10-13 17:33:47 UTC (rev 2461)
+++ trunk/bindings/java-jni/src/org/crosswire/android/sword/SWMgr.java 2009-10-14 05:38:40 UTC (rev 2462)
@@ -1,6 +1,10 @@
package org.crosswire.android.sword;
public class SWMgr {
+
+ static {
+ System.loadLibrary("sword");
+ }
public static class ModInfo {
public String name;
Modified: trunk/bindings/java-jni/src/org/crosswire/android/sword/SWModule.java
===================================================================
--- trunk/bindings/java-jni/src/org/crosswire/android/sword/SWModule.java 2009-10-13 17:33:47 UTC (rev 2461)
+++ trunk/bindings/java-jni/src/org/crosswire/android/sword/SWModule.java 2009-10-14 05:38:40 UTC (rev 2462)
@@ -1,27 +1,33 @@
package org.crosswire.android.sword;
public class SWModule {
-
- public final int SEARCHTYPE_REGEX = 1;
- public final int SEARCHTYPE_PHRASE = -1;
- public final int SEARCHTYPE_MULTIWORD = -2;
- public final int SEARCHTYPE_ENTRYATTR = -3;
- public final int SEARCHTYPE_LUCENE = -4;
-
+
private String name;
private String description;
private String category;
+
+ public static final int SEARCHTYPE_REGEX = 1;
+ public static final int SEARCHTYPE_PHRASE = -1;
+ public static final int SEARCHTYPE_MULTIWORD = -2;
+ public static final int SEARCHTYPE_ENTRYATTR = -3;
+ public static final int SEARCHTYPE_LUCENE = -4;
+
private SWModule() {} // don't allow allocation, instead use factory method SWMgr.getModuleByName to retrieve an instance
public static class SearchHit {
- String modName;
- String key;
- long score;
+ public String modName;
+ public String key;
+ public long score;
}
+
+ public static interface SearchProgressReporter {
+ public void progressReport(int percent);
+ }
public native void terminateSearch();
- public native SearchHit[] search(String istr, int searchType, long flags, String scope);
+ public native SearchHit[] search(String expression, int searchType, long flags, String scope, SearchProgressReporter progressReporter);
+ public SearchHit[] search(String expression) { return search(expression, SEARCHTYPE_MULTIWORD, 0, "", null); }
public native char error();
public native long getEntrySize();
public native String[] getEntryAttribute(String level1, String level2, String level3, boolean filtered);
More information about the sword-cvs
mailing list