commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex Karasulu <>
Subject [codec] Stateful/Streaming/Chunking Codecs (was: Who's In Charge)
Date Fri, 02 Jul 2004 16:20:48 GMT

> When I think about this, I come back to the Architecture used for the 
> JAXP Transformer Source and Result objects.

Is there some documentation on this architecture out there?  Might be
good for me to look it over.  BTW, although not directly related to JAXP
architecture specifically we looked at SAX while opting to go with the
callback mechanism.  The DecoderCallback is analogous to the SAX

> so in StatefulDecoder you have
> void decode( Object encoded ) throws DecoderException ;
> What about something like:
> void decode( EncodedSource source ) throws DecoderException ;
> then you can have
> ByteBufferSource implements EncodedSource { ...
> and
> ByteArraySource impements EncodedSource { ...

I like this approach.  What would the EncodedSource interface look like
or is it just a marker interface?

> The Source Implementations are responsible for those aspects that make 
> them NIO or not, then the Decoder itself stays generic and can even be 
> reused across different Source Implementations (Similar to how JAXP can 
> have a DOMSource, StreamSource or SAXSource).

That's most excellent; this is the goal we are all trying to achieve. 
The use of EncodedSource makes the API more explicit in the fact that it
operates upon some 'encoded' substrate btw.  It will give the API a
better defined symetry when we confront the Encoder interfaces.

If you'll permit me to play devil's advocate, let me ask what difference
is there in casting a EncodedSource to a
ByteArraySource/ByteBufferSource from casting an Object to a
byte[]/ByteBuffer?  In either case the API user will still have to cast
a general interface to get at a more specific implementation. 
Furthermore an extra wrapper object implementing EncodedSource would
need to be defined and instantiated in order to carry the byte[] or
ByteBuffer: referring here to the ByteArraySource and ByteBufferSource
implemenations respectfully.


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message