KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > beehive > netui > script > common > bundle > StrutsBundleNode


1 /*
2  * Copyright 2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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  * $Header:$
17  */

18 package org.apache.beehive.netui.script.common.bundle;
19
20 import java.util.Locale JavaDoc;
21 import java.util.Enumeration JavaDoc;
22
23 import org.apache.struts.util.MessageResources;
24 import org.apache.beehive.netui.util.internal.InternalStringBuilder;
25
26 /**
27  */

28 class StrutsBundleNode
29     extends BundleNode {
30
31     private Locale JavaDoc _locale;
32     private MessageResources _messageResource;
33
34     StrutsBundleNode(Locale JavaDoc locale, MessageResources messageResource) {
35         _locale = locale;
36         _messageResource = messageResource;
37     }
38
39     public boolean containsKey(String JavaDoc key) {
40         return _messageResource.getMessage(_locale, key) != null;
41     }
42
43     public String JavaDoc getString(String JavaDoc key) {
44         return _messageResource.getMessage(_locale, key);
45     }
46
47     public Enumeration JavaDoc getKeys() {
48         throw new UnsupportedOperationException JavaDoc("The getKeys() method is not supported on the MessageResources type.");
49     }
50
51     public String JavaDoc toString() {
52         InternalStringBuilder sb = new InternalStringBuilder();
53         sb.append("StrutsBundleNode ");
54         sb.append("messageResource: ");
55         sb.append(_messageResource);
56         sb.append(" ");
57         sb.append("locale: ");
58         sb.append(_locale);
59         return sb.toString();
60     }
61 }
62
Popular Tags