try {
final Bindings b = OtpErlang.match(
"{Payload, Encoding, Leader, From, Tstamp}", obj);
encoding = getEncoding(b.getAtom("Encoding"));
final OtpErlangObject o = b.get("Payload");
if (o instanceof OtpErlangString) {
message = ((OtpErlangString) o).stringValue();
} else if (o instanceof OtpErlangList) {
final OtpErlangList l = (OtpErlangList) o;
if (l.arity() == 0) {
message = "";
} else {
try {
message = l.stringValue();
} catch (final Exception e) {
message = o.toString();
}
}
} else {
message = o.toString();
}
message = convertEncoding(message, encoding);
leader = b.getPid("Leader");
final OtpErlangObject s = b.get("From");
if (s instanceof OtpErlangPid) {
sender = (OtpErlangPid) s;
} else {
sender = new OtpErlangPid("s", 0, 0, 0);
}