From: Matt B. <gud...@ya...> - 2008-01-31 21:40:57
|
--- Matt Sgarlata <mat...@sp...> wrote: > I was actually originally thinking of > isImprecise(Object,Object), but of > course that doesn't really work for converters, so I > hadn't through things > very clearly ;) It's probably a blessing in disguse > that > isImprecise(Class,Object) doesn't work, because that > interface really feels > like fudging things to me. > > How about this, for PNMC, just attempt to > instantiate an empty instance of > the source and destination and retrieve the > properties that way. If the > PNMC is able to instantiate the source and > destination and figure out the > properties of the objects, great. Otherwise, just > assume the transformation > is imprecise. Subclasses can refine the behavior. > How does that sound? > That sounds okay to me. > Or if that ends up being too much work, perhaps it > would be safest to just > assume PNMC is imprecise, because most of the time > it is going to be. This > is because PNMC takes any old Object as a source and > destination, so all the > nonsensical transformations like Integer -> Map get > thrown its way. > I'll keep this option in mind as well if I run into further trouble. Thanks, Matt B > Matt > > On Jan 31, 2008 2:03 PM, Matt Benson > <gud...@ya...> wrote: > > > Wait--this won't work with ChainedTransformer b/c > it > > wants to use classes when it's determining a > > conversion path (it doesn't have the intermediate > > objects). The only way to do this would be to > check > > each conversion step for precision; if precise > perform > > the conversion step and repeat. :( This is kind > of > > ugly and would at the very least require the > > conversion path to be cached. The caching isn't > > necessarily a bad idea anyway, but it still feels > very > > heavy. As does having separate interfaces and/or > > methods for Copiers vs. Converters. :( > > > > Matt B > > > > --- Matt Benson <gud...@ya...> wrote: > > > > > like > > > > ImpreciseTransformer.isImpreciseTransformation(Class > > > destinationType, Object source)? So that it > would > > > be > > > compatible w/ both Copiers and Converters. That > > > makes > > > sense... thanks! > > > > > > -Matt B > > > > > > --- Matt Sgarlata > > > <mat...@sp...> > > > wrote: > > > > > > > Perhaps it would make sense to change > > > > ImpreciseTransformer so that it > > > > operates on objects instead of classes? That > way > > > > you can give much more > > > > accurate results. For example, 3.0 (double) > is > > > > completely precise > > > > converting to the integer 3, whereas 3.01 -> > > > integer > > > > is not precise. > > > > > > > > Matt > > > > > > > > On Jan 30, 2008 10:15 AM, Matt Benson > > > > <gud...@ya...> wrote: > > > > > > > > > > > > > > --- Matt Sgarlata > > > > <mat...@sp...> > > > > > wrote: > > > > > > > > > > > To clarify, I am +0 on > ImpreciseTransformer. > > > I > > > > am > > > > > > -1 on > > > > > > PrecisionTransformer, but of course I am > all > > > > ears if > > > > > > you would like me to > > > > > > change my vote on that one ;) > > > > > > > > > > Hmm, I committed what I had for > > > > ImpreciseConverter, > > > > > refactored to ImpreciseTransformer. I began > to > > > > > implement ImpreciseTransformer for > > > > > PropertyNameMatchingCopier, with the idea > that > > > if > > > > > properties exist for the source object that > > > don't > > > > > exist on the destination object, then that > is > > > > > imprecise. The only problem is that > Reflectors > > > > work > > > > > on objects rather than classes. So I can't > > > tell > > > > this > > > > > info at the class level. Do you have any > > > > suggestions? > > > > > > > > > > -Matt B > > > > > > > > > > > > > > > > > > > > > > Matt > > > > > > > > > > > > On Jan 25, 2008 4:41 PM, Matt Sgarlata > > > > > > <mat...@sp...> > > > > > > wrote: > > > > > > > > > > > > > Oh boy, it's an Apache pop quiz! If I > > > > remember > > > > > > correctly, I am +0 to > > > > > > > indicate I support the feature's > addition, > > > but > > > > I > > > > > > do not plan on actively > > > > > > > working on it myself. > > > > > > > > > > > > > > Just to remind you, I believe I have > already > > > > fixed > > > > > > the issue that > > > > > > > ImpreciseTransformer is intended to > address > > > by > > > > > > ensuring order of components > > > > > > > is always maintained. However, I see no > > > > problem > > > > > > with having 2 alternative > > > > > > > solutions to the issue. > > > > > > > > > > > > > > Matt > > > > > > > > > > > > > > > > > > > > > On Jan 25, 2008 2:59 PM, Matt Benson > > > > > > <gud...@ya...> wrote: > > > > > > > > > > > > > > > Where did you end up on the > > > > ImpreciseTransformer > > > > > > idea? > > > > > > > > +1, -1, or +0? > > > > > > > > > > > > > > > > -Matt > > > > > > > > > > > > > > > > --- Matt Sgarlata > > > > > > <mat...@sp...> > > > > > > > > wrote: > > > > > > > > > > > > > > > > > I see what you mean. I prefer > > > > > > ImpreciseTransformer > > > > > > > > > to PrecisionTransformer > > > > > > > > > because of the difficulty of > assigning a > > > > > > numeric > > > > > > > > > value for the degree of > > > > > > > > > precision. I think that assignment > is > > > > going > > > > > > to end > > > > > > > > > up arbitrary and > > > > > > > > > confusing pretty quickly. > > > > > > ImpreciseTransformer also > > > > > > > > > would probably make the > > > > > > > > > logic for determining the conversion > > > path > > > > > > simpler. > > > > > > > > > > > > > > > > > > In terms of using different paths > for > > > > > > different > > > > > > > > > source and destination > > > > > > > > > combos, I think perhaps the best > > > solution > > > > in > > > > > > such a > > > > > > > > > case would be to just > > > > > > > > > make a bunch of individual > > > > AssemblerCopiers > > > > > > with > > > > > > > > > individual paths, and then > > > > > > > > > add them all together using the > > > > > > > > > SimpleDelegatingTransformer. > > > > > > > > > > > > > > > > > > Matt > > > > > > > > > > > > > > > > > > On Jan 10, 2008 12:14 PM, Matt > Benson > > > > > > > > > <gud...@ya...> wrote: > > > > > > > > > > > > > > > > > > > You have a point, though I guess > my > > > aim > > > > in > > > > > > > > > avoiding > > > > > > > > > > such a thing was > that--usually--the > > > path > > > > is > > > > > > simple > > > > > > > > > > enough to determine given source > and > > > > dest > > > > > > classes. > > > > > > > > > > Secondly, you might use a > different > > > path > > > > > > depending > > > > > > > > > on > > > > > > > > > > available source/dest combos, so > the > > > > > > configuration > > > > > > > > > > might be a little more complex. > :| > > > As > > > > for > > > > > > where > > > > > > > > > > converters with awareness of > > > "precision" > > > > > > might be > > > > > > > > > > useful, I can't say that I know of > > > > another > > > > > > context > > > > > > > > > > right now, but at the very least I > > > would > > > > say > > > > > > it > > > > > > > > > might > > > > > > > > > > be useful knowledge for both > number > > > and > > > > text > > > > > > > > > types. > > > > > > > > > > > > > > > > > > > > -Matt > > > > > > > > > > > > > > > > > > > > --- Matt Sgarlata > > > > > > > > > <mat...@sp...> > > > > > > > > > > wrote: > > > > > > > > > > > > > > > > > > > > > I agree, that does sound like it > > > could > > > > end > > > > > > up > > > > > > > > > being > > > > > > > > > > > somewhat arbitrary. I > > > > > > > > > > > know the original impetus for > this > > > was > > > > > > that > > > > > > > > > > > configuration of the > > > > > > > > > > > ChainedTransformer could be a > real > > > > pain in > > > > > > the > > > > > > > > > neck. > > > > > > > > > > > Are there other > > > > > > > > > > > situations where the information > > > > provided > > > > > > by > > > > > > > > > > > ImplicitTransformer or > > > > > > > > > > > PrecisionTransformer might be > > > useful? > > > > I > > > > > > guess > > > > > > > > > what > > > > > > > > > > > I'm getting at here is, > > > > > > > > > > > what is the requirement we are > > > trying > > > > to > > > > > > solve? > > > > > > > > > > > Perhaps if we think about > > > > > > > > > > > it in a new way a different > solution > > > > will > > > > > > > > > present > > > > > > > > > > > itself. > > > > > > > > > > > > > > > > > > > > > > Perhaps an alternative could be > to > > > > > > introduce a > > > > > > > > > new > > > > > > > > > > > setTransformationPath(Class[] > path) > > > > method > > > > > > to > > > > > > > > > the > > > > > > > > > > > ChainedTransformer. That > > > > > > > > > > > would make configuration a snap, > > > even > > > > if > > > > > > you > > > > > > > > > were > > > > > > > > > > > trying to use dependency > > > > > > > > > > > injection for the configuration. > > > > > > > > > > > > > > > > > > > > > > Matt S > > > > > > > > > > > > > > > > > > > > > > On Jan 10, 2008 11:24 AM, Matt > > > Benson > > > > > > > > > > > <gud...@ya...> wrote: > > > > > > > > > > > > > > > > > > > > > > > More on this: what do you > think > > > > about > > > > > > the > > > > > > > > > concept > > > > > > > > > > > of > > > > > > > > > > > > something like a > > > > PrecisionTransformer > > > > > > that > > > > > > > > > returns > > > > > > > > > > > a > > > > > > > > > > > > float precision from 0.0 to > 1.0 > > > > given a > > > > > > > > > > > > destinationClass and a > > > sourceClass? > > > > > > These > > > > > > > > > might > > > > > > > > > > > be > > > > > > > > > > > > somewhat arbitrary, or > calculated > > > > (like > > > > > > with > > > > > > > > > > > numeric > > > > > > > > > > > > types), but they might allow a > > > > little > > > > > > more > > > > > > > > > > > > informedness on the part of > the > > > > > > consumer. > > > > > > > > > > > > > > > > > > > > > > > > -Matt B > > > > > > > > > > > > > > > > > > > > > > > > --- Matt Benson > > > > <gud...@ya...> > > > > > > wrote: > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > --- Matt Sgarlata > > > > > > > > > > > > > > > > > <mat...@sp...> > > > > > > > > > > > > > wrote: > > > > > > > > > > > > > > > > > > > > > > > > > > > I have been thinking more > > > about > > > > this > > > > > > > > > approach, > > > > > > > > > > > and > > > > > > > > > > > > > > it's really starting to > > > > > > > > > > > > > > grow on me. I do have one > > > > concern > > > > > > though, > > > > > > > > > can > > > > > > > > > > > > > this > > > > > > > > > > > > > > approach be extended to > > > > > > > > > > > > > > Copiers? For example, a > Map > > > -> > > > > > > Object > > > > > > > > > copy > > > > > > > > > > > could > > > > > > > > > > > > > > probably be considered an > > > > > > > > > > > > > > imprecise transformation > > > because > > > > the > > > > > > Map > > > > > > > > > may > > > > > > > > > > > have > > > > > > > > > > > > > > more keys than the Object > > > > > > > > > > > > > > has properties. > > > > > > > > > > > > > > > > > > > > > > > > > > I thought about this as > well. > > > It > > > > > > could be > > > > > > > > > done; > > > > > > > > > > > it > > > > > > > > > > > > > might be slightly complex > > > > calculating > > > > > > the > > > > > > > > > > > > > "precision" > > > > > > > > > > > > > of a > > > PropertyNameMatchingCopier--I > > > > > > would > > > > > > > > > think > > > > > > > > > > > an > > > > > > > > > > > > > explicitly specified > PNMatchingC > > > > would > > > > > > be > > > > > > > > > > > precise; > > > > > > > > > > > > > an > > > > > > > > > > > > > imprecise one would be one > using > > > > > > property > > > > > > > > > name > > > > > > > > > > > > > discovery and where the > > > properties > > > > of > > > > > > the > > > > > > > > > source > > > > > > > > > > > are > > > > > > > > > > > > > not all available on the > > > > destination. > > > > > > > > > > > There--the > > > > > > > > > > > > > hard > > > > > > > > > > > > > part of that one is over. > :) I > > > > will > > > > > > work > > > > > > > > > on > > > > > > > > > > > > > ImpreciseConverter -> > > > > > > ImpreciseTransformer > > > > > > > > > > > extends > > > > > > > > > > > > > Transformer and other > semantic > > > > changes > > > > > > as > > > > > > > > > time > > > > > > > > > > > > > permits. Your ordering > changes > > > > are, I > > > > > > > > > expect, > > > > > > > > > > > fine > > > > > > > > > > > > > by > > > > > > > > > > > > > me as well. :) > > > > > > > > > > > > > > > > > > > > > > > > > > -Matt B > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > In addition to your > approach, > > > I > > > > also > > > > > > like > > > > > > > > > the > > > > > > > > > > > idea > > > > > > > > > > > > > > of cleaning up the > > > > > > > > > > > > > > internal implementation in > > > Morph > > > > so > > > > > > that > > > > > > > > > > > ordering > > > > > > > > > > > > > of > > > > > > > > > > > > > > source and destination > > > > > > > > > > > > > > classes is preserved for > the > > > > > > following > > > > > > > > > > > reasons: > > > > > > > > > > > > > > 1) for at least some > portion > > > of > > > > > > users, > > > > > > > > > setting > > > > > > > > > > > the > > > > > > > > > > > > > > order of source and > > > > > > > > > > > > > > destination classes will > make > > > > sense > > > > > > as an > > > > > > > > > > > > > indication > > > > > > > > > > > > > > of the transformer's > > > > > > > > > > > > > > preferences for performing > > > > > > transformations > > > > > > > > > (so > > > > > > > > > > > for > > > > > > > > > > > > > > this class of users, > > > > > > > > > > > > > > creating new transformers > that > > > > play > > > > > > nicely > > > > > > > > > > > with > > > > > > > > > > > > > the > > > > > > > > > > > > > > ChainedTransformerTestCase > > > will > > > > be > > > > > > > > > simpler) > > > > > > > > > > > > > > 2) I think a general > change > > > from > > > > > > using > > > > > > > > > > > HashSets to > > > > > > > > > > > > > > ordered sets in Morph's > > > > > > > > > > > > > > implementation will mean > > > > > > transformations > > > > > > > > > > > happen > > > > > > > > > > > > > more > > > > > > > > > > > > > > consistently across > > > > > > > > > > > > > > JVMs and across time on > the > > > same > > > > > > JVM, > > > > > > > > > leading > > > > > > > > > > > to a > > > > > > > > > > > > > > more stable platform > > > > > > > > > > > > > > > > > > > > > > > > > > > > So, what I did is I > basically > > > > went > > > > > > through > > > > > > > > > the > > > > > > > > > > > > > Morph > > > > > > > > > > > > > > codebase and replaced > > > > > > > > > > > > > > HashSets with ordered sets > > > > > > (preference > > > > > > > > > order > > > > > > > > > > > is: > > > > > > > > > > > > > JDK > > > > > > > > > > > > > > 1.4 LinkedHashSet, > > > > > > > > > > > > > > Commons-collections > > > > ListOrderedSet, > > > > > > copy > > > > > > > > > of > > > > > > > > > > > > > > ListOrderedSet in > > > > > > > > > > > > > > net.sf.morph.util). I was > > > never > > > > > > able to > > > > > > > > > > > modify > > > > > > > > > > > > > the > > > > > > > > > > > > > > ChainedTransformerTestCase > so > > > > that > > > > > > it > > > > > > > > > > > consistently > > > > > > > > > > > > > > threw an error. However, > > > > > > > > > > > > > > after working on the test > case > > > > long > > > > > > > > > enough, > > > > > > > > > > > > > > eventually something > changed > > > in > > > > > > > > > > > > > > my environment so that the > > > test > > > > > > started to > > > > > > > > > > > fail. > > > > > > > > > > > > > I > > > > > > > > > > > > > > did my change of > > > > > > > > > > > > > > HashSets to ordered sets, > and > > > > that > > > > > > was > > > > > > > > > able to > > > > > > > > > > > fix > > > > > > > > > > > > > > the broken test. > > > > > > > > > > > > > > > > > > > > > > > > > > > > I checked in my changes > for > > > you > > > > to > > > > > > take a > > > > > > > > > look > > > > > > > > > > > > > at... > > > > > > > > > > > > > > > > > > > > > > > > > > > > Matt S > > > > > > > > > > > > > > > > > > > > > > > > > > > > On Jan 6, 2008 12:59 PM, > Matt > > > > Benson > > > > > > > > > > > > > > <gud...@ya...> > wrote: > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Here's what I've got. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > -Matt B > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > ____________________________________________________________________________________ > > > > > > > > > > > > > > > Be a better friend, > > > newshound, > > > > and > > > > > > > > > > > > > > > know-it-all with Yahoo! > > > > Mobile. > > > > > > Try it > > > > > > > > > now. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Index: > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > src/core/net/sf/morph/transform/transformers/SimpleDelegatingTransformer.java > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > =================================================================== > > > > > > > > > > > > > > > --- > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > src/core/net/sf/morph/transform/transformers/SimpleDelegatingTransformer.java > > > > > > > > > > > > > > > (revision 357) > > > > > > > > > > > > > > > +++ > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > src/core/net/sf/morph/transform/transformers/SimpleDelegatingTransformer.java > > > > > > > > > > > > > > > (working copy) > > > > > > > > > > > > > > > @@ -1,5 +1,5 @@ > > > > > > > > > > > > > > > /* > > > > > > > > > > > > > > > - * Copyright 2004-2005, > > > 2007 > > > > the > > > > > > > > > original > > > > > > > > > > > > > author > > > > > > > > > > > > > > or authors. > > > > > > > > > > > > > > > + * Copyright 2004-2005, > > > > 2007-2008 > > > > > > the > > > > > > > > > > > original > > > > > > > > > > > > > > author or authors. > > > > > > > > > > > > > > > * > > > > > > > > > > > > > > > * Licensed under the > Apache > > > > > > License, > > > > > > > > > > > Version > > > > > > > > > > > > > 2.0 > > > > > > > > > > > > > > (the "License"); you may > > > > > > > > > > > > > > > not > > > > > > > > > > > > > > > * use this file except > in > > > > > > compliance > > > > > > > > > with > > > > > > > > > > > the > > > > > > > > > > > > > > License. You may obtain a > > > > > > > > > > > > > > > copy of > > > > > > > > > > > > > > > @@ -35,6 +35,7 @@ > > > > > > > > > > > > > > > import > > > > > > > > > > > > > > > > > > > net.sf.morph.transform.DecoratedConverter; > > > > > > > > > > > > > > > import > > > > > > > > > > > > > > > net.sf.morph.transform.DecoratedCopier; > > > > > > > > > > > > > > > import > > > > > > > > > > > > > > > > > > > > > > > > > > > net.sf.morph.transform.ExplicitTransformer; > > > > > > > > > > > > > > > +import > > > > > > > > > > > > > > > > > > > net.sf.morph.transform.ImpreciseConverter; > > > > > > > > > > > > > > > import > > > > > > > > > net.sf.morph.transform.NodeCopier; > > > > > > > > > > > > > > > import > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > net.sf.morph.transform.TransformationException; > > > > > > > > > > > > > > > import > > > > > > > > > net.sf.morph.transform.Transformer; > > > > > > > > > > > > > > > @@ -93,11 +94,11 @@ > > > > > > > > > > > > > > > * @since Dec 12, 2004 > > > > > > > > > > > > > > > */ > > > > > > > > > > > > > > > public class > > > > > > > > > SimpleDelegatingTransformer > > > > > > > > > > > > > extends > > > > > > > > > > > > > > BaseCompositeTransformer > > > > > > > > > > > > > > > implements > > > > > > > > > > > > > > > - > > > > SpecializableComposite, > > > > > > > > > > > > > > ExplicitTransformer, > > > > Transformer, > > > > > > > > > > > > > > > DecoratedCopier, > > > > > > DecoratedConverter, > > > > > > > > > > > Cloneable { > > > > > > > > > > > > > > > + > > > > > > SpecializableComposite, > > > > > > > > > > > > > > ExplicitTransformer, > > > > Transformer, > > > > > > > > > > > > > > > DecoratedCopier, > > > > > > > > > > > > > > > + > > > > > > DecoratedConverter, > > > > > > > > > > > Cloneable, > > > > > > > > > > > > > > ImpreciseConverter { > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > //TODO extract > > > > > > > > > > > BaseDelegatingTransformer > > > > > > > > > > > > > > with pluggable delegate > > > > > > > > > > > > > > > selection > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > - > > > > > > > > > > > > > > > private static > class > > > > > > > > > MapThreadLocal > > > > > > > > > > > > > extends > > > > > > > > > > > > > > ThreadLocal { > > > > > > > > > > > > > > > protected > > > > Object > > > > > > > > > > > initialValue() { > > > > > > > > > > > > > > > > > > return > > > > new > > > > > > > > > HashMap(); > > > > > > > > > > > > > > > @@ -138,6 +139,7 @@ > > > > > > > > > > > > > > > } > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > private > Specializer > > > > > > specializer; > > > > > > > > > > > > > > > + private boolean > > > > > > > > > > > > > preferPreciseTransformers; > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > private transient > > > > > > ThreadLocal > > > > > > > > > > > > > > > > > > > > > visitedSourceToDestinationMapThreadLocal > > > > > > > > > = > > > > > > > > > > > new > > > > > > > > > > > > > > MapThreadLocal(); > > > > > > > > > > > > > > > private transient > > > > > > ThreadLocal > > > > > > > > > > > > > > stackDepthThreadLocal = > new > > > > > > > > > > > > > > > StackDepthThreadLocal(); > > > > > > > > > > > > > > > @@ -225,6 +227,14 @@ > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > /** > > > > > > > > > > > > > > > * {@inheritDoc} > > > > > > > > > > > > > > > + */ > > > > > > > > > > > > > > > + protected > boolean > > > > > > > > > > > > > > > > > isImpreciseConversionImpl(Class > > > > > > > > > > > > > > > destinationClass, Class > > > > > > sourceClass) { > > > > > > > > > > > > > > > + return > > > > > > > > > > > > > > > > > > > > TransformerUtils.isImpreciseConversion > > > > > > > > > > > > > > > > > > > (getTransformer(destinationClass, > > > > > > > > > > > > > > > + > > > > > > > > > > > sourceClass), > > > > > > > > > > > > > > destinationClass, > > > > > > > > > > > > > > > sourceClass); > > > > > > > > > > > > > > > + } > > > > > > > > > > > > > > > + > > > > > > > > > > > > > > > + /** > > > > > > > > > > > > > > > + * {@inheritDoc} > > > > > > > > > > > > > > > * @see > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > net.sf.morph.transform.transformers.BaseTransformer#getSourceClassesImpl > > > > > > > > () > > > > > > > > > > > > > > > */ > > > > > > > > > > > > > > > protected Class[] > > > > > > > > > > > getSourceClassesImpl() > > > > > > > > > > > > > > throws Exception { > > > > > > > > > > > > > > > @@ -477,6 +487,7 @@ > > > > > > > > > > > > > > > * if > no > > > > > > suitable > > > > > > > > > > > transformer > > > > > > > > > > > > > > could be found > > > > > > > > > > > > > > > */ > > > > > > > > > > > > > > > private > Transformer > > > > > > > > > > > getTransformer(Class > > > > > > > > > > > > > > transformerType, Class > > > > > > > > > > > > > > > destinationClass, Class > > > > > > sourceClass) > > > > > > > > > throws > > > > > > > > > > > > > > TransformationException { > > > > > > > > > > > > > > > + > Transformer > > > > > > candidate = > > > > > > > > > > > null; > > > > > > > > > > > > > > > for (int > i = > > > 0; > > > > i < > > > > > > > > > > > > > > components.length; i++) { > > > > > > > > > > > > > > > > // if > > > > the > > > > > > > > > transformer > > > > > > > > > > > is > > > > > > > > > > > > > > the correct type > > > > > > > > > > > > > > > > > > > Transformer > > > > > > > > > > > transformer = > > > > > > > > > > > > > > (Transformer) > > > > > > > > > > > > > > > components[i]; > > > > > > > > > > > > > > > @@ -484,6 +495,13 @@ > > > > > > > > > > > > > > > > > > > > > > // > > > > > > if the > > > > > > > > > > > > > > transformer is capable of > > > > > > > > > > > > > > > performing the > > > transformation > > > > > > > > > > > > > > > > > > > > > > if > > > > > > > > > > > > > > > > > > (TransformerUtils.isTransformable( > > > > > > > > > > > > > > > > > > > > > > > > > > > > > transformer, > > > > > > > > > > > > > > > destinationClass, > > > > sourceClass)) { > > > > > > > > > > > > > > > + > > > > > > > > > if > > > > > > > > > > > > > > > (isPreferPreciseTransformers() > > > > > > > > > > > > > > > + > > > > > > > > > > > > > > > > > > > > > > > > > > > && candidate == > > > > > > > > > > > > > > > null > > > > > > > > > > > > > > > + > > > > > > > > > > > > > > > > > > > > > > > > > > > && > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > TransformerUtils.isImpreciseConversion(transformer, > > > > > > > > > > > > > > > + > > > > > > > > > > > > > > > destinationClass, > > > > sourceClass)) { > > > > > > > > > > > > > > > + > > > > > > > > > > > > > > candidate = transformer; > > > > > > > > > > > > > > > + > > > > > > > > > > > > > > continue; > > > > > > > > > > > > > > > + > > > > > > > > > } > > > > > > > > > > > > > > > > > > > > > > > > if > > > > > > > > > > > > > > > (getLog().isTraceEnabled()) { > > > > > > > > > > > > > > > > > > > > > > > > > > > > > getLog().trace("Using " > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > + > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > ClassUtils.getUnqualifiedClassName(transformerType) > > > > > > > > > > > > > > > @@ -496,7 +514,9 @@ > > > > > > > > > > > > > > > > > > > > > > > > > > return > > > > > > > > > > > > > > transformer; > > > > > > > > > > > > > > > > > > > > > > } > > > > > > > > > > > > > > > } > > > > > > > > > > > > > > > - > > > > > > > > > > > > > > > + > if > > > > > > (candidate != > > > > > > > > > > > null) { > > > > > > > > > > > > > > > + > > > > > > return > > > > > > > > > > > > > candidate; > > > > > > > > > > > > > > > + > } > > > > > > > > > > > > > > > } > > > > > > > > > > > > > > > throw new > > > > > > > > > > > > > TransformationException( > > > > > > > > > > > > > > > > > > "Could > > > > not > > > > > > find a > > > > > > > > > > > > > > transformer that can > transform > > > > > > > > > > > > > > > objects of " > > > > > > > > > > > > > > > @@ -612,4 +632,20 @@ > > > > > > > > > > > > > > > > > > > > > source); > > > > > > > > > > > > > > > } > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > + /** > > > > > > > > > > > > > > > + * Get the > > > > > > > > > > > preferPreciseTransformers. > > > > > > > > > > > > > > > + * @return > boolean > > > > > > > > > > > > > > > + */ > > > > > > > > > > > > > > > + public boolean > > > > > > > > > > > > > > > isPreferPreciseTransformers() > > > { > > > > > > > > > > > > > > > + return > > > > > > > > > > > > > preferPreciseTransformers; > > > > > > > > > > > > > > > + } > > > > > > > > > > > > > > > + > > > > > > > > > > > > > > > + /** > > > > > > > > > > > > > > > + * Set the > > > > > > > > > > > preferPreciseTransformers. > > > > > > > > > > > > > > Default false. > > > > > > > > > > > > > > > + * @param > > > > > > > > > preferPreciseTransformers > > > > > > > > > > > the > > > > > > > > > > > > > > boolean to set > > > > > > > > > > > > > > > + */ > > > > > > > > > > > > > > > + public void > > > > > > > > > > > > > > > > > > setPreferPreciseTransformers(boolean > > > > > > > > > > > > > > > > preferPreciseTransformers) { > > > > > > > > > > > > > > > + > > > > > > > > > > > this.preferPreciseTransformers = > > > > > > > > > > > > > > > > preferPreciseTransformers; > > > > > > > > > > > > > > > + } > > > > > > > > > > > > > > > + > > > > > > > > > > > > > > > } > > > > > > > > > > > > > > > \ No newline at end of > file > > > > > > > > > > > > > > > Index: > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > src/core/net/sf/morph/transform/transformers/BaseTransformer.java > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > =================================================================== > > > > > > > > > > > > > > > --- > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > src/core/net/sf/morph/transform/transformers/BaseTransformer.java > > > > > > > > > > > > > > > (revision 358) > > > > > > > > > > > > > > > +++ > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > src/core/net/sf/morph/transform/transformers/BaseTransformer.java > > > > > > > > > > > > > > > (working copy) > > > > > > > > > > > > > > > @@ -570,6 +570,35 @@ > > > > > > > > > > > > > > > } > > > > > > > > > > > > > > > } > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > + /** > > > > > > > > > > > > > > > + * > Implementation of > > > > > > > > > > > > > isImpreciseConversion > > > > > > > > > > > > > > > + * @param > > > > destinationClass > > > > > > > > > > > > > > > + * @param > > > sourceClass > > > > > > > > > > > > > > > + * @return > > > > > > > > > > > > > > > + */ > > > > > > > > > > > > > > > + protected > boolean > > > > > > > > > > > > > > > > > isImpreciseConversionImpl(Class > > > > > > > > > > > > > > > destinationClass, Class > > > > > > sourceClass) { > > > > > > > > > > > > > > > + return > > > > > > destinationClass > > > > > > > > > == > > > > > > > > > > > null > > > > > > > > > > > > > && > > > > > > > > > > > > > > sourceClass != null; > > > > > > > > > > > > > > > + } > > > > > > > > > > > > > > > + > > > > > > > > > > > > > > > + /** > > > > > > > > > > > > > > > + * Learn whether > the > > > > > > specified > > > > > > > > > > > > > conversion > > > > > > > > > > > > > > yields an imprecise > > > > > > > > > > > > > > > result. > > > > > > > > > > > > > > > + * @param > > > > destinationClass > > > > > > > > > > > > > > > + * @param > > > sourceClass > > > > > > > > > > > > > > > + * @return > boolean > > > > > > > > > > > > > > > + */ > > > > > > > > > > > > > > > + public final > boolean > > > > > > > > > > > > > > > isImpreciseConversion(Class > > > > > > > > > destinationClass, > > > > > > > > > > > > > > > Class sourceClass) { > > > > > > > > > > > > > > > + try { > > > > > > > > > > > > > > > + > > > return > > > > > > > > > > > > > > > > > > > > > > > > > > > isImpreciseConversionImpl(destinationClass, > > > > > > > > > > > > > > > sourceClass); > > > > > > > > > > > > > > > + } catch > > > > (Exception > > > > > > e) { > > > > > > > > > > > > > > > + > if > > > (e > > > > > > instanceof > > > > > > > > > > > > > > RuntimeException && > > > > > > > > > > > > > > > > > > > !isWrappingRuntimeExceptions()) { > > > > > > > > > > > > > > > + > > > > > > throw > > > > > > > > > > > > > > (RuntimeException) e; > > > > > > > > > > > > > > > + > } > > > > > > > > > > > > > > > + > > > throw > > > > new > > > > > > > > > > > > > > > TransformationException("Could > > > > not > > > > > > > > > > > > > > > determine if conversion > of " > > > > > > > > > > > > > > > + > > > > > > > > > + > > > > > > > > > > > > > > sourceClass + " to " + > > > > > > > > > > > > > > > destinationClass > > > > > > > > > > > > > > > + > > > > > > > > > + " > > > > > > > > > > > > > > results in a loss of > > > > > > > > > > > > > > > precision", e); > > > > > > > > > > > > > > > + } > > > > > > > > > > > > > > > + } > > > > > > > > > > > > > > > + > > > > > > > > > > > > > > > // property getters and > > > > setters > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > /** > > > > > > > > > > > > > > > Index: > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > src/core/net/sf/morph/transform/transformers/ChainedTransformer.java > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > =================================================================== > > > > > > > > > > > > > > > --- > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > src/core/net/sf/morph/transform/transformers/ChainedTransformer.java > > > > > > > > > > > > > > > (revision 357) > > > > > > > > > > > > > > > +++ > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > src/core/net/sf/morph/transform/transformers/ChainedTransformer.java > > > > > > > > > > > > > > > (working copy) > > > > > > > > > > > > > > > @@ -1,5 +1,5 @@ > > > > > > > > > > > > > > > /* > > > > > > > > > > > > > > > - * Copyright 2004-2005, > > > 2007 > > > > the > > > > > > > > > original > > > > > > > > > > > > > author > > > > > > > > > > > > > > or authors. > > > > > > > > > > > > > > > + * Copyright 2004-2005, > > > > 2007-2008 > > > > > > the > > > > > > > > > > > original > > > > > > > > > > > > > > author or authors. > > > > > > > > > > > > > > > * > > > > > > > > > > > > > > > * Licensed under the > Apache > > > > > > License, > > > > > > > > > > > Version > > > > > > > > > > > > > 2.0 > > > > > > > > > > > > > > (the "License"); you may > > > > > > > > > > > > > > > not > > > > > > > > > > > > > > > * use this file except > in > > > > > > compliance > > > > > > > > > with > > > > > > > > > > > the > > > > > > > > > > > > > > License. You may obtain a > > > > > > > > > > > > > > > copy of > > > > > > > > > > > > > > > @@ -16,6 +16,7 @@ > > > > > > > > > > > > > > > package > > > > > > > > > > > > net.sf.morph.transform.transformers; > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > import > java.util.ArrayList; > > > > > > > > > > > > > > > +import > java.util.Iterator; > > > > > > > > > > > > > > > import java.util.List; > > > > > > > > > > > > > > > import > java.util.Locale; > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > @@ -25,6 +26,7 @@ > > > > > > > > > > > > > > > import > > > > > > > > > > > > > > > > > > > net.sf.morph.transform.DecoratedConverter; > > > > > > > > > > > > > > > import > > > > > > > > > > > > > > > net.sf.morph.transform.DecoratedCopier; > > > > > > > > > > > > > > > import > > > > > > > > > > > > > > > > > > > > > > > > > > > net.sf.morph.transform.ExplicitTransformer; > > > > > > > > > > > > > > > +import > > > > > > > > > > > > > > > > > > > net.sf.morph.transform.ImpreciseConverter; > > > > > > > > > > > > > > > import > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > net.sf.morph.transform.TransformationException; > > > > > > > > > > > > > > > import > > > > > > > > > net.sf.morph.transform.Transformer; > > > > > > > > > > > > > > > import > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > net.sf.morph.transform.copiers.CopierDecorator; > > > > > > > > > > > > > > > @@ -40,7 +42,7 @@ > > > > > > > > > > > > > > > * @since Nov 24, 2004 > > > > > > > > > > > > > > > */ > > > > > > > > > > > > > > > public class > > > > ChainedTransformer > > > > > > extends > > > > > > > > > > > > > > BaseCompositeTransformer > > > > > > > > > > > > > > > implements > > > > > > > > > > > > > > > - > > > > > > DecoratedConverter, > > > > > > > > > > > > > > DecoratedCopier, > > > > ExplicitTransformer > > > > > > { > > > > > > > > > > > > > > > + > > > > > > DecoratedConverter, > > > > > > > > > > > > > > DecoratedCopier, > > > > > > ExplicitTransformer, > > > > > > > > > > > > > > > ImpreciseConverter { > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > private Converter > > > > > > copyConverter; > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > @@ -67,6 +69,14 @@ > > > > > > > > > > > > > > > } > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > /** > > > > > > > > > > > > > > > + * {@inheritDoc} > > > > > > > > > > > > > > > + */ > > > > > > > > > > > > > > > + protected > boolean > > > > > > > > > > > > > > > > > isImpreciseConversionImpl(Class > > > > > > > > > > > > > > > destinationClass, Class > > > > > > sourceClass) { > > > > > > > > > > > > > > > + List > > > > > > conversionPath = > > > > > > > > > > > > > > > > > > getConversionPath(destinationClass, > > > > > > > > > > > > > > > sourceClass); > > > > > > > > > > > > > > > + return > > > > > > > > > > > > > !isPrecise(conversionPath, > > > > > > > > > > > > > > sourceClass, 0); > > > > > > > > > > > > > > > + } > > > > > > > > > > > > > > > + > > > > > > > > > > > > > > > + /** > > > > > > > > > > > > > > > * Get the > converter > > > > used > > > > > > when > > > > > > > > > using > > > > > > > > > > > a > > > > > > > > > > > > > > ChainedTransformer as a > > > > > > > > > > > > > > > Copier. > > > > > > > > > > > > > > > * @return > > > > > > > > > > > > > > > */ > > > > > > > > > > > > > > > @@ -113,6 +123,7 @@ > > > > > > > > > > > > > > > > throw > > > > new > > > > > > > > > > > > > > > > > > > > TransformationException(destinationClass, > > > > > > > > > > > > > > > sourceType, null, > > > > > > > > > > > > > > > > > > > > > > > > > > "Chained > > > > > > > > > > > > > > conversion path could not > > > > > > > > > > > > > > > be determined"); > > > > > > > > > > > > > > > } > > > > > > > > > > > > > > > + > > > > log.debug("Using > > > > > > chained > > > > > > > > > > > > > > conversion path " + > > > > > > > > > > > > > > > conversionPath); > > > > > > > > > > > > > > > Object o > = > > > > source; > > > > > > > > > > > > > > > for (int > i = > > > 0; > > > > i < > > > > > > > > > > > > > > conversionPath.size(); > i++) { > > > > > > > > > > > > > > > o > = > > > > > > > > > > > > > > > > > > > > getConverter(chain[i]).convert((Class) > > > > > > > > > > > > > > > conversionPath.get(i), > o, > > > > locale); > > > > > > > > > > > > > > > @@ -144,6 +155,7 @@ > > > > > > > > > > > > > > > > throw > > > > new > > > > > > > > > > > > > > > > > > > > TransformationException(destinationClass, > > > > > > > > > > > > > > > source, null, > > > > > > > > > > > > > > > > > > > > > > > > > > "Chained > > > > > > > > > > > > > > conversion path could not > > > > > > > > > > > > > > > be determined"); > > > > > > > > > > > > > > > } > > > > > > > > > > > > > > > + > > > > log.debug("Using > > > > > > chained > > > > > > > > > > > > > > conversion path " + > > > > > > > > > > > > > > > conversionPath); > > > > > > > > > > > > > > > Object > last = > > > > > > > > > > > > > > > > > > getCopyConverter().convert((Class) > > > > > > > > > > > > > > > > > > > conversionPath.get(chain.length - > > > > > > 2), > > > > > > > > > > > source, > > > > > > > > > > > > > > locale); > > > > > > > > > > > > > > > ((Copier) > > > > > > > > > > > > > copier).copy(destination, > > > > > > > > > > > > > > last, locale); > > > > > > > > > > > > > > > } > > > > > > > > > > > > > > > @@ -192,13 +204,7 @@ > > > > > > > > > > > > > > > * @return List > > > > > > > > > > > > > > > */ > > > > > > > > > > > > > > > protected List > > > > > > > > > > > getConversionPath(Class > > > > > > > > > > > > > > destinationType, Class > > > > > > > > > > > > > > > sourceType) { > > > > > > > > > > > > > > > - if > > > (sourceType > > > > != > > > > > > null) > > > > > > > > > { > > > > > > > > > > > > > > > - > List > > > > > > withoutNull > > > > > > > > > = > > > > > > > > > > > > > > > > > > > getConversionPath(destinationType, > > > > > > > > > > > sourceType, > > > > > > > > > > > > > 0, > > > > > > > > > > > > > > false); > > > > > > > > > > > > > > > - > if > > > > > > (withoutNull > > > > > > > > > != > > > > > > > > > > > null) > > > > > > > > > > > > > { > > > > > > > > > > > > > > > - > > > > > > return > > > > > > > > > > > > > > withoutNull; > > > > > > > > > > > > > > > - > } > > > > > > > > > > > > > > > - } > > > > > > > > > > > > > > > - return > > > > > > > > > > > > > > > > > > getConversionPath(destinationType, > > > > > > > > > sourceType, > > > > > > > > > > > 0, > > > > > > > > > > > > > > > true); > > > > > > > > > > > > > > > + return > > > > > > > > > > > > > > > > > > getConversionPath(destinationType, > > > > > > > > > sourceType, > > > > > > > > > > > 0); > > > > > > > > > > > > > > > } > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > /** > > > > > > > > > > > > > > > @@ -210,7 +216,7 @@ > > > > > > > > > > > > > > > * @param > allowNull > > > > > > > > > > > > > > > * @return List > > > > > > > > > > > > > > > */ > > > > > > > > > > > > > > > - private List > > > > > > > > > getConversionPath(Class > > > > > > > > > > > > > > destinationType, Class > > > > > > > > > > > > > > > sourceType, int index, > > > boolean > > > > > > > > > allowNull) { > > > > > > > > > > > > > > > + private List > > > > > > > > > getConversionPath(Class > > > > > > > > > > > > > > destinationType, Class > > > > > > > > > > > > > > > sourceType, int index) { > > > > > > > > > > > > > > > > Transformer[] > > > > chain > > > > > > = > > > > > > > > > > > getChain(); > > > > > > > > > > > > > > > > Transformer c > > > = > > > > > > > > > chain[index]; > > > > > > > > > > > > > > > if (index > + 1 > > > > == > > > > > > > > > > > chain.length) { > > > > > > > > > > > > > > > @@ -221,22 +227,38 @@ > > > > > > > > > > > > > > > } > > > > > > > > > > > > > > > > > > return > > > > > > null; > > > > > > > > > > > > > > > } > > > > > > > > > > > > > > > + List > > > > > > possibleResult = > > > > > > > > > null; > > > > > > > > > > > > > > > Class[] > > > > available = > > > > > > > > > > > > > > c.getDestinationClasses(); > > > > > > > > > > > > > > > for (int > i = > > > 0; > > > > i < > > > > > > > > > > > > > > available.length; i++) { > > > > > > > > > > > > > > > - > if > > > > > > (available[i] > > > > > > > > > == > > > > > > > > > > > null > > > > > > > > > > > > > > && !allowNull) { > > > > > > > > > > > > > > > - > > > > > > > > > continue; > > > > > > > > > > > > > > > - > } > > > > > > > > > > > > > > > > if > > > > > > > > > > > > > > > > > > (TransformerUtils.isTransformable(c, > > > > > > > > > > > > > > > available[i], > sourceType)) { > > > > > > > > > > > > > > > - > > > > > > List > > > > > > > > > tail = > > > > > > > > > > > > > > > > > > > getConversionPath(destinationType, > > > > > > > > > > > available[i], > > > > > > > > > > > > > > index + 1, allowNull); > > > > > > > > > > > > > > > + > > > > > > List > > > > > > > > > tail = > > > > > > > > > > > > > > > > > > > getConversionPath(destinationType, > > > > > > > > > > > available[i], > > > > > > > > > > > > > > index + 1); > > > > > > > > > > > > > > > > > > > > > > if > > > > > > (tail > > > > > > > > > != > > > > > > > > > > > null) > > > > > > > > > > > > > { > > > > > > > > > > > > > > > > > > > > > > > > > > > > tail.add(0, > > > > > > > > > > > > > > available[i]); > > > > > > > > > > > > > > > - > > > > > > > > > > > return > > > > > > > > > > > > > > tail; > > > > > > > > > > > > > > > + > > > > > > > > > if > > > > > > > > > > > > > > (isPrecise(tail, > sourceType, > > > > > > > > > > > > > > > index)) { > > > > > > > > > > > > > > > + > > > > > > > > > > > > > > return tail; > > > > > > > > > > > > > > > + > > > > > > > > > } > > > > > > > > > > > > > > > + > > > > > > > > > > > > > > possibleResult = tail; > > > > > > > > > > > > > > > > > > > > > > } > > > > > > > > > > > > > > > } > > > > > > > > > > > > > > > } > > > > > > > > > > > > > > > - return > null; > > > > > > > > > > > > > > > + return > > > > > > possibleResult; > > > > > > > > > > > > > > > } > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > + private boolean > > > > > > isPrecise(List > > > > > > > > > > > > > > conversionPath, Class > > > > sourceType, > > > > > > > > > > > > > > > int index) { > > > > > > > > > > > > > > > + > > > Transformer[] > > > > > > chain = > > > > > > > > > > > > > getChain(); > > > > > > > > > > > > > > > + Class > > > > > > currentSource = > > > > > > > > > > > > > sourceType; > > > > > > > > > > > > > > > + int i = > 0; > > > > > > > > > > > > > > > + for > > > (Iterator > > > > iter > > > > > > = > > > > > > > > > > > > > > conversionPath.iterator(); > > > > > > > > > > > > > > > iter.hasNext(); i++) { > > > > > > > > > > > > > > > + > > > Class > > > > > > > > > currentDest = > > > > > > > > > > > > > > (Class) iter.next(); > > > > > > > > > > > > > > > + > if > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > (TransformerUtils.isImpreciseConversion(chain[index > > > > > > > > > > > > > > > + i], currentDest, > > > > > > > > > > > > > > > + > > > > > > > > > > > > > > currentSource)) { > > > > > > > > > > > > > > > + > > > > > > return > > > > > > > > > > > false; > > > > > > > > > > > > > > > + > } > > > > > > > > > > > > > > > + > > > > > > currentSource = > > > > > > > > > > > > > > currentDest; > > > > > > > > > > > > > > > + } > > > > > > > > > > > > > > > + return > true; > > > > > > > > > > > > > > > + } > > > > > > > > > > > > > > > + > > > > > > > > > > > > > > > /** > > > > > > > > > > > > > > > * Get the > components > > > > array > > > > > > > > > narrowed > > > > > > > > > > > to a > > > > > > > > > > > > > > Transformer[]. > > > > > > > > > > > > > > > * @return > > > > Transformer[] > > > > > > > > > > > > > > > Index: > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > src/core/net/sf/morph/transform/ImpreciseConverter.java > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > =================================================================== > > > > > > > > > > > > > > > --- > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > src/core/net/sf/morph/transform/ImpreciseConverter.java > > > > > > > > > > > > > > (revision > > > > > > > > > > > > > > > 0) > > > > > > > > > > > > > > > +++ > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > src/core/net/sf/morph/transform/ImpreciseConverter.java > > > > > > > > > > > > > > (revision > > > > > > > > > > > > > > > 0) > > > > > > > > > > > > > > > @@ -0,0 +1,32 @@ > > > > > > > > > > > > > > > +/* > > > > > > > > > > > > > > > + * Copyright 2008 the > > > > original > > > > > > author > > > > > > > > > or > > > > > > > > > > > > > authors. > > > > > > > > > > > > > > > + * > > > > > > > > > > > > > > > + * Licensed under the > > > Apache > > > > > > License, > > > > > > > > > > > Version > > > > > > > > > > > > > 2.0 > > > > > > > > > > > > > > (the "License"); you > > > > > > > > > > > > > > > may not > > > > > > > > > > > > > > > + * use this file except > in > > > > > > compliance > > > > > > > > > with > > > > > > > > > > > the > > > > > > > > > > > > > > License. You may obtain a > > > > > > > > > > > > > > > copy of > > > > > > > > > > > > > > > + * the License at > > > > > > > > > > > > > > > + * > > > > > > > > > > > > > > > + * > > > > > > > > > > > > > > > http://www.apache.org/licenses/LICENSE-2.0 > > > > > > > > > > > > > > > + * > > > > > > > > > > > > > > > + * Unless required by > > > > applicable > > > > > > law or > > > > > > > > > > > agreed > > > > > > > > > > > > > to > > > > > > > > > > > > > > in writing, software > > > > > > > > > > > > > > > + * distributed under > the > > > > License > > > > > > is > > > > > > > > > > > distributed > > > > > > > > > > > > > > on an "AS IS" BASIS, > > > > > > > > > > > > > > > WITHOUT > > > > > > > > > > > > > > > + * WARRANTIES OR > CONDITIONS > > > > OF > > > > > > ANY > > > > > > > > > KIND, > > > > > > > > > > > either > > > > > > > > > > > > > > express or implied. See > > > > > > > > > > > > > > > the > > > > > > > > > > > > > > > + * License for the > specific > > > > > > language > > > > > > > > > > > governing > > > > > > > > > > > > > > permissions and > > > > > > > > > > > > > > > limitations under > > > > > > > > > > > > > > > + * the License. > > > > > > > > > > > > > > > + */ > > > > > > > > > > > > > > > +package > > > > net.sf.morph.transform; > > > > > > > > > > > > > > > + > > > > > > > > > > > > > > > +/** > > > > > > > > > > > > > > > + * Defines a converter > > > whose > > > > > > operation > > > > > > > > > may > > > > > > > > > > > > > result > > > > > > > > > > > > > > in a loss of data > > > > > > > > > > > > > > > precision. > > > > > > > > > > > > > > > + * > > > > > > > > > > > > > > > + * @author mbenson > > > > > > > > > > > > > > > + * @since Morph 1.0.2 > > > > > > > > > > > > > > > + */ > > > > > > > > > > > > > > > +public interface > > > > > > ImpreciseConverter > > > > > > > > > extends > > > > > > > > > > > > > > Converter { > > > > > > > > > > > > > > > + /** > > > > > > > > > > > > > > > + * Learn whether > the > > > > > > specified > > > > > > > > > > > > > conversion > > > > > > > > > > > > > > might yield an imprecise > > > > > > > > > > > > > > > result. > > > > > > > > > > > > > > > + * @param > > > > destinationClass > > > > > > > > > > > > > > > + * @param > > > sourceClass > > > > > > > > > > > > > > > + * @return > boolean > > > > > > > > > > > > > > > + */ > > > > > > > > > > > > > > > + boolean > > > > > > > > > isImpreciseConversion(Class > > > > > > > > > > > > > > destinationClass, Class > > > > > > > > > > > > > > > sourceClass); > > > > > > > > > > > > > > > +} > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Property changes on: > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > src/core/net/sf/morph/transform/ImpreciseConverter.java > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > ___________________________________________________________________ > > > > > > > > > > > > > > > Name: svn:eol-style > > > > > > > > > > > > > > > + native > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Index: > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > src/core/net/sf/morph/transform/converters/ObjectToTextConverter.java > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > =================================================================== > > > > > > > > > > > > > > > --- > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > src/core/net/sf/morph/transform/converters/ObjectToTextConverter.java > > > > > > > > > > > > > > > (revision 362) > > > > > > > > > > > > > > > +++ > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > src/core/net/sf/morph/transform/converters/ObjectToTextConverter.java > > > > > > > > > > > > > > > (working copy) > > > > > > > > > > > > > > > @@ -20,7 +20,9 @@ > > > > > > > > > > > > > > > import > > > net.sf.morph.Defaults; > > > > > > > > > > > > > > > import > > > > > > > > > net.sf.morph.transform.Converter; > > > > > > > > > > > > > > > import > > > > > > > > > > > > > > > > > > > net.sf.morph.transform.DecoratedConverter; > > > > > > > > > > > > > > > +import > > > > > > > > > > > > > > > > > > > net.sf.morph.transform.ImpreciseConverter; > > > > > > > > > > > > > > > import > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > net.sf.morph.transform.transformers.BaseTransformer; > > > > > > > > > > > > > > > +import > > > > > > > > > net.sf.morph.util.TransformerUtils; > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > /** > > > > > > > > > > > > > > > * Converts an object to > a > > > > textual > > > > > > > > > > > > > representation > > > > > > > > > > > > > > by calling the object's > > > > > > > > > > > > > > > @@ -32,7 +34,7 @@ > > > > > > > > > > > > > > > * @author Matt Sgarlata > > > > > > > > > > > > > > > * @since Dec 24, 2004 > > > > > > > > > > > > > > > */ > > > > > > > > > > > > > > > -public class > > > > > > ObjectToTextConverter > > > > > > > > > extends > > > > > > > > > > > > > > BaseTransformer implements > > > > > > > > > > > > > > > DecoratedConverter { > > > > > > > > > > > > > > > +public class > > > > > > ObjectToTextConverter > > > > > > > > > extends > > > > > > > > > > > > > > BaseTransformer implements > > > > > > > > > > > > > > > DecoratedConverter, > > > > > > ImpreciseConverter { > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > private Converter > > > > > > textConverter; > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > @@ -52,6 +54,13 @@ > > > > > > > > > > > > > > > /** > > > > > > > > > > > > > > > * {@inheritDoc} > > > > > > > > > > > > > > > */ > > > > > > > > > > > > > > > + protected > boolean > > > > > > > > > > > > > > > > > isImpreciseConversionImpl(Class > > > > > > > > > > > > > > > destinationClass, Class > > > > > > sourceClass) { > > > > > > > > > > > > > > > + return > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > TransformerUtils.isImpreciseConversion(getTextConverter(), > > > > > > > > > > > > > > > destinationClass, > > > > String.class); > > > > > > > > > > > > > > > + } > > > > > > > > > > > > > > > + > > > > > > > > > > > > > > > + /** > > > > > > > > > > > > > > > + * {@inheritDoc} > > > > > > > > > > > > > > > + */ > > > > > > > > > > > > > > > protected boolean > > > > > > > > > > > > > > > isWrappingRuntimeExceptions() > > > { > > > > > > > > > > > > > > > return true; > > > > > > > > > > > > > > > } > > > > > > > > > > > > > > > Index: > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > src/core/net/sf/morph/transform/converters/TextToNumberConverter.java > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > =================================================================== > > > > > > > > > > > > > > > --- > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > src/core/net/sf/morph/transform/converters/TextToNumberConverter.java > > > > > > > > > > > > > > > (revision 361) > > > > > > > > > > > > > > > +++ > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > src/core/net/sf/morph/transform/converters/TextToNumberConverter.java > > > > > > > > > > > > > > > (wor... [truncated message content] |