1 8 package org.apache.avalon.excalibur.i18n; 9 10 import java.util.Locale ; 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 22 public class ConfigurableBundleInfo extends BundleInfo implements Configurable { 23 24 public ConfigurableBundleInfo() { 25 this(null, null, null); 26 } 27 28 public ConfigurableBundleInfo(String name, Locale locale) { 29 configure(name, locale, null); 30 } 31 32 public ConfigurableBundleInfo(String name, Locale locale, String ext) { 33 configure(name, locale, ext); 34 } 35 36 public void configure(String name, Locale locale, String ext) { 37 setName(name); 38 setLocale(locale); 39 setExtensionParameter(ext); 40 } 41 42 public void configure(String name, Locale locale) { 43 configure(name, locale, null); 44 } 45 46 public void configure(Locale locale) { 47 configure(null, locale); 48 } 49 50 public void configure(Configuration conf) { 51 Locale locale = null; 52 try { 53 Configuration localeConf = conf.getChild("locale"); 54 locale = new Locale (localeConf.getAttribute("language"), localeConf.getAttribute("country")); 55 locale = new Locale (localeConf.getAttribute("language"), localeConf.getAttribute("country"), 56 localeConf.getAttribute("variant")); 57 } 58 catch (ConfigurationException e) { 59 } 61 62 String bundleName = null; 63 try { 64 bundleName = conf.getAttribute("name"); 65 } 66 catch (ConfigurationException e) { 67 } 69 70 String ext = null; 71 try { 72 ext = conf.getAttribute("ext"); 73 } 74 catch (ConfigurationException e) { 75 } 77 configure(bundleName, locale, ext); 78 } 79 80 } 81 | Popular Tags |