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 a constant value of an item value.
29 *
30 * @author <a href="mailto:kriede@users.sourceforge.net">Kurt Riede</a>
31 */
32 public final class ConstantMapper extends BaseDMapper {
33
34 /*** Notes item name in the Notes document. */
35 private String itemName;
36
37 /*** Constant value. */
38 private String constant;
39
40 /***
41 * Constructor. Creates a constant mapper where the Notes item name is equal
42 * to the <tt>itemName</tt> attribute and the value if the item will always
43 * be the given constant. The business object will never be changed by this
44 * mapper.
45 *
46 * @param itemName name of Notes item
47 * @param constant the constant value for the item
48 */
49 public ConstantMapper(final String itemName, final String constant) {
50 this.itemName = itemName;
51 this.constant = constant;
52 }
53
54 /***
55 * Performs the direct mapping from a document to a business object.
56 *
57 * @param document the Notes document
58 * @param object the business object
59 * @throws MappingException if an error occurred during mapping
60 */
61 public void map(final DDocument document, final Object object) throws MappingException {
62 }
63
64 /***
65 * Performs the direct mapping from a business object to a document.
66 *
67 * @param object the business object
68 * @param document the Notes document
69 * @throws MappingException if an error occurred during mapping
70 */
71 public void map(final Object object, final DDocument document) throws MappingException {
72 document.replaceItemValue(itemName, constant);
73 }
74 }