View Javadoc

1   /*
2    * Copyright 2007-2011 smartics, Kronseder & Reiner GmbH
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package de.smartics.exceptions.i18n;
17  
18  import java.util.Locale;
19  import java.util.ResourceBundle;
20  
21  import de.smartics.exceptions.i18n.message.MessageType;
22  
23  /**
24   * The message composer creates messages from message templates by replacing the
25   * place holders with localized parameter values.
26   *
27   * @author <a href="mailto:robert.reiner@smartics.de">Robert Reiner</a>
28   * @version $Revision$
29   */
30  public interface MessageComposer
31  {
32    // ********************************* Fields *********************************
33  
34    // --- constants ------------------------------------------------------------
35  
36    // ****************************** Inner Classes *****************************
37  
38    // ********************************* Methods ********************************
39  
40    // --- get&set --------------------------------------------------------------
41  
42    // --- business -------------------------------------------------------------
43  
44    /**
45     * Creates the message from the message template.
46     *
47     * @param exception the instance with the values for the message template's
48     *          parameters.
49     * @param locale the locale to use to format the arguments within the
50     *          template.
51     * @param bundle the resource bundle to fetch the message from.
52     * @param keyPrefix the prefix to the key to fetch the message from the
53     *          bundle. The suffix is provided by the message type.
54     * @param messageType the type of message to format. This allows to access the
55     *          correct index of the exception's value within the template.
56     * @return the message constructed from the template and the exception's
57     *         member values.
58     */
59    String composeMessage(Throwable exception, Locale locale,
60        ResourceBundle bundle, String keyPrefix, MessageType messageType);
61  
62    // --- object basics --------------------------------------------------------
63  }