类java.util.ListResourceBundle源码实例Demo

下面列出了怎么用java.util.ListResourceBundle的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: jdk1.8-source-analysis   文件: SecuritySupport.java
/**
 * Gets a resource bundle using the specified base name and locale, and the caller's class loader.
 * @param bundle the base name of the resource bundle, a fully qualified class name
 * @param locale the locale for which a resource bundle is desired
 * @return a resource bundle for the given base name and locale
 */
public static ListResourceBundle getResourceBundle(final String bundle, final Locale locale) {
    return AccessController.doPrivileged(new PrivilegedAction<ListResourceBundle>() {
        public ListResourceBundle run() {
            try {
                return (ListResourceBundle)ResourceBundle.getBundle(bundle, locale);
            } catch (MissingResourceException e) {
                try {
                    return (ListResourceBundle)ResourceBundle.getBundle(bundle, new Locale("en", "US"));
                } catch (MissingResourceException e2) {
                    throw new MissingResourceException(
                            "Could not load any resource bundle by " + bundle, bundle, "");
                }
            }
        }
    });
}
 
源代码2 项目: jdk1.8-source-analysis   文件: SecuritySupport.java
/**
 * Gets a resource bundle using the specified base name and locale, and the
 * caller's class loader.
 *
 * @param bundle the base name of the resource bundle, a fully qualified
 * class name
 * @param locale the locale for which a resource bundle is desired
 * @return a resource bundle for the given base name and locale
 */
public static ListResourceBundle getResourceBundle(final String bundle, final Locale locale) {
    return AccessController.doPrivileged(new PrivilegedAction<ListResourceBundle>() {
        public ListResourceBundle run() {
            try {
                return (ListResourceBundle) ResourceBundle.getBundle(bundle, locale);
            } catch (MissingResourceException e) {
                try {
                    return (ListResourceBundle) ResourceBundle.getBundle(bundle, new Locale("en", "US"));
                } catch (MissingResourceException e2) {
                    throw new MissingResourceException(
                            "Could not load any resource bundle by " + bundle, bundle, "");
                }
            }
        }
    });
}
 
源代码3 项目: TencentKona-8   文件: NewResourcesNames.java
/**
 * Loads a resources using JRE and returns the names
 */
private static Set<String> loadClass(String clazz) throws Exception {
    ListResourceBundle lrb =
            (ListResourceBundle)Class.forName(clazz).newInstance();
    Set<String> keys = lrb.keySet();
    Map<String,String> newold = new HashMap<String,String>();
    boolean dup = false;
    // Check if normalize() creates dup entries. This is crucial.
    for (String k: keys) {
        String key = normalize(k);
        if (newold.containsKey(key)) {
            err("Dup found for " + key + ":");
            err("["+newold.get(key)+"]");
            err("["+k+"]");
            dup = true;
        }
        newold.put(key, k);
    }
    if (dup) throw new Exception();
    return keys;
}
 
源代码4 项目: TencentKona-8   文件: SecuritySupport.java
/**
 * Gets a resource bundle using the specified base name and locale, and the caller's class loader.
 * @param bundle the base name of the resource bundle, a fully qualified class name
 * @param locale the locale for which a resource bundle is desired
 * @return a resource bundle for the given base name and locale
 */
public static ListResourceBundle getResourceBundle(final String bundle, final Locale locale) {
    return AccessController.doPrivileged(new PrivilegedAction<ListResourceBundle>() {
        public ListResourceBundle run() {
            try {
                return (ListResourceBundle)ResourceBundle.getBundle(bundle, locale);
            } catch (MissingResourceException e) {
                try {
                    return (ListResourceBundle)ResourceBundle.getBundle(bundle, new Locale("en", "US"));
                } catch (MissingResourceException e2) {
                    throw new MissingResourceException(
                            "Could not load any resource bundle by " + bundle, bundle, "");
                }
            }
        }
    });
}
 
源代码5 项目: TencentKona-8   文件: SecuritySupport.java
/**
 * Gets a resource bundle using the specified base name and locale, and the
 * caller's class loader.
 *
 * @param bundle the base name of the resource bundle, a fully qualified
 * class name
 * @param locale the locale for which a resource bundle is desired
 * @return a resource bundle for the given base name and locale
 */
public static ListResourceBundle getResourceBundle(final String bundle, final Locale locale) {
    return AccessController.doPrivileged(new PrivilegedAction<ListResourceBundle>() {
        public ListResourceBundle run() {
            try {
                return (ListResourceBundle) ResourceBundle.getBundle(bundle, locale);
            } catch (MissingResourceException e) {
                try {
                    return (ListResourceBundle) ResourceBundle.getBundle(bundle, new Locale("en", "US"));
                } catch (MissingResourceException e2) {
                    throw new MissingResourceException(
                            "Could not load any resource bundle by " + bundle, bundle, "");
                }
            }
        }
    });
}
 
源代码6 项目: jdk8u60   文件: NewResourcesNames.java
/**
 * Loads a resources using JRE and returns the names
 */
private static Set<String> loadClass(String clazz) throws Exception {
    ListResourceBundle lrb =
            (ListResourceBundle)Class.forName(clazz).newInstance();
    Set<String> keys = lrb.keySet();
    Map<String,String> newold = new HashMap<String,String>();
    boolean dup = false;
    // Check if normalize() creates dup entries. This is crucial.
    for (String k: keys) {
        String key = normalize(k);
        if (newold.containsKey(key)) {
            err("Dup found for " + key + ":");
            err("["+newold.get(key)+"]");
            err("["+k+"]");
            dup = true;
        }
        newold.put(key, k);
    }
    if (dup) throw new Exception();
    return keys;
}
 
源代码7 项目: jdk8u60   文件: SecuritySupport.java
/**
 * Gets a resource bundle using the specified base name and locale, and the caller's class loader.
 * @param bundle the base name of the resource bundle, a fully qualified class name
 * @param locale the locale for which a resource bundle is desired
 * @return a resource bundle for the given base name and locale
 */
public static ListResourceBundle getResourceBundle(final String bundle, final Locale locale) {
    return AccessController.doPrivileged(new PrivilegedAction<ListResourceBundle>() {
        public ListResourceBundle run() {
            try {
                return (ListResourceBundle)ResourceBundle.getBundle(bundle, locale);
            } catch (MissingResourceException e) {
                try {
                    return (ListResourceBundle)ResourceBundle.getBundle(bundle, new Locale("en", "US"));
                } catch (MissingResourceException e2) {
                    throw new MissingResourceException(
                            "Could not load any resource bundle by " + bundle, bundle, "");
                }
            }
        }
    });
}
 
源代码8 项目: jdk8u60   文件: SecuritySupport.java
/**
 * Gets a resource bundle using the specified base name and locale, and the
 * caller's class loader.
 *
 * @param bundle the base name of the resource bundle, a fully qualified
 * class name
 * @param locale the locale for which a resource bundle is desired
 * @return a resource bundle for the given base name and locale
 */
public static ListResourceBundle getResourceBundle(final String bundle, final Locale locale) {
    return AccessController.doPrivileged(new PrivilegedAction<ListResourceBundle>() {
        public ListResourceBundle run() {
            try {
                return (ListResourceBundle) ResourceBundle.getBundle(bundle, locale);
            } catch (MissingResourceException e) {
                try {
                    return (ListResourceBundle) ResourceBundle.getBundle(bundle, new Locale("en", "US"));
                } catch (MissingResourceException e2) {
                    throw new MissingResourceException(
                            "Could not load any resource bundle by " + bundle, bundle, "");
                }
            }
        }
    });
}
 
源代码9 项目: JDKSourceCode1.8   文件: SecuritySupport.java
/**
 * Gets a resource bundle using the specified base name and locale, and the caller's class loader.
 * @param bundle the base name of the resource bundle, a fully qualified class name
 * @param locale the locale for which a resource bundle is desired
 * @return a resource bundle for the given base name and locale
 */
public static ListResourceBundle getResourceBundle(final String bundle, final Locale locale) {
    return AccessController.doPrivileged(new PrivilegedAction<ListResourceBundle>() {
        public ListResourceBundle run() {
            try {
                return (ListResourceBundle)ResourceBundle.getBundle(bundle, locale);
            } catch (MissingResourceException e) {
                try {
                    return (ListResourceBundle)ResourceBundle.getBundle(bundle, new Locale("en", "US"));
                } catch (MissingResourceException e2) {
                    throw new MissingResourceException(
                            "Could not load any resource bundle by " + bundle, bundle, "");
                }
            }
        }
    });
}
 
源代码10 项目: Pydev   文件: AdditionalInfoIntegrityChecker.java
@Override
public void onCreateActions(ListResourceBundle resources, final BaseEditor baseEditor, IProgressMonitor monitor) {
    IPyEdit edit = (IPyEdit) baseEditor;
    edit.addOfflineActionListener("--internal-test-modules", new Action() {
        @Override
        public void run() {
            List<IPythonNature> allPythonNatures = PythonNature.getAllPythonNatures();
            StringBuffer buf = new StringBuffer();
            try {
                for (IPythonNature nature : allPythonNatures) {
                    buf.append(checkIntegrity(nature, new NullProgressMonitor(), true));
                }
            } catch (MisconfigurationException e) {
                buf.append(e.getMessage());
            }
            PyDialogHelpers.showString(buf.toString());
        }
    }, "Used just for testing (do not use).", true);
}
 
源代码11 项目: openjdk-jdk8u   文件: SecuritySupport.java
/**
 * Gets a resource bundle using the specified base name and locale, and the caller's class loader.
 * @param bundle the base name of the resource bundle, a fully qualified class name
 * @param locale the locale for which a resource bundle is desired
 * @return a resource bundle for the given base name and locale
 */
public static ListResourceBundle getResourceBundle(final String bundle, final Locale locale) {
    return AccessController.doPrivileged(new PrivilegedAction<ListResourceBundle>() {
        public ListResourceBundle run() {
            try {
                return (ListResourceBundle)ResourceBundle.getBundle(bundle, locale);
            } catch (MissingResourceException e) {
                try {
                    return (ListResourceBundle)ResourceBundle.getBundle(bundle, new Locale("en", "US"));
                } catch (MissingResourceException e2) {
                    throw new MissingResourceException(
                            "Could not load any resource bundle by " + bundle, bundle, "");
                }
            }
        }
    });
}
 
源代码12 项目: openjdk-jdk8u   文件: SecuritySupport.java
/**
 * Gets a resource bundle using the specified base name and locale, and the
 * caller's class loader.
 *
 * @param bundle the base name of the resource bundle, a fully qualified
 * class name
 * @param locale the locale for which a resource bundle is desired
 * @return a resource bundle for the given base name and locale
 */
public static ListResourceBundle getResourceBundle(final String bundle, final Locale locale) {
    return AccessController.doPrivileged(new PrivilegedAction<ListResourceBundle>() {
        public ListResourceBundle run() {
            try {
                return (ListResourceBundle) ResourceBundle.getBundle(bundle, locale);
            } catch (MissingResourceException e) {
                try {
                    return (ListResourceBundle) ResourceBundle.getBundle(bundle, new Locale("en", "US"));
                } catch (MissingResourceException e2) {
                    throw new MissingResourceException(
                            "Could not load any resource bundle by " + bundle, bundle, "");
                }
            }
        }
    });
}
 
源代码13 项目: openjdk-jdk8u-backup   文件: NewResourcesNames.java
/**
 * Loads a resources using JRE and returns the names
 */
private static Set<String> loadClass(String clazz) throws Exception {
    ListResourceBundle lrb =
            (ListResourceBundle)Class.forName(clazz).newInstance();
    Set<String> keys = lrb.keySet();
    Map<String,String> newold = new HashMap<String,String>();
    boolean dup = false;
    // Check if normalize() creates dup entries. This is crucial.
    for (String k: keys) {
        String key = normalize(k);
        if (newold.containsKey(key)) {
            err("Dup found for " + key + ":");
            err("["+newold.get(key)+"]");
            err("["+k+"]");
            dup = true;
        }
        newold.put(key, k);
    }
    if (dup) throw new Exception();
    return keys;
}
 
源代码14 项目: Pydev   文件: PyEditNotifier.java
/**
 * Notifies listeners that the actions have just been created in the editor.
 */
public void notifyOnCreateActions(final ListResourceBundle resources) {
    final BaseEditor edit = pyEdit.get();
    if (edit == null) {
        return;
    }
    INotifierRunnable runnable = new INotifierRunnable() {
        @Override
        public void run(final IProgressMonitor monitor) {
            for (IPyEditListener listener : edit.getAllListeners()) {
                try {
                    if (!monitor.isCanceled()) {
                        listener.onCreateActions(resources, edit, monitor);
                    }
                } catch (Exception e) {
                    //must not fail
                    Log.log(e);
                }
            }
        }
    };
    runIt(runnable);
}
 
源代码15 项目: openjdk-jdk9   文件: NewResourcesNames.java
/**
 * Loads a resources using JRE and returns the names
 */
private static Set<String> loadClass(String clazz) throws Exception {
    ListResourceBundle lrb =
            (ListResourceBundle)Class.forName(clazz).newInstance();
    Set<String> keys = lrb.keySet();
    Map<String,String> newold = new HashMap<String,String>();
    boolean dup = false;
    // Check if normalize() creates dup entries. This is crucial.
    for (String k: keys) {
        String key = normalize(k);
        if (newold.containsKey(key)) {
            err("Dup found for " + key + ":");
            err("["+newold.get(key)+"]");
            err("["+k+"]");
            dup = true;
        }
        newold.put(key, k);
    }
    if (dup) throw new Exception();
    return keys;
}
 
源代码16 项目: openjdk-jdk9   文件: SecuritySupport.java
/**
 * Gets a resource bundle using the specified base name and locale, and the
 * caller's class loader.
 *
 * @param bundle the base name of the resource bundle, a fully qualified
 * class name
 * @param locale the locale for which a resource bundle is desired
 * @return a resource bundle for the given base name and locale
 */
public static ListResourceBundle getResourceBundle(final String bundle, final Locale locale) {
    return AccessController.doPrivileged(new PrivilegedAction<ListResourceBundle>() {
        public ListResourceBundle run() {
            try {
                return (ListResourceBundle) ResourceBundle.getBundle(bundle, locale);
            } catch (MissingResourceException e) {
                try {
                    return (ListResourceBundle) ResourceBundle.getBundle(bundle, new Locale("en", "US"));
                } catch (MissingResourceException e2) {
                    throw new MissingResourceException(
                            "Could not load any resource bundle by " + bundle, bundle, "");
                }
            }
        }
    });
}
 
@Override
public void onCreateActions(ListResourceBundle resources, BaseEditor baseEditor, IProgressMonitor monitor) {
    //Note: can be called multiple times (will only create handlers for the new actions).
    Map<String, InteractiveCommandCustomHandler> commandIdToHandler = InteractiveConsoleCommand
            .getCommandIdToHandler();
    Set<Entry<String, InteractiveCommandCustomHandler>> entrySet = commandIdToHandler.entrySet();
    for (Entry<String, InteractiveCommandCustomHandler> entry : entrySet) {
        if (idToAction.containsKey(entry.getKey())) {
            continue;
        }
        InteractiveConsoleUserCommandAction action = new InteractiveConsoleUserCommandAction(resources,
                "Pyedit.InteractiveConsoleUserCommand", baseEditor, entry.getKey());
        action.setActionDefinitionId(entry.getKey());
        action.setId(entry.getKey());
        baseEditor.setAction(FullRepIterable.getLastPart(entry.getKey()), action);
        idToAction.put(entry.getKey(), action);
    }
    this.resources = resources;
    this.weakEditor = new WeakReference<>(baseEditor);
    InteractiveConsoleCommand.onCommandIdToHandlerChanged.registerListener(onCommandIdToHandlerChangedCallback);
}
 
源代码18 项目: hottub   文件: NewResourcesNames.java
/**
 * Loads a resources using JRE and returns the names
 */
private static Set<String> loadClass(String clazz) throws Exception {
    ListResourceBundle lrb =
            (ListResourceBundle)Class.forName(clazz).newInstance();
    Set<String> keys = lrb.keySet();
    Map<String,String> newold = new HashMap<String,String>();
    boolean dup = false;
    // Check if normalize() creates dup entries. This is crucial.
    for (String k: keys) {
        String key = normalize(k);
        if (newold.containsKey(key)) {
            err("Dup found for " + key + ":");
            err("["+newold.get(key)+"]");
            err("["+k+"]");
            dup = true;
        }
        newold.put(key, k);
    }
    if (dup) throw new Exception();
    return keys;
}
 
源代码19 项目: hottub   文件: SecuritySupport.java
/**
 * Gets a resource bundle using the specified base name and locale, and the caller's class loader.
 * @param bundle the base name of the resource bundle, a fully qualified class name
 * @param locale the locale for which a resource bundle is desired
 * @return a resource bundle for the given base name and locale
 */
public static ListResourceBundle getResourceBundle(final String bundle, final Locale locale) {
    return AccessController.doPrivileged(new PrivilegedAction<ListResourceBundle>() {
        public ListResourceBundle run() {
            try {
                return (ListResourceBundle)ResourceBundle.getBundle(bundle, locale);
            } catch (MissingResourceException e) {
                try {
                    return (ListResourceBundle)ResourceBundle.getBundle(bundle, new Locale("en", "US"));
                } catch (MissingResourceException e2) {
                    throw new MissingResourceException(
                            "Could not load any resource bundle by " + bundle, bundle, "");
                }
            }
        }
    });
}
 
源代码20 项目: hottub   文件: SecuritySupport.java
/**
 * Gets a resource bundle using the specified base name and locale, and the
 * caller's class loader.
 *
 * @param bundle the base name of the resource bundle, a fully qualified
 * class name
 * @param locale the locale for which a resource bundle is desired
 * @return a resource bundle for the given base name and locale
 */
public static ListResourceBundle getResourceBundle(final String bundle, final Locale locale) {
    return AccessController.doPrivileged(new PrivilegedAction<ListResourceBundle>() {
        public ListResourceBundle run() {
            try {
                return (ListResourceBundle) ResourceBundle.getBundle(bundle, locale);
            } catch (MissingResourceException e) {
                try {
                    return (ListResourceBundle) ResourceBundle.getBundle(bundle, new Locale("en", "US"));
                } catch (MissingResourceException e2) {
                    throw new MissingResourceException(
                            "Could not load any resource bundle by " + bundle, bundle, "");
                }
            }
        }
    });
}
 
源代码21 项目: openjdk-8-source   文件: SecuritySupport.java
/**
 * Gets a resource bundle using the specified base name and locale, and the caller's class loader.
 * @param bundle the base name of the resource bundle, a fully qualified class name
 * @param locale the locale for which a resource bundle is desired
 * @return a resource bundle for the given base name and locale
 */
public static ListResourceBundle getResourceBundle(final String bundle, final Locale locale) {
    return AccessController.doPrivileged(new PrivilegedAction<ListResourceBundle>() {
        public ListResourceBundle run() {
            try {
                return (ListResourceBundle)ResourceBundle.getBundle(bundle, locale);
            } catch (MissingResourceException e) {
                try {
                    return (ListResourceBundle)ResourceBundle.getBundle(bundle, new Locale("en", "US"));
                } catch (MissingResourceException e2) {
                    throw new MissingResourceException(
                            "Could not load any resource bundle by " + bundle, bundle, "");
                }
            }
        }
    });
}
 
源代码22 项目: openjdk-8-source   文件: SecuritySupport.java
/**
 * Gets a resource bundle using the specified base name and locale, and the
 * caller's class loader.
 *
 * @param bundle the base name of the resource bundle, a fully qualified
 * class name
 * @param locale the locale for which a resource bundle is desired
 * @return a resource bundle for the given base name and locale
 */
public static ListResourceBundle getResourceBundle(final String bundle, final Locale locale) {
    return AccessController.doPrivileged(new PrivilegedAction<ListResourceBundle>() {
        public ListResourceBundle run() {
            try {
                return (ListResourceBundle) ResourceBundle.getBundle(bundle, locale);
            } catch (MissingResourceException e) {
                try {
                    return (ListResourceBundle) ResourceBundle.getBundle(bundle, new Locale("en", "US"));
                } catch (MissingResourceException e2) {
                    throw new MissingResourceException(
                            "Could not load any resource bundle by " + bundle, bundle, "");
                }
            }
        }
    });
}
 
源代码23 项目: vraptor4   文件: JstlLocalizationTest.java
@Before
public void setUp() {
	request = mock(HttpServletRequest.class);
	servletContext = mock(ServletContext.class);
	session = mock(HttpSession.class);

	localization = new JstlLocalization(request);

	ResourceBundle bundle = new ListResourceBundle() {
		@Override
		protected Object[][] getContents() {
			return new Object[][] { { "my.key", "abc" } };
		}
	};

	LocalizationContext context = new LocalizationContext(bundle);
	when(request.getAttribute(FMT_LOCALIZATION_CONTEXT + ".request")).thenReturn(context);

	when(request.getSession(false)).thenReturn(session);
	when(request.getServletContext()).thenReturn(servletContext);
}
 
源代码24 项目: pentaho-reporting   文件: Prd5262IT.java
protected ExpressionRuntime createRuntime() throws ReportProcessingException {
  ResourceBundle b = new ListResourceBundle() {
    protected Object[][] getContents() {
      return new Object[][] { { "format", "$(date,date,yyyy-MM-dd'T'HH:mm:ss,SSSZZZ)" } };
    }
  };

  ResourceBundleFactory f = Mockito.mock( ResourceBundleFactory.class );
  Mockito.when( f.getLocale() ).thenReturn( Locale.US );
  Mockito.when( f.getTimeZone() ).thenReturn( TimeZone.getTimeZone( "PST" ) );
  Mockito.when( f.getResourceBundle( "test" ) ).thenReturn( b );

  ProcessingContext pc = Mockito.mock( ProcessingContext.class );
  Mockito.when( pc.getResourceBundleFactory() ).thenReturn( f );

  DataRow r = Mockito.mock( DataRow.class );
  Mockito.when( r.get( "number" ) ).thenReturn( new Double( 123456.78901 ) );
  Mockito.when( r.get( "date" ) ).thenReturn( new Date( 1234567890123l ) );

  return new DebugExpressionRuntime( r, new DefaultTableModel(), 0, pc );
}
 
源代码25 项目: Pydev   文件: EvaluateActionSetter.java
/**
 * This method associates Ctrl+new line with the evaluation of commands in the console.
 */
@Override
public void onCreateActions(ListResourceBundle resources, final BaseEditor baseEditor, IProgressMonitor monitor) {
    final PyEdit edit = (PyEdit) baseEditor;
    final EvaluateAction evaluateAction = new EvaluateAction(edit);
    evaluateAction.setActionDefinitionId(IInteractiveConsoleConstants.EVALUATE_ACTION_ID);
    evaluateAction.setId(IInteractiveConsoleConstants.EVALUATE_ACTION_ID);
    Runnable runnable = new Runnable() {
        @Override
        public void run() {
            if (!edit.isDisposed()) {
                edit.setAction(IInteractiveConsoleConstants.EVALUATE_ACTION_ID, evaluateAction);
            }
        }
    };
    Display.getDefault().syncExec(runnable);
}
 
源代码26 项目: jdk8u_jdk   文件: NewResourcesNames.java
/**
 * Loads a resources using JRE and returns the names
 */
private static Set<String> loadClass(String clazz) throws Exception {
    ListResourceBundle lrb =
            (ListResourceBundle)Class.forName(clazz).newInstance();
    Set<String> keys = lrb.keySet();
    Map<String,String> newold = new HashMap<String,String>();
    boolean dup = false;
    // Check if normalize() creates dup entries. This is crucial.
    for (String k: keys) {
        String key = normalize(k);
        if (newold.containsKey(key)) {
            err("Dup found for " + key + ":");
            err("["+newold.get(key)+"]");
            err("["+k+"]");
            dup = true;
        }
        newold.put(key, k);
    }
    if (dup) throw new Exception();
    return keys;
}
 
源代码27 项目: jdk8u-jdk   文件: NewResourcesNames.java
/**
 * Loads a resources using JRE and returns the names
 */
private static Set<String> loadClass(String clazz) throws Exception {
    ListResourceBundle lrb =
            (ListResourceBundle)Class.forName(clazz).newInstance();
    Set<String> keys = lrb.keySet();
    Map<String,String> newold = new HashMap<String,String>();
    boolean dup = false;
    // Check if normalize() creates dup entries. This is crucial.
    for (String k: keys) {
        String key = normalize(k);
        if (newold.containsKey(key)) {
            err("Dup found for " + key + ":");
            err("["+newold.get(key)+"]");
            err("["+k+"]");
            dup = true;
        }
        newold.put(key, k);
    }
    if (dup) throw new Exception();
    return keys;
}
 
源代码28 项目: jdk8u-dev-jdk   文件: NewResourcesNames.java
/**
 * Loads a resources using JRE and returns the names
 */
private static Set<String> loadClass(String clazz) throws Exception {
    ListResourceBundle lrb =
            (ListResourceBundle)Class.forName(clazz).newInstance();
    Set<String> keys = lrb.keySet();
    Map<String,String> newold = new HashMap<String,String>();
    boolean dup = false;
    // Check if normalize() creates dup entries. This is crucial.
    for (String k: keys) {
        String key = normalize(k);
        if (newold.containsKey(key)) {
            err("Dup found for " + key + ":");
            err("["+newold.get(key)+"]");
            err("["+k+"]");
            dup = true;
        }
        newold.put(key, k);
    }
    if (dup) throw new Exception();
    return keys;
}
 
源代码29 项目: j2objc   文件: Logger.java
private static ResourceBundle findSystemResourceBundle(final Locale locale) {
  // J2ObjC: inlined contents of sun/util/logging/resources/logging/logging.properties
  return new ListResourceBundle() {
    @Override
    protected Object[][] getContents() {
      return new Object[][] {
        { "ALL", "ALL" },
        { "SEVERE", "SEVERE" },
        { "WARNING", "WARNING" },
        { "INFO", "INFO" },
        { "CONFIG", "CONFIG" },
        { "FINE", "FINE" },
        { "FINER", "FINER" },
        { "FINEST", "FINEST" },
        { "OFF", "OFF" }
      };
    }
  };
}
 
@Provides @Named(SetSecurityAnswersHandler.NAME_RESOURCE_BUNDLE)
public ResourceBundle stubSecurityQuestionBundle() {
   return new ListResourceBundle()
   {
      @Override
      protected Object[][] getContents()
      {
         return new Object[][] {
            { "questionA", "Mother's maiden name?" },
            { "questionB", "Father's middle name?" },
            { "questionC", "First car?" },
         };
      }
   };
}
 
 类所在包
 同包方法