]> rtime.felk.cvut.cz Git - orte.git/blob - orte/libjorte/setTopic.c
455d58b1370eedba0b9d685e12588ba0a062be76
[orte.git] / orte / libjorte / setTopic.c
1 /* setTopic.c */
2
3 #include <jni.h>
4 #include "jorte/4all.h"
5 #include "jorte/jorte_protos_api.h"
6
7 int setTopic(JNIEnv *env, jclass cls, jobject obj, const char *topic)
8 {
9     jfieldID  fid;
10     jstring   jstr;
11
12     // field ID - topic
13     fid = (*env)->GetFieldID(env,
14                              cls,
15                              "topic",
16                              "Ljava/lang/String;");
17     if(fid == 0)
18     {
19       #ifdef TEST_STAGE
20         printf(":!c: topic - fid = NULL \n");
21       #endif
22       return 0;
23     }
24     #ifdef TEST_STAGE
25        printf(":c: topic = %s \n",topic);
26     #endif
27    // create a new string
28    jstr = (*env)->NewStringUTF(env, topic);
29    if (jstr == 0)
30    {
31      #ifdef TEST_STAGE
32        printf(":!c: topic - fid = NULL \n");
33      #endif
34      return 0;
35    }
36    // set field
37    (*env)->SetObjectField(env, obj, fid, jstr);
38
39    return 1;
40
41 }