View Javadoc

1   /*
2    * This file is part of Domingo
3    * an Open Source Java-API to Lotus Notes/Domino
4    * hosted at http://domingo.sourceforge.net
5    *
6    * Copyright (c) 2003-2007 Beck et al. projects GmbH Munich, Germany (http://www.bea.de)
7    *
8    * This library is free software; you can redistribute it and/or
9    * modify it under the terms of the GNU Lesser General Public
10   * License as published by the Free Software Foundation; either
11   * version 2.1 of the License, or (at your option) any later version.
12   *
13   * This library is distributed in the hope that it will be useful,
14   * but WITHOUT ANY WARRANTY; without even the implied warranty of
15   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16   * Lesser General Public License for more details.
17   *
18   * You should have received a copy of the GNU Lesser General Public
19   * License along with this library; if not, write to the Free Software
20   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
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  }