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: package org.apache.pluto.internal.impl;
18:
19: import org.apache.pluto.util.StringManager;
20:
21: import java.util.ResourceBundle;
22: import java.util.Enumeration;
23: import java.util.HashMap;
24: import java.util.Vector;
25:
26: /**
27: *
28: * @version 1.0
29: * @since Jan 9, 2006
30: */
31: class CombinedPortletResourceBundle extends ResourceBundle {
32:
33: private static final StringManager EXCEPTIONS = StringManager
34: .getManager(CombinedPortletResourceBundle.class
35: .getPackage().getName());
36:
37: private final HashMap contents = new HashMap();
38:
39: public CombinedPortletResourceBundle(
40: InlinePortletResourceBundle inlineBundle,
41: ResourceBundle resourceBundle) {
42: dump(inlineBundle);
43: dump(resourceBundle);
44: }
45:
46: protected Object handleGetObject(String key) {
47: if (key == null) {
48: throw new NullPointerException(EXCEPTIONS
49: .getString("error.null"));
50: }
51: return contents.get(key);
52: }
53:
54: public Enumeration getKeys() {
55: return new Vector(contents.keySet()).elements();
56: }
57:
58: private void dump(ResourceBundle bundle) {
59: Enumeration e = bundle.getKeys();
60: while (e.hasMoreElements()) {
61: String value = e.nextElement().toString();
62: contents.put(value, bundle.getObject(value));
63: }
64: }
65: }
|