commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nicola Ken Barozzi" <nicola...@apache.org>
Subject Re: [Morphos] Java data morphing package - second stab
Date Thu, 06 Jun 2002 20:26:35 GMT
From: "Stephen Colebourne" <scolebourne@eurobell.co.uk>

> >   * It uses two params and not a return value to make it usable with
> >   * event based Objects (contenthandlers).
> >   * Events in the Morpher are notified by registering a listener.
> >   * [new] parameters are managed with beans get/set methods
> >   *            *none* are mandatory
> >   */
> >  public interface Morpher {
> >      void morph(Object input, Object output) throws MorphException.
> > [Clarification]
> > Why not
> >   Object morph(Object input) throws MorphException, IOException;
> > ?
> > Because if the output object is a SAX handler, the morphing doesn't take
> > place, and this is not evident.
> > Any other pros-cons?
>
> The problem with the two object input approach is that it precludes a
simple
> type convertor being written using this architecture. A type convertor
> typically takes in an immutable object and returns an imutable object
> (String/Integer etc.)

Hmmm...

Integer input = new Integer(1);
String output = null;
[...]
mymorpher.morph(input , output);

If the morpher does

  output=input.toString();

wouldn't it work?

> Object morph(Object input)   does allow a String to Integer convertor, but
> is obviously a second interface, potentially providing confusion.

Yes, we need a single way, I agree.

> Given this, you may want to refine the definition of what can or can't be
> morphed (ie. to exclude immutable outputs).

Thinking of the immutable objects, what is more confusing:

Integer input = new Integer(1);
String output = "immutable string that will be replaced";
[...]
mymorpher.morph(input , output);

or

Contenthandler input = ...
Contenthandler output = ...
output = mymorpher.morph(input);

and still need to trigger the morphing?


IMO you are right, immutable objects make the morph(input, output) method a
bit ridiculous.

I think you've convinced me, what do others think?

--
Nicola Ken Barozzi                   nicolaken@apache.org
            - verba volant, scripta manent -
   (discussions get forgotten, just code remains)
---------------------------------------------------------------------


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


Mime
View raw message