@Override
public Object doTransform(final Object src, final String encoding) throws TransformerException
{
if (src instanceof String)
{
return new OutputHandler()
{
public void write(MuleEvent event, OutputStream out) throws IOException
{
out.write(((String) src).getBytes(encoding));
}
};
}
else if (src instanceof byte[])
{
return new OutputHandler()
{
public void write(MuleEvent event, OutputStream out) throws IOException
{
out.write((byte[]) src);
}
};
}
else if (src instanceof InputStream)
{
return new OutputHandler()
{
public void write(MuleEvent event, OutputStream out) throws IOException
{
InputStream is = (InputStream) src;
try
{
IOUtils.copyLarge(is, out);
}
finally
{
is.close();
}
}
};
}
else if (src instanceof Serializable)
{
return new OutputHandler()
{
public void write(MuleEvent event, OutputStream out) throws IOException
{
SerializationUtils.serialize((Serializable) src, out);
}