Value subjectValue = iterator.next();
if (! subjectValue.isString())
return env.error("subject values must be strings");
subjects[i++] = new Text(subjectValue.toString());
}
}
else if (subject.isString()) {
if (! subject.isString())
return env.error("subject values must be strings");
subjects = new Text[] { new Text(subject.toString()) };
}
}
// extract body text
Text[] bodies = null;
if (body.isArray()) {
bodies = new Text[body.getSize()];
int i = 0;
Iterator<Value> iterator = body.getValueIterator(env);
while (iterator.hasNext()) {
Value bodyValue = iterator.next();
if (! bodyValue.isString())
return env.error("body values must be strings");
bodies[i++] = new Text(bodyValue.toString());
}
}
else if (body.isString()) {
if (! body.isString())
return env.error("body values must be strings");
bodies = new Text[] { new Text(body.toString()) };
}
ImMessage message = new ImMessage(to, from, type,
subjects, bodies, thread, extras);