commons-dev mailing list archives

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

> 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
handler.

> 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.

Alex



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message