KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > api > cintoo > messages > MessageHandler


1 /*
2  * Copyright 2006 cintoo, Berlin, Germany
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 api.cintoo.messages;
17
18 import api.cintoo.messages.bundle.BundleManager;
19 import api.cintoo.messages.context.Context;
20
21 import java.util.Locale JavaDoc;
22 import java.util.ResourceBundle JavaDoc;
23
24 /**
25  * Message handler formats texts with arguments.
26  * Texts are read from a resource bundle and retrieved
27  * by a key.
28  *
29  * @author Stephan J. Schmidt
30  * @version $id$
31  * @since 1.0
32  */

33 public interface MessageHandler {
34   /**
35    * Set the locale with the language and country for the
36    * current thread.
37    *
38    * @param language language code of the locale
39    */

40   public void setThreadLocale(String JavaDoc language);
41
42   /**
43    * Set the locale with the language and country for the
44    * current thread.
45    *
46    * @param language language code of the locale
47    * @param country country code of the locale
48    */

49   public void setThreadLocale(String JavaDoc language, String JavaDoc country);
50
51   /**
52    * Set the locale with the language and country for the
53    * current thread.
54    *
55    * @param locale locale to set
56    */

57   public void setThreadLocale(Locale JavaDoc locale);
58
59   /**
60    * Set the locale with the language and country for the
61    * current thread.
62    *
63    * @param language language code of the locale
64    * @param country country code of the locale
65    * @param variant variant code of the locale
66    */

67   public void setThreadLocale(String JavaDoc language, String JavaDoc country, String JavaDoc variant);
68
69   /**
70    * Set globally the locale with the language and country
71    *
72    * @param language language code of the locale
73    */

74   public void setLocale(String JavaDoc language);
75
76   /**
77    * Set globally the locale with the language and country
78    *
79    * @param language language code of the locale
80    * @param country country code of the locale
81    */

82   public void setLocale(String JavaDoc language, String JavaDoc country);
83
84   /**
85    * Set globally the locale with the language and country
86    *
87    * @param language language code of the locale
88    * @param country country code of the locale
89    * @param variant variant code of the locale
90    */

91   public void setLocale(String JavaDoc language, String JavaDoc country, String JavaDoc variant);
92
93   /**
94    * Set globally the locale with the language and country
95    *
96    * @param locale locale to set
97    */

98   public void setLocale(Locale JavaDoc locale);
99
100   /**
101    * Return currently used locale, either for thread or global.
102    *
103    * @return currently used locale
104    */

105   public Locale JavaDoc getLocale();
106
107   /**
108    * Set global bundle name
109    *
110    * @param bundleName bundle name for the bundle to be used
111    */

112   public void setBundle(String JavaDoc bundleName);
113
114   /**
115    * Set bundle for the package scope
116    *
117    * @param bundleName name of the bundle to set
118    * @param packageName package name which defines the scope
119    */

120   public void setBundle(String JavaDoc bundleName, String JavaDoc packageName);
121
122   /**
123    * Set bundle for the context scope
124    *
125    * @param bundleName name of the bundle to set
126    * @param context context wich defines the scope
127    */

128   public void setBundle(String JavaDoc bundleName, Context context);
129
130   public String JavaDoc format(Object JavaDoc context, String JavaDoc key);
131
132   public String JavaDoc format(String JavaDoc key);
133
134   public String JavaDoc format(Object JavaDoc context, String JavaDoc key, Object JavaDoc arg);
135
136   public String JavaDoc format(String JavaDoc key, Object JavaDoc arg);
137
138   public String JavaDoc format(Object JavaDoc context, String JavaDoc key, Object JavaDoc... args);
139
140   public String JavaDoc format(String JavaDoc key, Object JavaDoc... args);
141
142   /**
143    * Return the full scope bundle
144    *
145    * @return bundle with the full scope
146    */

147   public ResourceBundle JavaDoc getBundle();
148
149   /**
150    * Return the bundle for the context
151    *
152    * @param context context for which the bundle should be found
153    * @return corresponding bunlde
154    */

155   public ResourceBundle JavaDoc getBundle(Object JavaDoc context);
156
157   public void setBundleManager(BundleManager manager);
158
159   public void clear();
160 }
161
Popular Tags