* //
* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
*/
+
+#include <map>
+
#include "JniOcRepresentation.h"
#include "JniUtils.h"
/*
* Class: org_iotivity_base_OcRepresentation
+* Method: getValues
+* Signature: ()Ljava/util/Map;
+*/
+JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcRepresentation_getValues
+(JNIEnv *env, jobject thiz)
+{
+ LOGD("OcRepresentation_getValues");
+ OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
+ if (!rep) return nullptr;
+
+ std::map<std::string, AttributeValue> values = rep->getValues();
+ jobject jHashMap = env->NewObject(g_cls_HashMap, g_mid_HashMap_ctor);
+ if (!jHashMap) return nullptr;
+
+ for (std::map<std::string, AttributeValue>::const_iterator it = values.begin(); it != values.end(); it++) {
+ jobject key = static_cast<jobject>(env->NewStringUTF(it->first.c_str()));
+ jobject val = boost::apply_visitor(JObjectConverter(env), it->second);
+ env->CallObjectMethod(jHashMap, g_mid_HashMap_put, key, val);
+ }
+ return jHashMap;
+}
+
+/*
+* Class: org_iotivity_base_OcRepresentation
* Method: getValueN
* Signature: (Ljava/lang/String;)Ljava/lang/Object;
*/
/*
* Class: org_iotivity_base_OcRepresentation
+ * Method: getValues
+ * Signature: ()Ljava/util/Map;
+ */
+ JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcRepresentation_getValues
+ (JNIEnv *, jobject);
+
+ /*
+ * Class: org_iotivity_base_OcRepresentation
* Method: getValueN
* Signature: (Ljava/lang/String;)Ljava/lang/Object;
*/
import java.security.InvalidParameterException;
import java.util.Arrays;
import java.util.List;
+import java.util.Map;
/**
*
this.mNativeNeedsDelete = nativeNeedsDelete;
}
+ public native Map<String, Object> getValues();
+
public <T> T getValue(String key) throws OcException {
Object obj = this.getValueN(key);
@SuppressWarnings("unchecked")