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.util.Locale;
19  
20  import de.smartics.exceptions.CoreException;
21  import de.smartics.exceptions.i18n.message.MessageType;
22  import de.smartics.exceptions.i18n.message.Messages;
23  
24  /**
25   * Provides access to the localized exception implementations through a common
26   * interface.
27   */
28  public interface LocalizedException extends CoreException
29  {
30    // ********************************* Fields *********************************
31  
32    // --- constants ------------------------------------------------------------
33  
34    // ****************************** Initializer *******************************
35  
36    // ****************************** Inner Classes *****************************
37  
38    // ********************************* Methods ********************************
39  
40    // --- get&set --------------------------------------------------------------
41  
42    // --- business -------------------------------------------------------------
43  
44    /**
45     * Returns the message for the given message type and the system's default
46     * locale.
47     *
48     * @param messageType the type if message to return.
49     * @return the message for the given message type.
50     */
51    String getMessage(MessageType messageType);
52  
53    /**
54     * Returns the message for the given message type.
55     *
56     * @param locale the locale to select the localized message.
57     * @param messageType the type if message to return.
58     * @return the message for the given message type.
59     */
60    String getMessage(Locale locale, MessageType messageType);
61  
62    /**
63     * Returns the messages in one string. Useful to make a dump of all text
64     * information for all {@link MessageType message types} for debugging.
65     *
66     * @param locale the locale to use for the dump.
67     * @return a dump of all {@link MessageType types} of messages.
68     */
69    String getMessages(Locale locale);
70  
71    /**
72     * Returns the messages in one string. Useful to make a dump of all text
73     * information for all {@link MessageType message types} for debugging.
74     * <p>
75     * Uses the default locale to access the messages.
76     * </p>
77     *
78     * @return a dump of all {@link MessageType types} of messages.
79     */
80    String getMessages();
81  
82    /**
83     * Returns a created messages instance.
84     *
85     * @param locale the locale to use for the dump.
86     * @return messages of all {@link MessageType types}.
87     */
88    Messages createMessages(Locale locale);
89  
90    /**
91     * Returns a created messages instance.
92     * <p>
93     * Uses the default locale to access the messages.
94     * </p>
95     *
96     * @return messages of all {@link MessageType types}.
97     */
98    Messages createMessages();
99  
100   /**
101    * Returns the cause trail of messages. These are all messages of the cause to
102    * the root cause.
103    *
104    * @return the cause trail of messages.
105    */
106   CauseTrailMessages getCauseTrail();
107 
108   /**
109    * Returns the cause trail of messages. These are all messages of the cause to
110    * the root cause.
111    *
112    * @param locale the locale to use for the dump.
113    * @return the cause trail of messages.
114    */
115   CauseTrailMessages getCauseTrail(Locale locale);
116 
117   // --- object basics --------------------------------------------------------
118 }