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