本文整理汇总了Java中java.util.ListResourceBundle类的典型用法代码示例。如果您正苦于以下问题:Java ListResourceBundle类的具体用法?Java ListResourceBundle怎么用?Java ListResourceBundle使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ListResourceBundle类属于java.util包,在下文中一共展示了ListResourceBundle类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getResourceBundle
import java.util.ListResourceBundle; //导入依赖的package包/类
/**
* 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: getResourceBundle
import java.util.ListResourceBundle; //导入依赖的package包/类
/**
* 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: loadClass
import java.util.ListResourceBundle; //导入依赖的package包/类
/**
* 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: AbstractConverter
import java.util.ListResourceBundle; //导入依赖的package包/类
/**
* @deprecated Construtor para AbstractConverter contendo os formatadores de
* convers�o padr�o<br>
* � altamente recomend�vel que se construa este objeto
* informando o resourceBundle de internacionalizacao
*/
public AbstractConverter() {
logger
.warn("ATENCAO!! CONSTRUINDO UM RESOURCE BUNDLE COM A INTERNACIONALIZA��O DE "
+ "FORMATOS PADR�O!!!. ISTO PODE COMPROMETER A PORTABILIDADE DA APLICACAO");
ResourceBundle resourceBundle = new ListResourceBundle() {
protected Object[][] getContents() {
String valores[][] = {
{ PROPERTY_FORMATO_DATA_VIEW, DEFAULT_FORMATO_DATA },
{ PROPERTY_DECIMAL_SEPARATOR, DEFAULT_DECIMAL_SEPARATOR },
{ PROPERTY_GROUPING_SEPARATOR,
DEFAULT_GROUPING_SEPARATOR },
{ PROPERTY_FORMATO_SHORT, DEFAULT_FORMATO_SHORT },
{ PROPERTY_FORMATO_INTEGER, DEFAULT_FORMATO_INTEGER },
{ PROPERTY_FORMATO_LONG, DEFAULT_FORMATO_LONG },
{ PROPERTY_FORMATO_FLOAT, DEFAULT_FORMATO_FLOAT },
{ PROPERTY_FORMATO_DOUBLE, DEFAULT_FORMATO_DOUBLE } };
return valores;
}
};
setResourceBundle(resourceBundle);
}
示例5: getResourceBundle
import java.util.ListResourceBundle; //导入依赖的package包/类
@POST
@Path( "/wildcard" )
public ResourceBundle getResourceBundle( ResourceBundleRequest resourceBundleRequest ) {
final List<ResourceBundle> resourceBundles = new ArrayList<ResourceBundle>( );
for ( ResourceBundleWildcard resourceBundleWildcard : resourceBundleRequest.getWildcards() ) {
Pattern keyPattern = Pattern.compile( resourceBundleWildcard.getKeyRegex() );
resourceBundles.addAll( getResourceBundles( keyPattern, getLocale( resourceBundleRequest.getLocale() ) ) );
}
return new ListResourceBundle() {
@Override protected Object[][] getContents() {
List<Object[]> entries = new ArrayList<Object[]>();
for ( ResourceBundle resourceBundle : resourceBundles ) {
for ( String key : Collections.list( resourceBundle.getKeys() ) ) {
entries.add( new Object[] { key, resourceBundle.getString( key ) } );
}
}
return entries.toArray( new Object[ entries.size() ][] );
}
};
}
示例6: onCreateActions
import java.util.ListResourceBundle; //导入依赖的package包/类
@Override
public void onCreateActions(ListResourceBundle resources, final BaseEditor baseEditor, IProgressMonitor monitor) {
PyEdit edit = (PyEdit) 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());
}
UIUtils.showString(buf.toString());
}
}, "Used just for testing (do not use).", true);
}
示例7: notifyOnCreateActions
import java.util.ListResourceBundle; //导入依赖的package包/类
/**
* 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);
}
示例8: onCreateActions
import java.util.ListResourceBundle; //导入依赖的package包/类
/**
* 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);
}
示例9: onCreateActions
import java.util.ListResourceBundle; //导入依赖的package包/类
@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);
}
示例10: setUp
import java.util.ListResourceBundle; //导入依赖的package包/类
@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);
}
示例11: call
import java.util.ListResourceBundle; //导入依赖的package包/类
public Object call() throws Exception {
LogRecord lg = new LogRecord(Level.ALL, getMessage());
lg.setResourceBundle(new ListResourceBundle() {
protected Object[][] getContents() {
return new Object[][] { {getMessage(), getMessage()} };
}
});
return new LogRecord[] { lg };
}
示例12: AbstractConverter
import java.util.ListResourceBundle; //导入依赖的package包/类
/**
* @deprecated Construtor para AbstractConverter contendo os formatadores de conversao padrAo<br>
* e altamente recomendAvel que se construa este objeto informando o resourceBundle de internacionalizacao
*/
public AbstractConverter() {
logger.warn("ATENCAO!! CONSTRUINDO UM RESOURCE BUNDLE COM A INTERNACIONALIZAcao DE " + "FORMATOS PADRAO!!!. ISTO PODE COMPROMETER A PORTABILIDADE DA APLICACAO");
ResourceBundle resourceBundle = new ListResourceBundle() {
protected Object[][] getContents() {
String valores[][] = { { PROPERTY_FORMATO_DATA_VIEW, DEFAULT_FORMATO_DATA }, { PROPERTY_DECIMAL_SEPARATOR, DEFAULT_DECIMAL_SEPARATOR }, { PROPERTY_GROUPING_SEPARATOR, DEFAULT_GROUPING_SEPARATOR }, { PROPERTY_FORMATO_SHORT, DEFAULT_FORMATO_SHORT }, { PROPERTY_FORMATO_INTEGER, DEFAULT_FORMATO_INTEGER }, { PROPERTY_FORMATO_LONG, DEFAULT_FORMATO_LONG },
{ PROPERTY_FORMATO_FLOAT, DEFAULT_FORMATO_FLOAT }, { PROPERTY_FORMATO_DOUBLE, DEFAULT_FORMATO_DOUBLE } };
return valores;
}
};
setResourceBundle(resourceBundle);
}
示例13: getDefaultBuildInfo
import java.util.ListResourceBundle; //导入依赖的package包/类
private static BuildInfo getDefaultBuildInfo() {
return new BuildInfo(
new ListResourceBundle() {
@Override
public Object[][] getContents() {
return new Object[][] {
{ "svnVersion", "345M", },
{ "timestamp", "January 1, 2007", },
};
}
});
}
示例14: testConvertResourceBundle_add2558
import java.util.ListResourceBundle; //导入依赖的package包/类
@org.junit.Test(timeout = 1000)
public void testConvertResourceBundle_add2558() {
fr.inria.diversify.testamplification.logger.Logger.writeTestStart(Thread.currentThread(),this, "testConvertResourceBundle_add2558");
final Map<java.lang.String, java.lang.String> in = new HashMap<java.lang.String, java.lang.String>(5 , 1);
in.put("1", "A");
in.put("1", "A");
in.put("2", "B");
in.put("3", "C");
in.put("4", "D");
in.put("5", "E");
final ResourceBundle b = new ListResourceBundle() {
@Override
public Object[][] getContents() {
final Object[][] contents = new Object[in.size()][2];
final Iterator<java.lang.String> i = in.keySet().iterator();
int n = 0;
while (i.hasNext()) {
final Object key = i.next();
final Object val = in.get(key);
contents[n][0] = key;
contents[n][1] = val;
++n;
}
return contents;
}
};
final Map<java.lang.String, java.lang.Object> out = org.apache.commons.collections4.MapUtils.toMap(b);
fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),7777,in,7776,in.equals(out));
fr.inria.diversify.testamplification.logger.Logger.writeTestFinish(Thread.currentThread());
}
示例15: testConvertResourceBundle_add2559
import java.util.ListResourceBundle; //导入依赖的package包/类
@org.junit.Test(timeout = 1000)
public void testConvertResourceBundle_add2559() {
fr.inria.diversify.testamplification.logger.Logger.writeTestStart(Thread.currentThread(),this, "testConvertResourceBundle_add2559");
final Map<java.lang.String, java.lang.String> in = new HashMap<java.lang.String, java.lang.String>(5 , 1);
in.put("1", "A");
in.put("2", "B");
in.put("2", "B");
in.put("3", "C");
in.put("4", "D");
in.put("5", "E");
final ResourceBundle b = new ListResourceBundle() {
@Override
public Object[][] getContents() {
final Object[][] contents = new Object[in.size()][2];
final Iterator<java.lang.String> i = in.keySet().iterator();
int n = 0;
while (i.hasNext()) {
final Object key = i.next();
final Object val = in.get(key);
contents[n][0] = key;
contents[n][1] = val;
++n;
}
return contents;
}
};
final Map<java.lang.String, java.lang.Object> out = org.apache.commons.collections4.MapUtils.toMap(b);
fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),7777,in,7776,in.equals(out));
fr.inria.diversify.testamplification.logger.Logger.writeTestFinish(Thread.currentThread());
}