1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 package org.apache.commons.resources.impl;
25
26 import org.apache.commons.resources.Resources;
27 import org.apache.commons.resources.ResourcesException;
28
29 /***
30 * <p>Concrete implementation of {@link org.apache.commons.resources.ResourcesFactory} that creates
31 * {@link org.apache.commons.resources.Resources} instances that wrap a family (one per Locale) of
32 * XML documents that share a base URL and have name suffices reflecting
33 * the Locale for which the document's messages apply. Resources are
34 * looked up in a hierarchy of documents in a manner identical to that
35 * performed by <code>java.util.ResourceBundle.getBundle()</code>.</p>
36 *
37 * <p>The configuration variable passed to the <code>createResources()</code>
38 * method must be the URL of the base name of the XML document family.
39 * For example, if the configuration URL is passed as
40 * <code>http://localhost/foo/Bar</code>, the resources for the
41 * <code>en_US</code> Locale would be stored under URL
42 * <code>http://localhost/foo/Bar_en_US.xml</code>, and the default
43 * resources would be stored in
44 * <code>http://localhost/foo/Bar.xml</code>.</p>
45 */
46 public class XMLResourcesFactory extends ResourcesFactoryBase {
47
48 /***
49 * <p>Create and return a new {@link org.apache.commons.resources.Resources} instance with the
50 * specified logical name, after calling its <code>init()</code>
51 * method and delegating the relevant properties.</p>
52 *
53 * @param name Logical name of the {@link org.apache.commons.resources.Resources} instance to create
54 * @param config Configuration string for this resource (if any)
55 * @return The new Resources instance.
56 *
57 * @exception ResourcesException if a {@link org.apache.commons.resources.Resources} instance
58 * of the specified logical name cannot be created.
59 */
60 protected Resources createResources(String name, String config) {
61
62 Resources res = new XMLResources(name, config);
63 res.setReturnNull(isReturnNull());
64 res.init();
65 return (res);
66
67 }
68
69
70 }