1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.commons.chain.web;
17
18
19 import java.util.Locale;
20 import org.apache.commons.chain.Command;
21 import org.apache.commons.chain.Context;
22
23
24 /***
25 * <p>Abstract base {@link Command} implementation for setting the
26 * response locale for this response to the <code>Locale</code> stored
27 * under the context attribute key returned by the <code>localeKey</code>
28 * property.</p>
29 *
30 * @author Craig R. McClanahan
31 * @version $Revision: 1.5 $ $Date: 2004/02/25 00:01:06 $
32 */
33
34 public abstract class AbstractSetLocaleCommand implements Command {
35
36
37
38
39
40 /***
41 * <p>The context attribute key used to retrieve the <code>Locale</code>.</p>
42 */
43 private String localeKey = "locale";
44
45
46 /***
47 * <p>Return the context attribute key under which we will retrieve
48 * the response <code>Locale</code>.</p>
49 */
50 public String getLocaleKey() {
51
52 return (this.localeKey);
53
54 }
55
56
57 /***
58 * <p>Set the context attribute key under which we will retrieve
59 * the response <code>Locale</code>.</p>
60 *
61 * @param localeKey The new context attribute key
62 */
63 public void setLocaleKey(String localeKey) {
64
65 this.localeKey = localeKey;
66
67 }
68
69
70
71
72
73 /***
74 * <p>Retrieve the <code>Locale</code> stored under the specified
75 * context attribute key, and establish it on this response.</p>
76 *
77 * @param context The {@link Context} we are operating on
78 *
79 * @return <code>false</code> so that processng will continue
80 */
81 public boolean execute(Context context) throws Exception {
82
83 setLocale(context,
84 (Locale) context.get(getLocaleKey()));
85 return (false);
86
87 }
88
89
90
91
92
93 /***
94 * <p>Establish the specified <code>Locale</code> for this response.</p>
95 */
96 protected abstract void setLocale(Context context, Locale locale);
97
98
99 }