I'm trying to parse a REXP output. I've converted the result into a java object. However I'm not able to get the value inside the object. The object m contains:
[1, 1, 3, 1, 3, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]
[9.12324245]
[1212,1234,4343]
[3.456]
I need to get these value into an array for further processing
Any help here would be really great? The code snippet is given below:
REXP kmv = connection.eval(kmeans);
HashMap<String, Object> j = (HashMap<String, Object>) kmv.asNativeJavaObject();
Set<Entry<String, Object>> set = j.entrySet();
Iterator<Entry<String, Object>> i = set.iterator();
while(i.hasNext()) {
Map.Entry<String, Object> me = (Map.Entry<String, Object>)i.next();
String key = (String) me.getValue();
Object m = (Object)me.getKey();
}
The answer was simple
// Back to the basics of decoding an object :)
if (m.getClass().isArray()) {
if (m instanceof double[]) {
value = Arrays.toString((double[])m);
} else if (m instanceof int[]) {
value = Arrays.toString((int[])m);
}
}