You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Robin Green <gr...@hotmail.com> on 2001/02/02 02:36:53 UTC
[C1] proposed change to formatter interface
As a product of discussions with Uli on cocoon-users on outputting non-XML
content directly, such as .DOC or .PDF files, I think it would be an
improvement to tweak the Formatter interface to take an OutputStream instead
of a Writer (and then tweak all the implementations, of course). This would
serve two purposes:
1. Efficiency and reducing likelihood of OutOfMemoryErrors - Strings can be
converted into bytes in smaller chunks - rather than in one go as it is now,
which requires effectively two buffers (String and byte[]) equal to the size
of the entire output. (Actually there are 3 buffers! One can easily be
removed, which I'll do - it was just a very quick hack.) When generating
large output (e.g. PDF) this is a big waste and might require unnecessary
cache freeing-up. Plus, if a serializer has a faster way of converting chars
to bytes under a given encoding than String.getBytes (), this is the only to
take advantage of it!
2. I'd like to do a LiteralFormatter to do what Uli is trying to do but in a
way more suited to C1. (Unlike if you use XSP, this takes full advantage of
C1's response header support - heh, not much yet, but I plan to add more -
and caching, so there _are_ possible advantages). Anyway, it's
counterintuitive to output binary data through a Writer and store it in a
String. It would actually work, providing you choose an appropriate
encoding, but it just makes more sense to use an OutputStream.
(As a knock-on effect .../framework/Page.java would store cacheable content
as a byte array rather than a String.)
_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.