<commit_before>#include "rhodes/JNIRhodes.h"
#include "rhodes/JNIRhoJS.h"

#undef DEFAULT_LOGCATEGORY
#define DEFAULT_LOGCATEGORY "JNIRhoJS"

namespace details {

using rho::json::CJSONArray;
using rho::json::CJSONStructIterator;

//----------------------------------------------------------------------------------------------------------------------

jstring rho_cast_helper<jstring, CJSONEntry>::operator ()(JNIEnv *env, const CJSONEntry& jsonEntry)
{
    return rho_cast<jstring>(env, jsonEntry.getString());
}
//----------------------------------------------------------------------------------------------------------------------

jobject rho_cast_helper<jobject, CJSONEntry>::convertJsonEntryToJavaCollection(const CJSONEntry& jsonEntry)
{
    jobject jList = m_env->NewObject(clsArrayList, midArrayList);
    if(!jList)
    {
        return 0;
    }
    CJSONArray jsonArray(jsonEntry);
    int size = jsonArray.getSize();

    for(int i = 0; i < size; ++i)
    {
        jhstring jhElement = rho_cast<jstring>(m_env, jsonArray.getItem(i).getString());
        m_env->CallBooleanMethod(jList, RhoJniConvertor::midArrayListAdd, jhElement.get());
    }

    return jList;
}
//----------------------------------------------------------------------------------------------------------------------

jobject rho_cast_helper<jobject, CJSONEntry>::convertJsonEntryToJavaMap(const CJSONEntry& jsonEntry)
{
    jobject jMap = m_env->NewObject(clsHashMap, midHashMap);
    if(!jMap)
    {
        return 0;
    }

    CJSONStructIterator jsonObjectIt(jsonEntry);
    while(!jsonObjectIt.isEnd())
    {
        jhstring jhKey = rho_cast<jstring>(m_env, jsonObjectIt.getCurKey());
        jhstring jhVal = rho_cast<jstring>(m_env, jsonObjectIt.getCurString());

        jhobject jhPrev = m_env->CallObjectMethod(jMap, RhoJniConvertor::midHashMapPut, jhKey.get(), jhVal.get());
    }
<commit_msg>Update JNIRhoJS.cpp<commit_after>#include "rhodes/JNIRhodes.h"
#include "rhodes/JNIRhoJS.h"

#undef DEFAULT_LOGCATEGORY
#define DEFAULT_LOGCATEGORY "JNIRhoJS"

namespace details {

using rho::json::CJSONArray;
using rho::json::CJSONStructIterator;

//----------------------------------------------------------------------------------------------------------------------

jstring rho_cast_helper<jstring, CJSONEntry>::operator ()(JNIEnv *env, const CJSONEntry& jsonEntry)
{
    return rho_cast<jstring>(env, jsonEntry.getString());
}
//----------------------------------------------------------------------------------------------------------------------

jobject rho_cast_helper<jobject, CJSONEntry>::convertJsonEntryToJavaCollection(const CJSONEntry& jsonEntry)
{
    jobject jList = m_env->NewObject(clsArrayList, midArrayList);
    if(!jList)
    {
        return 0;
    }
    CJSONArray jsonArray(jsonEntry);
    int size = jsonArray.getSize();

    for(int i = 0; i < size; ++i)
    {
        jhstring jhElement = rho_cast<jstring>(m_env, jsonArray.getItem(i).getString());
        m_env->CallBooleanMethod(jList, RhoJniConvertor::midArrayListAdd, jhElement.get());
    }

    return jList;
}
//----------------------------------------------------------------------------------------------------------------------

jobject rho_cast_helper<jobject, CJSONEntry>::convertJsonEntryToJavaMap(const CJSONEntry& jsonEntry)
{
    jobject jMap = m_env->NewObject(clsHashMap, midHashMap);
    if(!jMap)
    {
        return 0;
    }

    CJSONStructIterator jsonObjectIt(jsonEntry);
    for( ; !jsonObjectIt.isEnd(); jsonObjectIt.next() )
    {
        jhstring jhKey = rho_cast<jstring>(m_env, jsonObjectIt.getCurKey());
        jhstring jhVal = rho_cast<jstring>(m_env, jsonObjectIt.getCurString());

        jhobject jhPrev = m_env->CallObjectMethod(jMap, RhoJniConvertor::midHashMapPut, jhKey.get(), jhVal.get());
    }

{'fraction_non_alphanumeric': 0.28931478078235756, 'fraction_numerical': 0.0015752165922814387, 'mean_word_length': 1.9858934169278997, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6710109', 'n_tokens_mistral': 1133, 'n_tokens_neox': 1114, 'n_words': 177}