[xwiki-devs] [GSoC][officeimporter]the interface of office converter
Hi Vincent, I think OutputStream convert(InputStream inputStream, OfficeDocumentType inputDocumentType, OfficeDocumentType outputDocumentType) is not appropriate. The OutputStream is a place to write data to. I just can't get the data from the OutputStream. I think the OutputStream should be a special outputStream the user provide, so I have these to proposals for this interface: 1. ByteArrayOutputStream convert(InputStream inputStream, OfficeDocumentType inputDocumentType, OfficeDocumentType outputDocumentType) return type change to ByteArrayOutputStream. Then client can use ByteArrayOutputStream.toByteArray() to get the contents in OutputStream. 2. void convert(InputStream inputStream, OfficeDocumentType inputDocumentType, OutputStream outputStream, OfficeDocumentType outputDocumentType) Client provide a output Target to store the contents. Example: ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); convert(inputStream, inputDocumentType, outputStream, outputDocumentType) WDYT? -- Thanks Wang Ning
Hi Vincent, I found this page, http://ostermiller.org/convert_java_outputstream_inputstream.html On Sat, Aug 23, 2008 at 1:54 PM, Wang Ning <[email protected]> wrote:
Hi Vincent,
I think OutputStream convert(InputStream inputStream, OfficeDocumentType inputDocumentType, OfficeDocumentType outputDocumentType) is not appropriate. The OutputStream is a place to write data to. I just can't get the data from the OutputStream. I think the OutputStream should be a special outputStream the user provide, so I have these to proposals for this interface: 1. ByteArrayOutputStream convert(InputStream inputStream, OfficeDocumentType inputDocumentType, OfficeDocumentType outputDocumentType) return type change to ByteArrayOutputStream. Then client can use ByteArrayOutputStream.toByteArray() to get the contents in OutputStream.
2. void convert(InputStream inputStream, OfficeDocumentType inputDocumentType, OutputStream outputStream, OfficeDocumentType outputDocumentType) Client provide a output Target to store the contents. Example: ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); convert(inputStream, inputDocumentType, outputStream, outputDocumentType)
WDYT? -- Thanks Wang Ning
-- Thanks Wang Ning
On Aug 23, 2008, at 7:54 AM, Wang Ning wrote:
Hi Vincent,
I think OutputStream convert(InputStream inputStream, OfficeDocumentType inputDocumentType, OfficeDocumentType outputDocumentType) is not appropriate. The OutputStream is a place to write data to. I just can't get the data from the OutputStream.
But why would you want to get data from it! You should only write to it inside convert() :) It's the user of it who may want to get the data and this is easy since he just have to use a StringBuffer/String as the underlying storage mechanism. So yes it definitely seem the correct way to do it. Thanks -Vincent
I think the OutputStream should be a special outputStream the user provide, so I have these to proposals for this interface: 1. ByteArrayOutputStream convert(InputStream inputStream, OfficeDocumentType inputDocumentType, OfficeDocumentType outputDocumentType) return type change to ByteArrayOutputStream. Then client can use ByteArrayOutputStream.toByteArray() to get the contents in OutputStream.
2. void convert(InputStream inputStream, OfficeDocumentType inputDocumentType, OutputStream outputStream, OfficeDocumentType outputDocumentType) Client provide a output Target to store the contents. Example: ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); convert(inputStream, inputDocumentType, outputStream, outputDocumentType)
WDYT? -- Thanks Wang Ning _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
participants (2)
-
Vincent Massol -
Wang Ning