I like it.

I think init() should be aptly named setOutputFormat(), with a guarantee
that doing either a setOutputFormat() or setOutputStream() will
re-intialize the serializer.

I would rather use the names asDOMSerializer() and asDocumentHandler()
because you are returning a different view of an already created
serializer, not creating a new one (even though each of these objects
could be separate).

Other than that, +1 for me on all interfaces proposed.


One question, though. I see people getting confused with the name
BaseSerializer assuming that all serializers must extend it, when in
fact it's very specific to XML/HTMLSerializer. I'm looking a name that
will convey being a parent class (and abstract), but not one that people
should be looking to extend or construct. And idead?

arkin


> Sorry.  Something along the lines of...
> 
> public interface DOMSerializer
> {
>   /**
>    * Serialized the DOM element. Throws an exception only
>    * if an I/O exception occured while serializing.
>    *
>    * @param node The node to serialize
>    * @throws IOException An I/O exception occured while
>    *   serializing
>    */
>   public void serialize( Node node )
>     throws IOException;
> 
>   /**
>    * Serializes the DOM document. Throws an exception only
>    * if an I/O exception occured while serializing.
>    *
>    * @param doc The document to serialize
>    * @throws IOException An I/O exception occured while
>    *   serializing
>    */
>   public void serialize( Document doc )
>     throws IOException;
> }
> 
> public interface Serializer
> {
>     /**
>      * Re-initialize the serializer with the given
>      * OutputFormat.  This does not use the method
>      * property of the OutputFormat, since the method
>      * should have already been determined.
>      */
>     void reinit( OutputFormat format );
> 
>     /**
>      * Reset out output stream.
>      */
>     void setOutputByteStream(OutputStream output)
>       throws UnsupportedEncodingException;
> 
>     /**
>      * Reset the ouput character stream.
>      */
>     void setOutputCharStream(Writer output);
> 
>     /**
>      * Return a DocumentHandler interface, if this
>      * object support this.  This method may return null.
>      */
>     DocumentHandler getDocumentHandler();
> 
>     /**
>      * Return a DOMSerializer interface, if this
>      * object supports this.  This method may return null.
>      */
>     DOMSerializer getDOMSerializer();
> }
> 
> public abstract class SerializerFactory
> {
>   /**
>    * Register a serializer factory, keyed by the given
>    * method string.
>    */
>   public static void registerSerializerFactory( String method,
>                                   SerializerFactory factory )
>   {
>     ...
>   }
> 
>   /**
>    * Register a serializer factory, keyed by the given
>    * method string.
>    */
>   public static SerializerFactory getSerializerFactory( String method )
>   {
>     ...
>   }
> 
>   /**
>    * Create a new serializer, based on the OutputFormat.  If this
>    * method is used to create the Serializer, the setOutputByteStream
>    * or setOutputCharStream methods on the Serializer will need
>    * to be called.
>    */
>   public abstract Serializer makeSerializer(OutputFormat format);
> 
>   /**
>    * Create a new serializer, based on the OutputFormat, and
>    * using the writer as the output character stream.  If this
>    * method is used, the encoding property will be ignored.
>    */
>   public abstract Serializer makeSerializer(Writer writer,
>                                             OutputFormat format);
> 
>   /**
>    * Create a new serializer, based on the
>    */
>   public abstract Serializer makeSerializer(OutputStream output,
>                                             OutputFormat format)
>     throws UnsupportedEncodingException;
> 
> }
> 
> -scott

-- 
____________________________________________________________
Assaf Arkin                               [EMAIL PROTECTED]
CTO                                  http://www.exoffice.com
Exoffice, The ExoLab Company             tel: (650) 259-9796

Reply via email to