Currently Dozer supports two types of mapping between collections: cumulative and non-cumulative.
If you are mapping to a Class which has already been initialized, dozer will either 'add' or 'update' objects to your List. If your List or Set already has objects in it dozer checks the mapped List, Set, or Array and calls the contains() method to determine if it needs to 'add' or 'update'. This is determined using the relationship-type attribute on the field tag. The default is 'cumulative'.
We sometimes initialize the target object to hold an array of size 10 (for example). The object array is filled with default values (not nulls). When mapping the source array which has only 5 (for example)elements (not nulls) to the target array we expect to have in the target array 10 elements; 5 from the original array and the last 5 are the last five elements of the original, filled with default values (in this specific order).
We need a third option for list mapping "by-index" which will update according to order of elements (according to List definition). Meaning, position 0 will map to position 0, etc (perform mapping between the elements of the same index).
Included in the attached file are:
1)dozer files:
a)the dozerbeanmapping.dtd (added "by-index")
b)2 source files (MappingProcessor.java ; MapperConstants.java). Lines which are suffixed with "//yoni" were added by myself
2)test files:
a)indexedMapper.xml - the mapping file
b)Indexed.java - the main class. In general it maps between types of objects (ArrayList to array. array to array etc.). The sub-objects residing in the main-objects can be a String or a complicated object. It is possible to determine what the source and targets are by setting the variable "SOURCE_DESTINATION_TYPE" accordingly.
c)other java sources for the test
The dozer version we are using is 3.3.1
Thanks
the modified sources and my test
Logged In: YES
user_id=1236069
Originator: NO
I was not able to apply this patch because it was applied to an old code base. A lot has changed since 3.3.1, so I was not able to translate it to the current code base. If you wanted to apply it to the 4.1 code base, we could take a look. Thanks.
Logged In: YES
user_id=1893277
Originator: YES
The files are now compatible with version 4.2.
Because I see that the dozerbeanmapping.dtd does not have the hard-coded values for 'relationship-type', the file was not modified.
As before, lines which have the comment //yoni were added/modified.
Thanks
File Added: indexed_new.zip
files
Logged In: YES
user_id=1312539
Originator: NO
This Tracker item was closed automatically by the system. It was
previously set to a Pending status, and the original submitter
did not respond within 14 days (the time period specified by
the administrator of this Tracker).
Logged In: YES
user_id=1893277
Originator: YES
Please see followup from 2008-04-02. Thanks
Logged In: YES
user_id=1312539
Originator: NO
This Tracker item was closed automatically by the system. It was
previously set to a Pending status, and the original submitter
did not respond within 14 days (the time period specified by
the administrator of this Tracker).
The indexed_new.jar appeared to be missing files. i.e) MappingProcessor, etc