/** * Converts the message implementation into a String representation * * @return String representation of the message * @throws Exception Implemetation may throw an endpoint specific exception */ public byte[] getPayloadAsBytes() throws Exception { if (out instanceof ByteArrayOutputStream) { return ((ByteArrayOutputStream) out).toByteArray(); } else { logger.warn("Attempting to get the bytes of a non-ByteArray output stream"); return StringMessageUtils.getBytes(out.toString()); } }
public OutStreamMessageAdapter(Object message) throws MessageTypeNotSupportedException { try { if (message instanceof OutputStream) { out = (OutputStream) message; } else if (message instanceof String) { out = new ByteArrayOutputStream(message.toString().length()); out.write(StringMessageUtils.getBytes(message.toString())); } else if (message instanceof byte[]) { out = new ByteArrayOutputStream(((byte[]) message).length); out.write((byte[]) message); } else { throw new MessageTypeNotSupportedException(message, getClass()); } } catch (IOException e) { throw new MessageTypeNotSupportedException(message, getClass(), e); } }
public void write(String string, int offset, int len) throws IOException { out.write(StringMessageUtils.getBytes(string), offset, len); }
public void write(String string) throws IOException { out.write(StringMessageUtils.getBytes(string)); }