}
else if (result instanceof BufferedStreamResult)
{
BufferedStreamResult br = (BufferedStreamResult)result;
ByteArrayOutputStream baos = (ByteArrayOutputStream)br.getOutputStream();
source = new BufferedStreamSource(baos.toByteArray());
}
else
{
throw new IllegalArgumentException("Unsupported result type: " + result);
}