1 10 11 package org.mule.providers.dq; 12 13 import org.mule.providers.AbstractMessageAdapter; 14 import org.mule.transformers.simple.SerializableToByteArray; 15 import org.mule.umo.provider.MessageTypeNotSupportedException; 16 17 21 public class DQMessageAdapter extends AbstractMessageAdapter 22 { 23 26 private static final long serialVersionUID = -7484858345063740661L; 27 28 private static final SerializableToByteArray serializableToByteArray = new SerializableToByteArray(); 29 30 private final DQMessage message; 31 32 37 public DQMessageAdapter(Object message) throws MessageTypeNotSupportedException 38 { 39 if (message instanceof DQMessage) 40 { 41 this.message = (DQMessage)message; 42 } 43 else 44 { 45 throw new MessageTypeNotSupportedException(message, getClass()); 46 } 47 } 48 49 52 public final Object getPayload() 53 { 54 return message; 55 } 56 57 60 61 public final byte[] getPayloadAsBytes() throws Exception 62 { 63 return (byte[])serializableToByteArray.doTransform(message, getEncoding()); 64 } 65 66 74 public String getPayloadAsString(String encoding) throws Exception 75 { 76 return new String (getPayloadAsBytes(), encoding); 77 } 78 79 } 80 | Popular Tags |