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 retrieving the
26 * requested Locale from our {@link Context}, and storing it under the
27 * context attribute key returned by the <code>localeKey</code> property.</p>
28 *
29 * @author Craig R. McClanahan
30 * @version $Revision: 1.5 $ $Date: 2004/02/25 00:01:06 $
31 */
32
33 public abstract class AbstractGetLocaleCommand implements Command {
34
35
36
37
38
39 /***
40 * <p>The context attribute key used to store the <code>Locale</code>.</p>
41 */
42 private String localeKey = "locale";
43
44
45 /***
46 * <p>Return the context attribute key under which we will store
47 * the request <code>Locale</code>.</p>
48 */
49 public String getLocaleKey() {
50
51 return (this.localeKey);
52
53 }
54
55
56 /***
57 * <p>Set the context attribute key under which we will store
58 * the request <code>Locale</code>.</p>
59 *
60 * @param localeKey The new context attribute key
61 */
62 public void setLocaleKey(String localeKey) {
63
64 this.localeKey = localeKey;
65
66 }
67
68
69
70
71
72 /***
73 * <p>Retrieve the <code>Locale</code> for this request, and store it
74 * under the specified context attribute.</p>
75 *
76 * @param context The {@link Context} we are operating on
77 *
78 * @return <code>false</code> so that processng will continue
79 */
80 public boolean execute(Context context) throws Exception {
81
82 context.put(getLocaleKey(), getLocale(context));
83 return (false);
84
85 }
86
87
88
89
90
91 /***
92 * <p>Retrieve and return the <code>Locale</code> for this request.</p>
93 */
94 protected abstract Locale getLocale(Context context);
95
96
97 }