00001
00002
00003
00004 #include "IndexBuilder.java.h"
00005 #include "JNIGateway.hpp"
00006
00014
00015 using namespace aitools::invertedindex;
00016
00017
00018
00019
00020
00021
00022 JNIEXPORT jint JNICALL Java_de_aitools_aq_invertedindex_core_IndexBuilder_natInstance
00023 (JNIEnv* env, jobject jbuilder, jstring jclazz)
00024 {
00025 try
00026 {
00027 Builder::shared_pointer builder;
00028 builder = JNIGateway::create_builder(env, jclazz);
00029 return JNIGateway::put_builder(builder);
00030 }
00031 catch (const std::exception& error)
00032 {
00033 env->ThrowNew(env->FindClass(JNIGateway::java_exception), error.what());
00034 }
00035 return -1;
00036 }
00037
00038
00039
00040
00041
00042
00043 JNIEXPORT void JNICALL Java_de_aitools_aq_invertedindex_core_IndexBuilder_natBuild
00044 (JNIEnv* env, jobject jbuilder, jint oid, jbyteArray jconfig)
00045 {
00046 try
00047 {
00048 Configuration config;
00049 if (!config.ParseFromArray(env->GetByteArrayElements(jconfig, NULL),
00050 env->GetArrayLength(jconfig)))
00051 {
00052 Exception::throw_invalid_argument("JNI: Cannot parse config");
00053 }
00054 JNIGateway::get_builder(oid)->build(config);
00055 }
00056 catch (const std::exception& error)
00057 {
00058 env->ThrowNew(env->FindClass(JNIGateway::java_exception), error.what());
00059 }
00060 }
00061
00062
00063
00064
00065
00066
00067 JNIEXPORT void JNICALL Java_de_aitools_aq_invertedindex_core_IndexBuilder_natDelete
00068 (JNIEnv* env, jobject jbuilder, jint oid)
00069 {
00070 JNIGateway::delete_builder(oid);
00071 }