Andy Clark wrote:

> Aleksander Slominski wrote:
> > i have implemented something like this already by wrapping
> > real reader with special reader that is cumulating input when
> > asked for. that allows me to keep buffer offsets from
> > XMLString and uses content in cumulative reader buffer
> > even though Xerces may reuse its internal buffer
> > (see below how i implemented CumulativeReader - it
> > works but is inefficient as it adds extra layer of indirection
> > and another buffer potentially for all IO operations).
>
> The inefficiency is precisely the reason why I wouldn't
> want to use this type of approach. Besides, this approach
> has a hard limit of Integer.MAX_VALUE.

hi,

typical usage pattern is to lock buffer when interesting
event happens (for example first call to characters())
and then unlock to retrieve content (for example in endElement())
- that means that client does not need to copy
buffer content (no need to accumulate characters()
content in StringBuffer etc.).

when unlocked the content of the buffer has exactly
the same semantics as currently (when unlocked buffer can be shrank)
however when locked it is then guaranteed that offsets
into buffer content are valid until buffer is unlocked.
therefore only if buffer is locked permanently it will grow indefinitely.


anyway i think it is very useful feature.


> The approach I'm thinking of simply manages the creation
> of buffers, not what is done with them. So the various
> parts of the code would still be in control of their own
> buffers but would simply request new buffers from the
> buffer manager/factory/whatever.

however that means that making sure that
buffer can be safely reused will be very difficult - right?

i think that if buffers are not reused then xerces may
be facing memory problems when parsing large XML input
(for example if client keeps reference to buffers
passed in characters())?

thanks,

alek



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to