From: Matt B. <gud...@ya...> - 2008-01-04 21:04:54
|
In the meantime I am experimenting with the ImpreciseConverter idea. When I get things working satisfactorily I'll post a patch. Let me remind you that it would be fairly unintrusive since ChainedTransformer would be the only internal Morph code that would need the information. Users might like to have such information available; another example of imprecise conversions is numeric conversions, e.g. long to int, int to byte, etc. -Matt B --- Matt Sgarlata <mat...@sp...> wrote: > It sounds to me like I need to fix how the source > and destination arrays are > constructed so that order is preserved. > > I agree it is definitely not OK for this to require > repetitive configuration > to prevent difficult to detect errors. > > I will take a look first thing Monday. > > Matt > > On Jan 4, 2008 1:04 PM, Matt Benson > <gud...@ya...> wrote: > > > Basically the order of destination classes in a > given > > converter in the chain already does influence the > > conversion path chosen. However, many of the > stock > > transformers use sets to build the source and/or > > destination class arrays, so the final order is > > unpredictable. As for examples, anytime you > convert a > > string to a char/Character, you (unless the string > is > > exactly one character in length) lose information. > > Anytime you convert an object to null, you lose > all > > information that was associated with that object. > So > > if you, as in ChainedTransformerTest, chain a > > TextToNumberConverter, a DefaultToTextConverter, > and > > another TextToNumberConverter, and the > > DefaultToTextConverter happens to return a char > type > > before one of its other types, digits will be lost > and > > the test will fail. An easy way to trigger an > error > > is to insert an extra TextConverter at index 2, > with { > > char.class, String.class } as its > destinationClasses. > > Again, it's very easy to solve the problem through > > configuration. The problem is that it's > repetitive > > and can be hard to detect because the odds will > often > > be against selecting the bad path--then one day it > > will arise unexpectedly. > > > > -Matt B > > > > --- Matt Sgarlata > > <Mat...@wh...> wrote: > > > > > Yikes, that doesn't sound good. I'm wondering > if it > > > would be possible to > > > fix this as an implementation concern rather > than > > > introducing a new > > > interface. Perhaps the ordering of the source > and > > > destination classes could > > > be used by the ChainedTransformer to give an > > > indication of preference for > > > the conversion path chosen. > > > > > > Can you give me a concrete example where data is > > > lost? I would be very > > > interested in setting up a test case that > > > demonstrates the problem and also > > > a solution for the problem. This is the type of > > > problem with Morph that I > > > have a lot of fun with ;) > > > > > > Matt S > > > > > > On Jan 3, 2008 5:27 PM, Matt Benson > > > <gud...@ya...> wrote: > > > > > > > In using ChainedTransformer I find I have to > jump > > > > through hoops at times to pick the proper > > > > transformation path, particularly with the > > > > TextConverter. If it happens to pick char, > > > Character, > > > > or null as a conversion step between e.g. a > > > "to-text" > > > > converter and a "from-text" converter, data is > > > lost. > > > > I am thinking of an interface like this: > > > > > > > > public interface ImpreciseConverter extends > > > Converter > > > > { > > > > boolean isImpreciseConversion(Class > > > > destinationClass, Class sourceClass); > > > > } > > > > > > > > The default implementation on BaseTransformer: > > > > > > > > public boolean isImpreciseConversion(Class > > > > destinationClass, Class sourceClass) { > > > > return destinationClass == null && > sourceClass > > > != > > > > null; > > > > } > > > > > > > > TextConverter would report that a conversion > from > > > a > > > > string to null or char is imprecise. > > > > ChainedTransformer could then be coded to > avoid > > > > imprecise conversions when possible. > > > > > > > > WDYT? > > > > > > > > -Matt B > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > ____________________________________________________________________________________ > > > > Never miss a thing. Make Yahoo your home > page. > > > > http://www.yahoo.com/r/hs > > > > > > > > > > > > > > ------------------------------------------------------------------------- > > > > This SF.net email is sponsored by: Microsoft > > > > Defy all challenges. Microsoft(R) Visual > Studio > > > 2005. > > > > > > > > > > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > > > > > _______________________________________________ > > > > morph-developer mailing list > > > > mor...@li... > > > > > > > > > > https://lists.sourceforge.net/lists/listinfo/morph-developer > > > > > > > > > > > > > > > > -- > > > This message is intended only for the named > > > recipient. If you are not the > > > intended recipient, you are notified that > > > disclosing, copying, distributing, > > > or taking any action in reliance on the contents > of > > > this information is > > > strictly prohibited. > > > > > > > ------------------------------------------------------------------------- > > > This SF.net email is sponsored by: Microsoft > > > Defy all challenges. Microsoft(R) Visual Studio > > > 2005. > > > > > > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/> > > _______________________________________________ > > > morph-developer mailing list > > > mor...@li... > > > > > > https://lists.sourceforge.net/lists/listinfo/morph-developer > > > > > > > > > > > > > > ____________________________________________________________________________________ > > Looking for last minute shopping deals? > > Find them fast with Yahoo! Search. > > > http://tools.search.yahoo.com/newsearch/category.php?category=shopping > > > > > ------------------------------------------------------------------------- > > This SF.net email is sponsored by: Microsoft > > Defy all challenges. Microsoft(R) Visual Studio > 2005. > > > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > > _______________________________________________ > > morph-developer mailing list > > mor...@li... > > > https://lists.sourceforge.net/lists/listinfo/morph-developer > > > > > > -- > This message is intended only for the named > recipient. If you are not the > intended recipient, you are notified that > disclosing, copying, distributing, > or taking any action in reliance on the contents of > this information is > strictly prohibited. > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio > 2005. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/> _______________________________________________ > morph-developer mailing list > mor...@li... > https://lists.sourceforge.net/lists/listinfo/morph-developer > ____________________________________________________________________________________ Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ |