Changeset 68 for trunk


Ignore:
Timestamp:
Jan 12, 2011, 8:57:19 PM (14 years ago)
Author:
djay
Message:

JAVA Supprot : binary files support for data in both inputs and outputs.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/zoo-kernel/service_internal_java.c

    r62 r68  
    197197      map* tmp1=tmp->content;
    198198      scObject1 = (*env)->NewObject(env, scHashMap_class, scHashMap_constructor);
     199      map* sizeV=getMap(tmp1,"size");
    199200      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));
    201207        tmp1=tmp1->next;
    202208      }
     
    224230   */
    225231  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;
    227233  jobject scObject,scObject1;
    228234  if(scHashMapClass==NULL){
     
    231237  }
    232238  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  }
    233247  if(entrySet_mid==0){
    234248    fprintf(stderr,"unable to load entrySet from HashMap object (%d) \n",entrySet_mid);
     
    279293    jobject iterator=(*env)->CallObjectMethod(env,set,iterator_mid);
    280294
     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   
    281303    while((*env)->CallBooleanMethod(env,iterator,hasNext_mid)){
    282304      jobject tmp1=(*env)->CallObjectMethod(env,iterator,next_mid);
     
    285307
    286308      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      }
    288334
    289335#ifdef DEBUG
     
    291337#endif
    292338
    293       if(res==NULL){
    294         res=createMap(jkd,jvd);
    295       }else{
    296         addToMap(res,jkd,jvd);
    297       }
    298339      (*env)->ReleaseStringChars(env, jk, jkd);
    299       (*env)->ReleaseStringChars(env, jv, jvd);
    300340
    301341    }
Note: See TracChangeset for help on using the changeset viewer.

Search

Context Navigation

ZOO Sponsors

http://www.zoo-project.org/trac/chrome/site/img/geolabs-logo.pnghttp://www.zoo-project.org/trac/chrome/site/img/neogeo-logo.png http://www.zoo-project.org/trac/chrome/site/img/apptech-logo.png http://www.zoo-project.org/trac/chrome/site/img/3liz-logo.png http://www.zoo-project.org/trac/chrome/site/img/gateway-logo.png

Become a sponsor !

Knowledge partners

http://www.zoo-project.org/trac/chrome/site/img/ocu-logo.png http://www.zoo-project.org/trac/chrome/site/img/gucas-logo.png http://www.zoo-project.org/trac/chrome/site/img/polimi-logo.png http://www.zoo-project.org/trac/chrome/site/img/fem-logo.png http://www.zoo-project.org/trac/chrome/site/img/supsi-logo.png http://www.zoo-project.org/trac/chrome/site/img/cumtb-logo.png

Become a knowledge partner

Related links

http://zoo-project.org/img/ogclogo.png http://zoo-project.org/img/osgeologo.png