1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 package de.bea.domingo.map;
24
25 import de.bea.domingo.DDocument;
26
27 /***
28 * Class defining and performing a mapping of an attribute that itself is a
29 * complex sub object of a business object.
30 *
31 * @author <a href="mailto:kriede@users.sourceforge.net">Kurt Riede</a>
32 */
33 public abstract class SubMapper implements Mapper {
34
35 /*** Reference to the associated mapper. */
36 private final Mapper mapper;
37
38 /***
39 * Constructor. Creates a direct mapper where the Notes item name is equal
40 * to the <tt>itemName</tt> attribute and the names of the get/set methods
41 * in the business class are equal to <tt>"get" + itemName</tt> and
42 * <tt>"set" + itemName</tt>.
43 *
44 * @param mapper the mapper for the sub-object
45 */
46 public SubMapper(final Mapper mapper) {
47 this.mapper = mapper;
48 }
49
50 /***
51 * Implementing class must return the sub-object to map.
52 *
53 * @param object base object
54 * @return sub-object
55 */
56 protected abstract Object getObject(final Object object);
57
58 /***
59 * Performs the mapping from a document to a business object.
60 *
61 * @param document the Notes document
62 * @param object the business object
63 * @throws MappingException if an error occurred during mapping
64 */
65 public final void map(final DDocument document, final Object object) throws MappingException {
66 mapper.map(document, getObject(object));
67 }
68
69 /***
70 * Performs the mapping from a business object to a document.
71 *
72 * @param object the business object
73 * @param document the Notes document
74 * @throws MappingException if an error occurred during mapping
75 */
76 public final void map(final Object object, final DDocument document) throws MappingException {
77 mapper.map(getObject(object), document);
78 }
79 }