KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > avalon > excalibur > i18n > ConfigurableBundleInfo


1 /*
2  * Copyright (C) The Apache Software Foundation. All rights reserved.
3  *
4  * This software is published under the terms of the Apache Software License
5  * version 1.1, a copy of which has been included with this distribution in
6  * the LICENSE.txt file.
7  */

8 package org.apache.avalon.excalibur.i18n;
9
10 import java.util.Locale JavaDoc;
11
12 import org.apache.avalon.framework.configuration.Configurable;
13 import org.apache.avalon.framework.configuration.Configuration;
14 import org.apache.avalon.framework.configuration.ConfigurationException;
15
16 /**
17  * Used to map locale information to URI space, to find the relevant bundle.
18  *
19  * @author <a HREF="mailto:neeme@apache.org">Neeme Praks</a>
20  * @version CVS $Revision: 1.1 $ $Date: 2002/01/02 19:04:56 $ $Author: neeme $
21  */

22 public class ConfigurableBundleInfo extends BundleInfo implements Configurable {
23
24     public ConfigurableBundleInfo() {
25         this(null, null, null);
26     }
27
28     public ConfigurableBundleInfo(String JavaDoc name, Locale JavaDoc locale) {
29         configure(name, locale, null);
30     }
31
32     public ConfigurableBundleInfo(String JavaDoc name, Locale JavaDoc locale, String JavaDoc ext) {
33         configure(name, locale, ext);
34     }
35
36     public void configure(String JavaDoc name, Locale JavaDoc locale, String JavaDoc ext) {
37         setName(name);
38         setLocale(locale);
39         setExtensionParameter(ext);
40     }
41
42     public void configure(String JavaDoc name, Locale JavaDoc locale) {
43         configure(name, locale, null);
44     }
45
46     public void configure(Locale JavaDoc locale) {
47         configure(null, locale);
48     }
49
50     public void configure(Configuration conf) {
51         Locale JavaDoc locale = null;
52         try {
53             Configuration localeConf = conf.getChild("locale");
54             locale = new Locale JavaDoc(localeConf.getAttribute("language"), localeConf.getAttribute("country"));
55             locale = new Locale JavaDoc(localeConf.getAttribute("language"), localeConf.getAttribute("country"),
56                                 localeConf.getAttribute("variant"));
57         }
58         catch (ConfigurationException e) {
59             // ignore
60
}
61
62         String JavaDoc bundleName = null;
63         try {
64             bundleName = conf.getAttribute("name");
65         }
66         catch (ConfigurationException e) {
67             // ignore
68
}
69
70         String JavaDoc ext = null;
71         try {
72             ext = conf.getAttribute("ext");
73         }
74         catch (ConfigurationException e) {
75             // ignore
76
}
77         configure(bundleName, locale, ext);
78     }
79
80 }
81
Popular Tags