ByteBuffer buf = ByteBuffer.wrap(bytes);
UUID uuid = (UUID) o;
buf.putLong(uuid.getMostSignificantBits());
buf.putLong(uuid.getLeastSignificantBits());
atom.setType(pn_type_t.PN_UUID);
pn_bytes_t val = new pn_bytes_t();
Proton.pn_bytes_from_array(val, bytes);
atom.getU().setAs_bytes(val);
val.delete();
}
//PN_BINARY
else if(o instanceof byte[] || o instanceof Binary)
{
byte[] bytes = (o instanceof byte[]) ? (byte[])o : ((Binary)o).getArray();
atom.setType(pn_type_t.PN_BINARY);
pn_bytes_t val = new pn_bytes_t();
Proton.pn_bytes_from_array(val, bytes);
atom.getU().setAs_bytes(val);
val.delete();
}
//PN_STRING
else if(o instanceof String)
{
byte[] bytes = ((String)o).getBytes(UTF8_CHARSET);
atom.setType(pn_type_t.PN_STRING);
pn_bytes_t val = new pn_bytes_t();
Proton.pn_bytes_from_array(val, bytes);
atom.getU().setAs_bytes(val);
val.delete();
}
//PN_SYMBOL
else if(o instanceof Symbol)
{
byte[] bytes = ((Symbol)o).toString().getBytes(ASCII_CHARSET);
atom.setType(pn_type_t.PN_STRING);
pn_bytes_t val = new pn_bytes_t();
Proton.pn_bytes_from_array(val, bytes);
atom.getU().setAs_bytes(val);
val.delete();
}
//PN_DESCRIBED
// TODO
//PN_ARRAY
// TODO