01: /*
02: * Copyright 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.mvel;
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 MVEL expressions.
25: *
26: * @author Shellman, Dan
27: */
28: public class MvelResourceMessage extends MvelMessage {
29: protected ConfiguredResource resource;
30: protected String key;
31:
32: /**
33: * Default constructor.
34: */
35: public MvelResourceMessage(ConfiguredResource theResource,
36: String theKey) {
37: resource = theResource;
38: key = theKey;
39: } //end MvelResourceMessage()
40:
41: /**
42: * Retrieves the template from the resource using the key provided.
43: *
44: * @param locale The locale to use in determining the template.
45: *
46: * @return Returns the template from the resource using the key.
47: */
48: public String getTemplate(Locale locale) {
49: return resource.getValue(key, locale);
50: } //end getTemplate()
51:
52: /**
53: * For debug info.
54: *
55: * @return Returns debug info.
56: */
57: public String toString() {
58: return key + "=" + resource.getValue(key, Locale.getDefault());
59: } //end toString()
60: } //end MvelResourceMessage
|