- Timestamp:
- Jan 12, 2011, 8:57:19 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/zoo-kernel/service_internal_java.c
r62 r68 197 197 map* tmp1=tmp->content; 198 198 scObject1 = (*env)->NewObject(env, scHashMap_class, scHashMap_constructor); 199 map* sizeV=getMap(tmp1,"size"); 199 200 while(tmp1!=NULL){ 200 (*env)->CallObjectMethod(env,scObject1, put_mid, (*env)->NewStringUTF(env,tmp1->name), (*env)->NewStringUTF(env,tmp1->value)); 201 if(sizeV!=NULL && strcmp(tmp1->name,"value")==0){ 202 jbyteArray tmpData=(*env)->NewByteArray(env,atoi(sizeV->value)); 203 (*env)->SetByteArrayRegion(env,tmpData,0,atoi(sizeV->value),tmp1->value); 204 (*env)->CallObjectMethod(env,scObject1, put_mid, (*env)->NewStringUTF(env,tmp1->name), tmpData); 205 }else 206 (*env)->CallObjectMethod(env,scObject1, put_mid, (*env)->NewStringUTF(env,tmp1->name), (*env)->NewStringUTF(env,tmp1->value)); 201 207 tmp1=tmp1->next; 202 208 } … … 224 230 */ 225 231 jclass scHashMap_class,scSetClass,scIteratorClass,scMapEntryClass,scSet_class,scMapClass; 226 jmethodID entrySet_mid, iterator_mid,hasNext_mid,next_mid,getKey_mid,getValue_mid;232 jmethodID entrySet_mid,containsKey_mid,get_mid,iterator_mid,hasNext_mid,next_mid,getKey_mid,getValue_mid; 227 233 jobject scObject,scObject1; 228 234 if(scHashMapClass==NULL){ … … 231 237 } 232 238 entrySet_mid = (*env)->GetMethodID(env, scHashMapClass, "entrySet", "()Ljava/util/Set;"); 239 containsKey_mid = (*env)->GetMethodID(env, scHashMapClass, "containsKey", "(Ljava/lang/Object;)Z"); 240 get_mid = (*env)->GetMethodID(env, scHashMapClass, "get", "(Ljava/lang/Object;)Ljava/lang/Object;"); 241 if(containsKey_mid==0){ 242 fprintf(stderr,"unable to load containsKey from HashMap object (%d) \n",entrySet_mid); 243 } 244 if(get_mid==0){ 245 fprintf(stderr,"unable to load get from HashMap object (%d) \n",entrySet_mid); 246 } 233 247 if(entrySet_mid==0){ 234 248 fprintf(stderr,"unable to load entrySet from HashMap object (%d) \n",entrySet_mid); … … 279 293 jobject iterator=(*env)->CallObjectMethod(env,set,iterator_mid); 280 294 295 int size=-1; 296 if((*env)->CallBooleanMethod(env,imap,containsKey_mid,(*env)->NewStringUTF(env,"size"))){ 297 jobject sizeV=(*env)->CallObjectMethod(env, imap, get_mid,(*env)->NewStringUTF(env,"size")); 298 jstring sizeVS=(*env)->GetStringUTFChars(env, sizeV, NULL); 299 size=atoi(sizeVS); 300 fprintf(stderr,"SIZE : %s\n",sizeVS); 301 } 302 281 303 while((*env)->CallBooleanMethod(env,iterator,hasNext_mid)){ 282 304 jobject tmp1=(*env)->CallObjectMethod(env,iterator,next_mid); … … 285 307 286 308 jstring jkd=(*env)->GetStringUTFChars(env, jk, NULL); 287 jstring jvd=(*env)->GetStringUTFChars(env, jv, NULL); 309 if(size>=0 && strcmp(jkd,"value")==0){ 310 fprintf(stderr,"%s\n",jkd); 311 jobject value=(*env)->GetByteArrayElements(env, jv, NULL); 312 if(res==NULL){ 313 res=createMap(jkd,""); 314 }else{ 315 addToMap(res,jkd,""); 316 } 317 fprintf(stderr,"/%s\n",jkd); 318 map* tmpR=getMap(res,"value"); 319 free(tmpR->value); 320 tmpR->value=(char*)malloc((size+1)*sizeof(char)); 321 memmove(tmpR->value,value,size*sizeof(char)); 322 tmpR->value[size]=0; 323 fprintf(stderr,"/%s\n",jkd); 324 } 325 else{ 326 jstring jvd=(*env)->GetStringUTFChars(env, jv, NULL); 327 if(res==NULL){ 328 res=createMap(jkd,jvd); 329 }else{ 330 addToMap(res,jkd,jvd); 331 } 332 (*env)->ReleaseStringChars(env, jv, jvd); 333 } 288 334 289 335 #ifdef DEBUG … … 291 337 #endif 292 338 293 if(res==NULL){294 res=createMap(jkd,jvd);295 }else{296 addToMap(res,jkd,jvd);297 }298 339 (*env)->ReleaseStringChars(env, jk, jkd); 299 (*env)->ReleaseStringChars(env, jv, jvd);300 340 301 341 }
Note: See TracChangeset
for help on using the changeset viewer.