Bugs item #1113428, was opened at 2005-01-31 15:32
Message generated for change (Comment added) made by sgarlatm
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=700930&aid=1113428&group_id=124910
Category: None
Group: None
>Status: Closed
Resolution: None
Priority: 9
Submitted By: Nobody/Anonymous (nobody)
Assigned to: Nobody/Anonymous (nobody)
Summary: Contribution to Morph and some fixes for Castor Objects
Initial Comment:
Hi Matt,
I have spent 3 weeks using your excellent Morph
package to solve a deeply nested tree graph
conversion. I successfully completed the "morphing" of
a large XML schema processed by Castor objects into
internal project specific Java Bean representations.
As a result of this work I came up with a few
interesting enhancements to Morph classes as well as a
couple of bug fixes. I am submitting these classes for
your review and possible inclusion into Morph 1.0. I
found the Morph project to be the perfect match for the
task at hand and congratulate you for the excellent
work you produced.
Without further rambling here is what I have to
contribute:
The PropertyNameMappingCopier seems to be a simple
reincarnation of PropertyMatchingCopier. Probably a
result of coding to fast to meet a deadline ;-) I
attached the corrected implementation with some extra
frills. I discovered it was too easy to fumble the
property names and the copiers would happily skip over
the mistyped properties leaving me wondering what
was the problem. To solve this I added a "strict" flag to
the copier that causes a TransformationException to be
thrown when a specified property fails to copy. If I
bothered to specify the property chances are I really
want to know that it did get copied successfully.
Furthermore, the order of copying the mapped
properties is dictated by the Iterator of the Map. Thus if
I use an OrderedHashMap I can control the order for
the copy process.
Another enhancement was that the order of copying
selected properties in the
SelectivePropertyNameMatchingCopier was not set. I
reversed the process by iterating over the properties to
copy instead of the sourceProperties. I also added the
strict flag to this one as well.
Finally, most of my conversions were bidirectional in
the sense I am converting class X to class Y but I would
also want to convert class Y to class X. This was done at
first with a PropertyNameMappingCopier by specifying
the mappings for each direction in the same Map. But it
became obvious that it would be better to make the
PropertyNameMappingCopier handle this. So, the
PropertyNameTwoWayMappingCopier was born. This
allows me to have my strict flag and can copy to/from
easily.
The TimeToNumberConverter and
NumberToTimeConverter gave me trouble at first until I
realized the default assignments for TimeConverter and
NumberConverter were actually wrong. The defaults
used Defaults.CONVERTER instead of
Defaults.TIME_CONVERTER and
Defaults.NUMBER_CONVERTER respectively. I changed
the assignments of the defaults to the specific
converters and the stack overflow exceptions I was
getting were gone. I noticed version 0.8.1 fixed one of
the two, the other one needs fixing as well.
The last problem I encountered was that the Castor
classes I was converting to/from have get/set methods
with non-standard arguments. This was causing
problems that I resolved by modifying the
ObjectReflector class. When the bean ReflectionInfo is
collected I pay attention to the arguments and use the
getter with no arguments and setter with one
argument. For completeness I captured the "indexed"
getter/setter that Castor provides and added an
indexed getter/setter method but did not end up using
it. I do not know if it will be useful. If you like the
changes you can roll them into the current Morph code
base. At least the change to pick the specific no-
argument getter and one argument setter needs to be
there to avoid problems.
Thanks,
Alex Volanis, CISSP
Consultant Software Engineer
RSA Security Inc
----------------------------------------------------------------------
>Comment By: Matt Sgarlata (sgarlatm)
Date: 2005-04-19 18:27
Message:
Logged In: YES
user_id=1161666
These bug fixes and design ideas are implemented in Morph 0.9.1
----------------------------------------------------------------------
Comment By: Matt Sgarlata (sgarlatm)
Date: 2005-02-12 20:20
Message:
Logged In: YES
user_id=1161666
These changes are great! Morph 0.8.2 incorporates most of
them, but there's still more to do to get your fixes 100%
encorporated.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=700930&aid=1113428&group_id=124910
|