1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * 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
18 package org.apache.commons.resources.impl;
19
20 import org.apache.commons.resources.Resources;
21 import org.apache.commons.resources.ResourcesException;
22
23 /**
24 * <p>Concrete implementation of {@link org.apache.commons.resources.ResourcesFactory} that creates
25 * {@link org.apache.commons.resources.Resources} instances that wrap a set (one per Locale) of
26 * <code>java.util.ResourceBundle</code> instances that share a common
27 * base name. The configuration String that is passed to the
28 * <code>getResources()</code> method must contain the fully qualified
29 * Java name of the underlying <code>ResourceBundle</code> family
30 * that is to be wrapped.</p>
31 */
32 public class ResourceBundleResourcesFactory extends ResourcesFactoryBase {
33
34
35 // --------------------------------------------------------- Public Methods
36
37
38 // ------------------------------------------------------ Protected Methods
39
40
41 /**
42 * <p>Create and return a new {@link org.apache.commons.resources.Resources} instance with the
43 * specified logical name, after calling its <code>init()</code>
44 * method and delegating the relevant properties.</p>
45 *
46 * @param name Logical name of the {@link org.apache.commons.resources.Resources} instance to create
47 * @param config Configuration string for this resource (if any)
48 * @return The new Resources instance.
49 *
50 * @exception ResourcesException if a {@link org.apache.commons.resources.Resources} instance
51 * of the specified logical name cannot be created.
52 */
53 protected Resources createResources(String name, String config) {
54
55 Resources res = new ResourceBundleResources(name, config);
56 res.setReturnNull(isReturnNull());
57 res.init();
58 return (res);
59
60 }
61
62
63 }