01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: *
17: * $Header:$
18: */
19: package org.apache.beehive.netui.script.common.bundle;
20:
21: import java.util.Locale;
22: import java.util.Enumeration;
23:
24: import org.apache.struts.util.MessageResources;
25: import org.apache.beehive.netui.util.internal.InternalStringBuilder;
26:
27: /**
28: */
29: class StrutsBundleNode extends BundleNode {
30:
31: private Locale _locale;
32: private MessageResources _messageResource;
33:
34: StrutsBundleNode(Locale locale, MessageResources messageResource) {
35: _locale = locale;
36: _messageResource = messageResource;
37: }
38:
39: public boolean containsKey(String key) {
40: assert _messageResource != null;
41: return _messageResource.getMessage(_locale, key) != null;
42: }
43:
44: public String getString(String key) {
45: assert _messageResource != null;
46: return _messageResource.getMessage(_locale, key);
47: }
48:
49: public Enumeration getKeys() {
50: throw new UnsupportedOperationException(
51: "The getKeys() method is not supported on the MessageResources type.");
52: }
53:
54: public String toString() {
55: InternalStringBuilder sb = new InternalStringBuilder();
56: sb.append("StrutsBundleNode ");
57: sb.append("messageResource: ");
58: sb.append(_messageResource);
59: sb.append(" ");
60: sb.append("locale: ");
61: sb.append(_locale);
62: return sb.toString();
63: }
64: }
|