View Javadoc

1   /*
2    * Copyright 2007-2013 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.io.Serializable;
19  import java.util.Locale;
20  
21  import de.smartics.exceptions.core.Code;
22  import de.smartics.exceptions.i18n.message.LocalizedInfo;
23  import de.smartics.exceptions.i18n.message.MessageType;
24  import de.smartics.exceptions.i18n.message.Messages;
25  
26  /**
27   * Message provider. The message provider may be attached to infrastructure to
28   * access message templates and to construct messages.
29   */
30  public interface MessageBean extends Serializable
31  {
32    // ********************************* Fields *********************************
33  
34    // --- constants ------------------------------------------------------------
35  
36    // ****************************** Initializer *******************************
37  
38    // ****************************** Inner Classes *****************************
39  
40    // ********************************* Methods ********************************
41  
42    // --- get&set --------------------------------------------------------------
43  
44    // --- business -------------------------------------------------------------
45  
46    // --- object basics --------------------------------------------------------
47  
48    /**
49     * Returns the code the message bean provides messages for.
50     *
51     * @return the code the message bean provides messages for.
52     */
53    Code getCode();
54  
55    /**
56     * Returns the localized information that provides access to messages.
57     *
58     * @return the localized information that provides access to messages.
59     */
60    LocalizedInfo getLocalizedInfo();
61  
62    /**
63     * Returns the message for the given type.
64     *
65     * @param locale the locale to use.
66     * @param messageType the type of message to retrieve.
67     * @return the message or <code>null</code> if there is no message for the
68     *         given type.
69     */
70    // @CheckForNull
71    String getMessage(Locale locale, MessageType messageType);
72  
73    /**
74     * Returns the messages for the given locale.
75     *
76     * @param locale the locale to use.
77     * @return the set of messages set
78     */
79    Messages getMessages(Locale locale);
80  
81    /**
82     * Returns the cause trail of messages. These are all messages of the cause to
83     * the root cause.
84     *
85     * @return the cause trail of messages.
86     */
87    CauseTrailMessages getCauseTrail();
88  
89    /**
90     * Returns the cause trail of messages. These are all messages of the cause to
91     * the root cause.
92     *
93     * @param locale the locale to use.
94     * @return the cause trail of messages.
95     */
96    CauseTrailMessages getCauseTrail(Locale locale);
97  
98    /**
99     * Returns the cause to the exception. May be <code>null</code>.
100    *
101    * @return the cause to the exception. May be <code>null</code>.
102    */
103   Throwable getCause();
104 }