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.ResourceBundle;
22: import java.util.Enumeration;
23:
24: import org.apache.beehive.netui.util.internal.InternalStringBuilder;
25:
26: /**
27: */
28: class ResourceBundleNode extends BundleNode {
29:
30: private ResourceBundle _bundle;
31:
32: ResourceBundleNode(ResourceBundle resourceBundle) {
33: _bundle = resourceBundle;
34: }
35:
36: public boolean containsKey(String key) {
37: return _bundle != null && _bundle.getString(key) != null;
38: }
39:
40: public String getString(String key) {
41: return _bundle != null ? _bundle.getString(key) : null;
42: }
43:
44: public Enumeration getKeys() {
45: return _bundle != null ? _bundle.getKeys() : null;
46: }
47:
48: public String toString() {
49: InternalStringBuilder sb = new InternalStringBuilder();
50: sb.append("ResourceBundleNode ");
51: Enumeration keys = getKeys();
52: if (keys != null) {
53: boolean first = true;
54: sb.append("{");
55: while (keys.hasMoreElements()) {
56: if (!first)
57: sb.append(",");
58: else
59: first = false;
60:
61: String key = (String) keys.nextElement();
62: sb.append(key);
63: sb.append("=");
64: sb.append(getString(key));
65: }
66: sb.append("}");
67: }
68: return sb.toString();
69: }
70: }
|