* @throws ClassNotFoundException
*/
protected JComponent handleBytesMessage(JScrollPane parent, BytesMessage bytesMessage) throws JMSException, IOException, ClassNotFoundException {
final MyConfig currentConfig = (MyConfig) getConfig();
JTextArea textPane = new MyTextArea();
textPane.setEditable(false);
textPane.setWrapStyleWord(true);
textPane.setLineWrap(true);
bytesMessage.reset();
if (currentConfig.isBytesIsObject()) {
final byte[] bytes = MessageUtils.asBytes(bytesMessage);
final ByteArrayInputStream bistream = new ByteArrayInputStream(bytes);
final ObjectInputStream oistream = new ObjectInputStream(bistream);
final Object o = oistream.readObject();
textPane.setText(o.toString());
} else if (currentConfig.isBytesIsString()) {
try {
String text = new String(MessageUtils.asBytes(bytesMessage), currentConfig.getBytesEncoding());
textPane.setText(text);
return textPane;
} catch (JMSException e) {
textPane.setText(e.getMessage());
}
} else {
HexMessageRenderer renderer = new HexMessageRenderer();
textPane = (JTextArea) renderer.render(parent, bytesMessage); // Hack.
}
textPane.setCaretPosition(0);
return textPane;
}