コード例 #1
0
 Dictionary<String, String> getHeaders(String localeString) {
   if (localeString == null) localeString = Locale.getDefault().toString();
   if (localeString.length() == 0) return rawHeaders;
   boolean isDefaultLocale = localeString.equals(Locale.getDefault().toString());
   Dictionary<String, String> currentDefault = defaultLocaleHeaders;
   if (isDefaultLocale && currentDefault != null) {
     return currentDefault;
   }
   if (generation
       .getRevision()
       .getRevisions()
       .getModule()
       .getState()
       .equals(Module.State.UNINSTALLED)) {
     // defaultLocaleHeaders should have been initialized on uninstall
     if (currentDefault != null) return currentDefault;
     return rawHeaders;
   }
   ResourceBundle localeProperties = getResourceBundle(localeString, isDefaultLocale);
   Enumeration<String> eKeys = this.rawHeaders.keys();
   Headers<String, String> localeHeaders = new Headers<String, String>(this.rawHeaders.size());
   while (eKeys.hasMoreElements()) {
     String key = eKeys.nextElement();
     String value = this.rawHeaders.get(key);
     if (value.startsWith("%") && (value.length() > 1)) { // $NON-NLS-1$
       String propertiesKey = value.substring(1);
       try {
         value =
             localeProperties == null
                 ? propertiesKey
                 : (String) localeProperties.getObject(propertiesKey);
       } catch (MissingResourceException ex) {
         value = propertiesKey;
       }
     }
     localeHeaders.set(key, value);
   }
   localeHeaders.setReadOnly();
   if (isDefaultLocale) {
     defaultLocaleHeaders = localeHeaders;
   }
   return (localeHeaders);
 }