01: /*
02: * Copyright 2005-2006 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
05: * in compliance with the License. You may obtain a copy of the License at
06: *
07: * http://www.apache.org/licenses/LICENSE-2.0
08: *
09: * Unless required by applicable law or agreed to in writing, software distributed under the License
10: * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11: * or implied. See the License for the specific language governing permissions and limitations under
12: * the License.
13: */
14:
15: package org.strecks.message;
16:
17: import java.util.Locale;
18:
19: import org.apache.struts.util.MessageResources;
20: import org.strecks.util.Assert;
21:
22: /**
23: * Basic implementation of <code>MessageResourcesHelper</code>
24: * @author Phil Zoio
25: */
26: public class MessageResourcesHelperImpl implements
27: MessageResourcesHelper {
28:
29: private MessageResources resources;
30:
31: private Locale locale;
32:
33: /**
34: * Instantiates helper class
35: * @param locale
36: * the current request locale. May be null
37: * @param resources
38: * the message resources bundle. Cannot be null
39: */
40: public MessageResourcesHelperImpl(Locale locale,
41: MessageResources resources) {
42: super ();
43: Assert.notNull(resources);
44:
45: this .locale = locale;
46: this .resources = resources;
47: }
48:
49: public String getMessage(String key) {
50: return resources.getMessage(locale, key);
51: }
52:
53: public String getMessage(String key, Object... params) {
54: return resources.getMessage(locale, key, params);
55: }
56:
57: /* *********************** package level getters ********************* */
58:
59: public Locale getLocale() {
60: return locale;
61: }
62:
63: public MessageResources getMessageResources() {
64: return resources;
65: }
66:
67: }
|