01: /*
02: * Copyright 2006 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.impl;
17:
18: import java.util.Locale;
19:
20: /**
21: * A ResourceValue is a combination of a key and the Resource that's
22: * associated with it. Fundamentally, then, an instance of this class
23: * represents a value within a Resource prior to "realizing" that value.
24: *
25: * @author Shellman, Dan
26: */
27: public class ResourceValue {
28: protected Resource resource;
29: protected String key;
30: protected String value;
31:
32: /**
33: * Construct with given resource and key.
34: *
35: * @param theResource The Resource.
36: * @param theKey The key to the value within the Resource.
37: */
38: public ResourceValue(Resource theResource, String theKey) {
39: resource = theResource;
40: key = theKey;
41: } //end ResourceValue()
42:
43: /**
44: * Construct with the given value. In this case, no resource or key
45: * are involved.
46: *
47: * @param theValue The value of this resource/key pair.
48: */
49: public ResourceValue(String theValue) {
50: value = theValue;
51: } //end ResourceValue()
52:
53: /**
54: * Retrieves the value associated with this key/resource pair that
55: * this instance represents.
56: *
57: * @param locale The locale to use in getting the value.
58: *
59: * @return Returns the value associated with the key and Resource.
60: */
61: public String getValue(Locale locale) {
62: if (value != null) {
63: return value;
64: }
65:
66: return resource.getValue(key, locale);
67: } //end getValue()
68: } //end ResourceValue
|