01: /*
02: * Copyright 2006-2007 Dan Shellman
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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 org.iscreen.ognl;
17:
18: import java.util.Locale;
19:
20: import org.iscreen.impl.ConfiguredResource;
21:
22: /**
23: * This resource message is pulled from a resource and then converted
24: * based upon the contained OGNL expressions.
25: *
26: * @author Shellman, Dan
27: */
28: public class OgnlResourceMessage extends OgnlMessage {
29: protected ConfiguredResource resource;
30: protected String key;
31:
32: /**
33: * Constructor requiring a resource and resource key.
34: *
35: * @param theResource The configured resource
36: * @param theKey The resource key
37: */
38: public OgnlResourceMessage(ConfiguredResource theResource,
39: String theKey) {
40: resource = theResource;
41: key = theKey;
42: } //end OgnlResourceMessage()
43:
44: /**
45: * Retrieves the template from the resource using the key provided.
46: *
47: * @param locale The locale to use in determining the template.
48: *
49: * @return Returns the template from the resource using the key.
50: */
51: public String getTemplate(Locale locale) {
52: return resource.getValue(key, locale);
53: } //end getTemplate()
54:
55: /**
56: * For debug info.
57: *
58: * @return Returns debug info.
59: */
60: public String toString() {
61: return key + "=" + resource.getValue(key, Locale.getDefault());
62: } //end toString()
63: } //end OgnlResourceMessage
|