コード例 #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);
 }
コード例 #2
0
 @Override
 public Enumeration<URL> getResources(String name) throws IOException {
   try {
     equinoxContainer.checkAdminPermission(this, AdminPermission.RESOURCE);
   } catch (SecurityException e) {
     return null;
   }
   checkValid();
   if (isFragment()) {
     return null;
   }
   ModuleClassLoader classLoader = getModuleClassLoader(false);
   Enumeration<URL> result = null;
   if (classLoader != null) {
     result = classLoader.getResources(name);
   } else {
     result =
         new ClasspathManager((Generation) module.getCurrentRevision().getRevisionInfo(), null)
             .findLocalResources(name);
   }
   return result != null && result.hasMoreElements() ? result : null;
 }